Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """concept_id is string |
||
2 | |||
3 | Revision ID: 88214d86a9d1 |
||
4 | Revises: 79ff53a30228 |
||
5 | Create Date: 2023-01-18 13:17:21.700138 |
||
6 | |||
7 | """ |
||
8 | |||
9 | from alembic import op |
||
10 | import sqlalchemy as sa |
||
11 | |||
12 | |||
13 | # revision identifiers, used by Alembic. |
||
14 | revision = '88214d86a9d1' |
||
15 | down_revision = '79ff53a30228' |
||
16 | |||
17 | |||
18 | def upgrade(): |
||
19 | with op.batch_alter_table('concept') as batch_op: |
||
20 | batch_op.alter_column('concept_id', type_=sa.String, existing_type=sa.Integer) |
||
21 | |||
22 | |||
23 | def downgrade(): |
||
24 | # Drop concepts which have non-integer concept_id |
||
25 | op.execute("DELETE FROM concept WHERE cast(cast(concept_id AS INTEGER) AS TEXT) != concept_id") |
||
26 | with op.batch_alter_table('concept') as batch_op: |
||
27 | batch_op.alter_column('concept_id', existing_type=sa.String, type_=sa.Integer) |
||
28 |