Skip to content

Commit

Permalink
#1897 - participant_id and va_profile_id in VAProfileLocalCache updat…
Browse files Browse the repository at this point in the history
…ed to BigInt
  • Loading branch information
MackHalliday authored Aug 6, 2024
1 parent 926c9d3 commit af2d06e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2176,12 +2176,12 @@ class VAProfileLocalCache(db.Model):

id = db.Column(db.Integer, primary_key=True)
allowed = db.Column(db.Boolean, nullable=False)
va_profile_id = db.Column(db.Integer, nullable=False)
va_profile_id = db.Column(db.BigInteger, nullable=False)
communication_item_id = db.Column(db.Integer, nullable=False)
communication_channel_id = db.Column(db.Integer, nullable=False)
source_datetime = db.Column(db.DateTime, nullable=False)

participant_id = db.Column(db.Integer, nullable=True)
participant_id = db.Column(db.BigInteger, nullable=True)
has_duplicate_mappings = db.Column(db.Boolean, nullable=False, default=False)

__table_args__ = (
Expand Down
53 changes: 53 additions & 0 deletions migrations/versions/0369a_va_profile_cache_fields.py
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 ###

0 comments on commit af2d06e

Please sign in to comment.