forked from cds-snc/notification-api
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1897 - participant_id and va_profile_id in VAProfileLocalCache updat…
…ed to BigInt
- Loading branch information
1 parent
926c9d3
commit af2d06e
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Revision ID:0369a_va_profile_cache_fields | ||
Revises: 0369_va_profile_cache_fields | ||
Create Date: 2024-08-05 15:10:01 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
revision = '0369a_va_profile_cache_fields' | ||
down_revision = '0369_va_profile_cache_fields' | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column('va_profile_local_cache', 'va_profile_id', | ||
existing_type=sa.INTEGER(), | ||
type_=sa.BigInteger(), | ||
existing_nullable=False) | ||
op.alter_column('va_profile_local_cache', 'participant_id', | ||
existing_type=sa.INTEGER(), | ||
type_=sa.BigInteger(), | ||
existing_nullable=True) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
|
||
# Update participant_id to -1 where it cannot be converted back to INTEGER | ||
op.execute(""" | ||
UPDATE va_profile_local_cache | ||
SET participant_id = -1 | ||
WHERE participant_id > 2147483647 | ||
""") | ||
|
||
# Delete rows where va_profile_id cannot be converted back to INTEGER | ||
op.execute(""" | ||
DELETE FROM va_profile_local_cache | ||
WHERE va_profile_id > 2147483647 | ||
""") | ||
|
||
|
||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column('va_profile_local_cache', 'participant_id', | ||
existing_type=sa.BigInteger(), | ||
type_=sa.INTEGER(), | ||
existing_nullable=True) | ||
op.alter_column('va_profile_local_cache', 'va_profile_id', | ||
existing_type=sa.BigInteger(), | ||
type_=sa.INTEGER(), | ||
existing_nullable=False) | ||
# ### end Alembic commands ### |