-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alter ConceptVisitLog concept_id to string.
Issue #906
- Loading branch information
1 parent
63a9633
commit 22c46be
Showing
4 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
atramhasis/alembic/versions/29306f749043_alter_conceptvisitlog_concept_id_to_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""alter ConceptVisitLog concept_id to string | ||
Revision ID: 29306f749043 | ||
Revises: b2a7d7614973 | ||
Create Date: 2024-07-30 09:12:37.521748 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '29306f749043' | ||
down_revision = 'b2a7d7614973' | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table('concept_visit_log') as batch_op: | ||
batch_op.alter_column('concept_id', type_=sa.String, existing_type=sa.Integer) | ||
|
||
|
||
def downgrade(): | ||
# Drop concept_visit_log which have non-integer concept_id | ||
op.execute( | ||
"DELETE FROM concept_visit_log " | ||
"WHERE cast(cast(concept_id AS INTEGER) AS TEXT) != concept_id" | ||
) | ||
with op.batch_alter_table('concept_visit_log') as batch_op: | ||
batch_op.alter_column('concept_id', type_=sa.Integer, existing_type=sa.String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters