From e97ea0f860dd49ea4322e2ac3f615d83daec5169 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Fri, 2 Aug 2024 10:37:51 -0400 Subject: [PATCH 01/12] Squash #1897 - participant_id updated to biginit --- app/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index e5696b6fbd..1469d37fc5 100644 --- a/app/models.py +++ b/app/models.py @@ -2181,7 +2181,7 @@ class VAProfileLocalCache(db.Model): 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__ = ( From 97a3fa880f28bb357965ee4cef99fc046cd0ef15 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 10:05:39 -0400 Subject: [PATCH 02/12] Squash #1897 - Update talismanrc --- .talismanrc | 2 + .../versions/0369a_va_profile_cache_fields.py | 261 ++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 migrations/versions/0369a_va_profile_cache_fields.py diff --git a/.talismanrc b/.talismanrc index 64bd7d7e7d..eebcd57583 100644 --- a/.talismanrc +++ b/.talismanrc @@ -17,6 +17,8 @@ fileignoreconfig: checksum: e06cc6abd755fa5cb5c2b1deceb1a40f87bf9f2b8be73102623cbfe0f28a20cd - filename: ci/.local.env checksum: a2dca7e8e15af2a98112a405725e0b6f07c6adcb61507d8d32715ee17c383b6b +- filename: migrations/versions/0369a_va_profile_cache_fields.py + checksum: 46fc08a846152dde6173054c447d5abbf78708bdbdf2af5dc003c5439f12c618 - filename: poetry.lock checksum: 7a495ebe704b7723f9abfe67d965e53fb3ae830ba537b36a1aa07de4eeecb4fa - filename: tests/app/celery/test_scheduled_tasks.py diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py new file mode 100644 index 0000000000..5773b8a77e --- /dev/null +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -0,0 +1,261 @@ +""" + +Revision ID: 73ba076d31a5 +Revises: 0369_va_profile_cache_fields +Create Date: 2024-08-05 13:51:38.281958 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '73ba076d31a5' +down_revision = '0369_va_profile_cache_fields' + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_foreign_key(None, 'complaints', 'notification_history', ['notification_id'], ['id']) + op.alter_column('dm_datetime', 'month_name', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.alter_column('dm_datetime', 'week_day_name', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.alter_column('dm_datetime', 'quartal', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.alter_column('dm_datetime', 'year_quartal', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.alter_column('dm_datetime', 'year_month', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.alter_column('dm_datetime', 'year_calendar_week', + existing_type=sa.VARCHAR(), + type_=sa.Text(), + existing_nullable=False) + op.create_index(op.f('ix_fido2_sessions_user_id'), 'fido2_sessions', ['user_id'], unique=True) + op.alter_column('notification_failures', 'body', + existing_type=postgresql.JSONB(astext_type=sa.Text()), + nullable=False) + op.alter_column('notification_history', 'notification_status', + existing_type=sa.TEXT(), + type_=sa.String(), + existing_nullable=True) + op.alter_column('notification_history', 'international', + existing_type=sa.BOOLEAN(), + nullable=False) + op.alter_column('notification_history', 'rate_multiplier', + existing_type=sa.NUMERIC(), + type_=sa.Float(), + existing_nullable=True) + op.alter_column('notifications', 'notification_status', + existing_type=sa.TEXT(), + type_=sa.String(), + existing_nullable=True) + op.alter_column('notifications', 'international', + existing_type=sa.BOOLEAN(), + nullable=False) + op.alter_column('notifications', 'rate_multiplier', + existing_type=sa.NUMERIC(), + type_=sa.Float(), + existing_nullable=True) + op.drop_index('ix_notifications_service_created_at', table_name='notifications') + op.create_index(op.f('ix_promoted_templates_id'), 'promoted_templates', ['id'], unique=False) + op.drop_column('promoted_templates', 'promoted_at') + op.alter_column('rates', 'rate', + existing_type=sa.NUMERIC(), + type_=sa.Float(), + existing_nullable=False) + op.alter_column('reply_to_inbox', 'created_at', + existing_type=postgresql.TIMESTAMP(), + nullable=False) + op.alter_column('service_callback', 'bearer_token', + existing_type=sa.VARCHAR(), + nullable=False) + op.drop_index('ix_service_callback_api_service_id', table_name='service_callback') + op.drop_index('ix_service_callback_api_updated_by_id', table_name='service_callback') + op.create_index(op.f('ix_service_callback_service_id'), 'service_callback', ['service_id'], unique=False) + op.create_index(op.f('ix_service_callback_updated_by_id'), 'service_callback', ['updated_by_id'], unique=False) + op.create_unique_constraint('uix_service_callback_channel', 'service_callback', ['service_id', 'callback_channel']) + op.alter_column('service_callback_history', 'bearer_token', + existing_type=sa.VARCHAR(), + nullable=False) + op.drop_index('ix_service_callback_api_history_service_id', table_name='service_callback_history') + op.drop_index('ix_service_callback_api_history_updated_by_id', table_name='service_callback_history') + op.create_index(op.f('ix_service_callback_history_service_id'), 'service_callback_history', ['service_id'], unique=False) + op.create_index(op.f('ix_service_callback_history_updated_by_id'), 'service_callback_history', ['updated_by_id'], unique=False) + op.alter_column('services', 'sending_domain', + existing_type=sa.TEXT(), + type_=sa.String(length=255), + existing_nullable=True) + op.alter_column('services', 'smtp_user', + existing_type=sa.TEXT(), + type_=sa.String(length=255), + existing_nullable=True) + op.alter_column('services_history', 'prefix_sms', + existing_type=sa.BOOLEAN(), + nullable=False) + op.alter_column('services_history', 'sending_domain', + existing_type=sa.TEXT(), + type_=sa.String(length=255), + existing_nullable=True) + op.alter_column('services_history', 'smtp_user', + existing_type=sa.TEXT(), + type_=sa.String(length=255), + existing_nullable=True) + op.alter_column('sessions', 'data', + existing_type=sa.TEXT(), + nullable=False) + op.drop_index('index_sessions_on_session_id', table_name='sessions') + op.drop_index('index_sessions_on_updated_at', table_name='sessions') + op.create_index(op.f('ix_sessions_session_id'), 'sessions', ['session_id'], unique=False) + op.create_index(op.f('ix_sessions_updated_at'), 'sessions', ['updated_at'], unique=False) + op.create_foreign_key(None, 'templates_history', 'communication_items', ['communication_item_id'], ['id']) + op.create_foreign_key(None, 'templates_history', 'provider_details', ['provider_id'], ['id']) + op.alter_column('user_to_service', 'user_id', + existing_type=postgresql.UUID(), + nullable=False) + op.alter_column('user_to_service', 'service_id', + existing_type=postgresql.UUID(), + nullable=False) + op.drop_constraint('users_identity_provider_user_id', 'users', type_='unique') + op.create_index(op.f('ix_users_identity_provider_user_id'), 'users', ['identity_provider_user_id'], unique=True) + op.alter_column('va_profile_local_cache', 'source_datetime', + existing_type=postgresql.TIMESTAMP(), + 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(): + # ### 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', 'source_datetime', + existing_type=postgresql.TIMESTAMP(), + nullable=True) + op.drop_index(op.f('ix_users_identity_provider_user_id'), table_name='users') + op.create_unique_constraint('users_identity_provider_user_id', 'users', ['identity_provider_user_id']) + op.alter_column('user_to_service', 'service_id', + existing_type=postgresql.UUID(), + nullable=True) + op.alter_column('user_to_service', 'user_id', + existing_type=postgresql.UUID(), + nullable=True) + op.drop_constraint(None, 'templates_history', type_='foreignkey') + op.drop_constraint(None, 'templates_history', type_='foreignkey') + op.drop_index(op.f('ix_sessions_updated_at'), table_name='sessions') + op.drop_index(op.f('ix_sessions_session_id'), table_name='sessions') + op.create_index('index_sessions_on_updated_at', 'sessions', ['updated_at'], unique=False) + op.create_index('index_sessions_on_session_id', 'sessions', ['session_id'], unique=True) + op.alter_column('sessions', 'data', + existing_type=sa.TEXT(), + nullable=True) + op.alter_column('services_history', 'smtp_user', + existing_type=sa.String(length=255), + type_=sa.TEXT(), + existing_nullable=True) + op.alter_column('services_history', 'sending_domain', + existing_type=sa.String(length=255), + type_=sa.TEXT(), + existing_nullable=True) + op.alter_column('services_history', 'prefix_sms', + existing_type=sa.BOOLEAN(), + nullable=True) + op.alter_column('services', 'smtp_user', + existing_type=sa.String(length=255), + type_=sa.TEXT(), + existing_nullable=True) + op.alter_column('services', 'sending_domain', + existing_type=sa.String(length=255), + type_=sa.TEXT(), + existing_nullable=True) + op.drop_index(op.f('ix_service_callback_history_updated_by_id'), table_name='service_callback_history') + op.drop_index(op.f('ix_service_callback_history_service_id'), table_name='service_callback_history') + op.create_index('ix_service_callback_api_history_updated_by_id', 'service_callback_history', ['updated_by_id'], unique=False) + op.create_index('ix_service_callback_api_history_service_id', 'service_callback_history', ['service_id'], unique=False) + op.alter_column('service_callback_history', 'bearer_token', + existing_type=sa.VARCHAR(), + nullable=True) + op.drop_constraint('uix_service_callback_channel', 'service_callback', type_='unique') + op.drop_index(op.f('ix_service_callback_updated_by_id'), table_name='service_callback') + op.drop_index(op.f('ix_service_callback_service_id'), table_name='service_callback') + op.create_index('ix_service_callback_api_updated_by_id', 'service_callback', ['updated_by_id'], unique=False) + op.create_index('ix_service_callback_api_service_id', 'service_callback', ['service_id'], unique=False) + op.alter_column('service_callback', 'bearer_token', + existing_type=sa.VARCHAR(), + nullable=True) + op.alter_column('reply_to_inbox', 'created_at', + existing_type=postgresql.TIMESTAMP(), + nullable=True) + op.alter_column('rates', 'rate', + existing_type=sa.Float(), + type_=sa.NUMERIC(), + existing_nullable=False) + op.add_column('promoted_templates', sa.Column('promoted_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) + op.drop_index(op.f('ix_promoted_templates_id'), table_name='promoted_templates') + op.create_index('ix_notifications_service_created_at', 'notifications', ['service_id', 'created_at'], unique=False) + op.alter_column('notifications', 'rate_multiplier', + existing_type=sa.Float(), + type_=sa.NUMERIC(), + existing_nullable=True) + op.alter_column('notifications', 'international', + existing_type=sa.BOOLEAN(), + nullable=True) + op.alter_column('notifications', 'notification_status', + existing_type=sa.String(), + type_=sa.TEXT(), + existing_nullable=True) + op.alter_column('notification_history', 'rate_multiplier', + existing_type=sa.Float(), + type_=sa.NUMERIC(), + existing_nullable=True) + op.alter_column('notification_history', 'international', + existing_type=sa.BOOLEAN(), + nullable=True) + op.alter_column('notification_history', 'notification_status', + existing_type=sa.String(), + type_=sa.TEXT(), + existing_nullable=True) + op.alter_column('notification_failures', 'body', + existing_type=postgresql.JSONB(astext_type=sa.Text()), + nullable=True) + op.drop_index(op.f('ix_fido2_sessions_user_id'), table_name='fido2_sessions') + op.alter_column('dm_datetime', 'year_calendar_week', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.alter_column('dm_datetime', 'year_month', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.alter_column('dm_datetime', 'year_quartal', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.alter_column('dm_datetime', 'quartal', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.alter_column('dm_datetime', 'week_day_name', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.alter_column('dm_datetime', 'month_name', + existing_type=sa.Text(), + type_=sa.VARCHAR(), + existing_nullable=False) + op.drop_constraint(None, 'complaints', type_='foreignkey') + # ### end Alembic commands ### From 0a6ae6a2b44f635485c19e80fbaa9911adacf641 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 10:37:21 -0400 Subject: [PATCH 03/12] Squash #1897 - Update va profile id as well --- app/models.py | 2 +- .../versions/0369a_va_profile_cache_fields.py | 231 ------------------ 2 files changed, 1 insertion(+), 232 deletions(-) diff --git a/app/models.py b/app/models.py index 1469d37fc5..b4d634610a 100644 --- a/app/models.py +++ b/app/models.py @@ -2176,7 +2176,7 @@ 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) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index 5773b8a77e..482b14bdf9 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -7,7 +7,6 @@ """ from alembic import op import sqlalchemy as sa -from sqlalchemy.dialects import postgresql revision = '73ba076d31a5' down_revision = '0369_va_profile_cache_fields' @@ -15,121 +14,6 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_foreign_key(None, 'complaints', 'notification_history', ['notification_id'], ['id']) - op.alter_column('dm_datetime', 'month_name', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.alter_column('dm_datetime', 'week_day_name', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.alter_column('dm_datetime', 'quartal', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.alter_column('dm_datetime', 'year_quartal', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.alter_column('dm_datetime', 'year_month', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.alter_column('dm_datetime', 'year_calendar_week', - existing_type=sa.VARCHAR(), - type_=sa.Text(), - existing_nullable=False) - op.create_index(op.f('ix_fido2_sessions_user_id'), 'fido2_sessions', ['user_id'], unique=True) - op.alter_column('notification_failures', 'body', - existing_type=postgresql.JSONB(astext_type=sa.Text()), - nullable=False) - op.alter_column('notification_history', 'notification_status', - existing_type=sa.TEXT(), - type_=sa.String(), - existing_nullable=True) - op.alter_column('notification_history', 'international', - existing_type=sa.BOOLEAN(), - nullable=False) - op.alter_column('notification_history', 'rate_multiplier', - existing_type=sa.NUMERIC(), - type_=sa.Float(), - existing_nullable=True) - op.alter_column('notifications', 'notification_status', - existing_type=sa.TEXT(), - type_=sa.String(), - existing_nullable=True) - op.alter_column('notifications', 'international', - existing_type=sa.BOOLEAN(), - nullable=False) - op.alter_column('notifications', 'rate_multiplier', - existing_type=sa.NUMERIC(), - type_=sa.Float(), - existing_nullable=True) - op.drop_index('ix_notifications_service_created_at', table_name='notifications') - op.create_index(op.f('ix_promoted_templates_id'), 'promoted_templates', ['id'], unique=False) - op.drop_column('promoted_templates', 'promoted_at') - op.alter_column('rates', 'rate', - existing_type=sa.NUMERIC(), - type_=sa.Float(), - existing_nullable=False) - op.alter_column('reply_to_inbox', 'created_at', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('service_callback', 'bearer_token', - existing_type=sa.VARCHAR(), - nullable=False) - op.drop_index('ix_service_callback_api_service_id', table_name='service_callback') - op.drop_index('ix_service_callback_api_updated_by_id', table_name='service_callback') - op.create_index(op.f('ix_service_callback_service_id'), 'service_callback', ['service_id'], unique=False) - op.create_index(op.f('ix_service_callback_updated_by_id'), 'service_callback', ['updated_by_id'], unique=False) - op.create_unique_constraint('uix_service_callback_channel', 'service_callback', ['service_id', 'callback_channel']) - op.alter_column('service_callback_history', 'bearer_token', - existing_type=sa.VARCHAR(), - nullable=False) - op.drop_index('ix_service_callback_api_history_service_id', table_name='service_callback_history') - op.drop_index('ix_service_callback_api_history_updated_by_id', table_name='service_callback_history') - op.create_index(op.f('ix_service_callback_history_service_id'), 'service_callback_history', ['service_id'], unique=False) - op.create_index(op.f('ix_service_callback_history_updated_by_id'), 'service_callback_history', ['updated_by_id'], unique=False) - op.alter_column('services', 'sending_domain', - existing_type=sa.TEXT(), - type_=sa.String(length=255), - existing_nullable=True) - op.alter_column('services', 'smtp_user', - existing_type=sa.TEXT(), - type_=sa.String(length=255), - existing_nullable=True) - op.alter_column('services_history', 'prefix_sms', - existing_type=sa.BOOLEAN(), - nullable=False) - op.alter_column('services_history', 'sending_domain', - existing_type=sa.TEXT(), - type_=sa.String(length=255), - existing_nullable=True) - op.alter_column('services_history', 'smtp_user', - existing_type=sa.TEXT(), - type_=sa.String(length=255), - existing_nullable=True) - op.alter_column('sessions', 'data', - existing_type=sa.TEXT(), - nullable=False) - op.drop_index('index_sessions_on_session_id', table_name='sessions') - op.drop_index('index_sessions_on_updated_at', table_name='sessions') - op.create_index(op.f('ix_sessions_session_id'), 'sessions', ['session_id'], unique=False) - op.create_index(op.f('ix_sessions_updated_at'), 'sessions', ['updated_at'], unique=False) - op.create_foreign_key(None, 'templates_history', 'communication_items', ['communication_item_id'], ['id']) - op.create_foreign_key(None, 'templates_history', 'provider_details', ['provider_id'], ['id']) - op.alter_column('user_to_service', 'user_id', - existing_type=postgresql.UUID(), - nullable=False) - op.alter_column('user_to_service', 'service_id', - existing_type=postgresql.UUID(), - nullable=False) - op.drop_constraint('users_identity_provider_user_id', 'users', type_='unique') - op.create_index(op.f('ix_users_identity_provider_user_id'), 'users', ['identity_provider_user_id'], unique=True) - op.alter_column('va_profile_local_cache', 'source_datetime', - existing_type=postgresql.TIMESTAMP(), - nullable=False) op.alter_column('va_profile_local_cache', 'participant_id', existing_type=sa.INTEGER(), type_=sa.BigInteger(), @@ -143,119 +27,4 @@ def downgrade(): existing_type=sa.BigInteger(), type_=sa.INTEGER(), existing_nullable=True) - op.alter_column('va_profile_local_cache', 'source_datetime', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_index(op.f('ix_users_identity_provider_user_id'), table_name='users') - op.create_unique_constraint('users_identity_provider_user_id', 'users', ['identity_provider_user_id']) - op.alter_column('user_to_service', 'service_id', - existing_type=postgresql.UUID(), - nullable=True) - op.alter_column('user_to_service', 'user_id', - existing_type=postgresql.UUID(), - nullable=True) - op.drop_constraint(None, 'templates_history', type_='foreignkey') - op.drop_constraint(None, 'templates_history', type_='foreignkey') - op.drop_index(op.f('ix_sessions_updated_at'), table_name='sessions') - op.drop_index(op.f('ix_sessions_session_id'), table_name='sessions') - op.create_index('index_sessions_on_updated_at', 'sessions', ['updated_at'], unique=False) - op.create_index('index_sessions_on_session_id', 'sessions', ['session_id'], unique=True) - op.alter_column('sessions', 'data', - existing_type=sa.TEXT(), - nullable=True) - op.alter_column('services_history', 'smtp_user', - existing_type=sa.String(length=255), - type_=sa.TEXT(), - existing_nullable=True) - op.alter_column('services_history', 'sending_domain', - existing_type=sa.String(length=255), - type_=sa.TEXT(), - existing_nullable=True) - op.alter_column('services_history', 'prefix_sms', - existing_type=sa.BOOLEAN(), - nullable=True) - op.alter_column('services', 'smtp_user', - existing_type=sa.String(length=255), - type_=sa.TEXT(), - existing_nullable=True) - op.alter_column('services', 'sending_domain', - existing_type=sa.String(length=255), - type_=sa.TEXT(), - existing_nullable=True) - op.drop_index(op.f('ix_service_callback_history_updated_by_id'), table_name='service_callback_history') - op.drop_index(op.f('ix_service_callback_history_service_id'), table_name='service_callback_history') - op.create_index('ix_service_callback_api_history_updated_by_id', 'service_callback_history', ['updated_by_id'], unique=False) - op.create_index('ix_service_callback_api_history_service_id', 'service_callback_history', ['service_id'], unique=False) - op.alter_column('service_callback_history', 'bearer_token', - existing_type=sa.VARCHAR(), - nullable=True) - op.drop_constraint('uix_service_callback_channel', 'service_callback', type_='unique') - op.drop_index(op.f('ix_service_callback_updated_by_id'), table_name='service_callback') - op.drop_index(op.f('ix_service_callback_service_id'), table_name='service_callback') - op.create_index('ix_service_callback_api_updated_by_id', 'service_callback', ['updated_by_id'], unique=False) - op.create_index('ix_service_callback_api_service_id', 'service_callback', ['service_id'], unique=False) - op.alter_column('service_callback', 'bearer_token', - existing_type=sa.VARCHAR(), - nullable=True) - op.alter_column('reply_to_inbox', 'created_at', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('rates', 'rate', - existing_type=sa.Float(), - type_=sa.NUMERIC(), - existing_nullable=False) - op.add_column('promoted_templates', sa.Column('promoted_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) - op.drop_index(op.f('ix_promoted_templates_id'), table_name='promoted_templates') - op.create_index('ix_notifications_service_created_at', 'notifications', ['service_id', 'created_at'], unique=False) - op.alter_column('notifications', 'rate_multiplier', - existing_type=sa.Float(), - type_=sa.NUMERIC(), - existing_nullable=True) - op.alter_column('notifications', 'international', - existing_type=sa.BOOLEAN(), - nullable=True) - op.alter_column('notifications', 'notification_status', - existing_type=sa.String(), - type_=sa.TEXT(), - existing_nullable=True) - op.alter_column('notification_history', 'rate_multiplier', - existing_type=sa.Float(), - type_=sa.NUMERIC(), - existing_nullable=True) - op.alter_column('notification_history', 'international', - existing_type=sa.BOOLEAN(), - nullable=True) - op.alter_column('notification_history', 'notification_status', - existing_type=sa.String(), - type_=sa.TEXT(), - existing_nullable=True) - op.alter_column('notification_failures', 'body', - existing_type=postgresql.JSONB(astext_type=sa.Text()), - nullable=True) - op.drop_index(op.f('ix_fido2_sessions_user_id'), table_name='fido2_sessions') - op.alter_column('dm_datetime', 'year_calendar_week', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.alter_column('dm_datetime', 'year_month', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.alter_column('dm_datetime', 'year_quartal', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.alter_column('dm_datetime', 'quartal', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.alter_column('dm_datetime', 'week_day_name', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.alter_column('dm_datetime', 'month_name', - existing_type=sa.Text(), - type_=sa.VARCHAR(), - existing_nullable=False) - op.drop_constraint(None, 'complaints', type_='foreignkey') # ### end Alembic commands ### From fa5b215785822c12cb86cc0cc7c86766cd9b0564 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 11:38:04 -0400 Subject: [PATCH 04/12] Squash #1897 - Add vaprofile id as well --- .../versions/0369a_va_profile_cache_fields.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index 482b14bdf9..01f7ee2e96 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -1,19 +1,24 @@ """ -Revision ID: 73ba076d31a5 +Revision ID: bab2a5de15d8 Revises: 0369_va_profile_cache_fields -Create Date: 2024-08-05 13:51:38.281958 +Create Date: 2024-08-05 15:10:01.963467 """ from alembic import op import sqlalchemy as sa +from sqlalchemy.dialects import postgresql -revision = '73ba076d31a5' -down_revision = '0369_va_profile_cache_fields' +revision = 'bab2a5de15d8' +down_revision = '0369a_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(), @@ -27,4 +32,8 @@ def downgrade(): 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 ### From 44a1ab834ecfa4779596dacf11d74035919129c2 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 11:41:12 -0400 Subject: [PATCH 05/12] Squash #1897 - Remove extra import --- migrations/versions/0369a_va_profile_cache_fields.py | 1 - 1 file changed, 1 deletion(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index 01f7ee2e96..c1bc6c1d97 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -7,7 +7,6 @@ """ from alembic import op import sqlalchemy as sa -from sqlalchemy.dialects import postgresql revision = 'bab2a5de15d8' down_revision = '0369a_va_profile_cache_fields' From c27ae8c2b28079be8f7c78e170cbe5246cdeba80 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 11:45:44 -0400 Subject: [PATCH 06/12] Squash #1897 - Correct reivison ID and down_revision --- migrations/versions/0369a_va_profile_cache_fields.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index c1bc6c1d97..bc17c1f307 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -1,15 +1,15 @@ """ -Revision ID: bab2a5de15d8 -Revises: 0369_va_profile_cache_fields +Revision ID: 0369a_va_profile_cache_fields +Revises: 0369_vaprofile_cache_fields Create Date: 2024-08-05 15:10:01.963467 """ from alembic import op import sqlalchemy as sa -revision = 'bab2a5de15d8' -down_revision = '0369a_va_profile_cache_fields' +revision = '0369a_va_profile_cache_fields' +down_revision = '0369_vaprofile_cache_fields' def upgrade(): From f0560c244776aaadf7ffcc3074d6006eb851c736 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 11:49:41 -0400 Subject: [PATCH 07/12] Squash #1897 - Remove spacing to match other migrations --- migrations/versions/0369a_va_profile_cache_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index bc17c1f307..ccb136bcca 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -1,6 +1,6 @@ """ -Revision ID: 0369a_va_profile_cache_fields +Revision ID:0369a_va_profile_cache_fields Revises: 0369_vaprofile_cache_fields Create Date: 2024-08-05 15:10:01.963467 From f5a993abad9791445137510dbd3559cfe7aa2fd3 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 12:03:17 -0400 Subject: [PATCH 08/12] Squash #1897 - Remove part of timestamp --- migrations/versions/0369a_va_profile_cache_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index ccb136bcca..664d7ba002 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -2,7 +2,7 @@ Revision ID:0369a_va_profile_cache_fields Revises: 0369_vaprofile_cache_fields -Create Date: 2024-08-05 15:10:01.963467 +Create Date: 2024-08-05 15:10:01 """ from alembic import op From 56e729ce45fbb4093f7a2b2cbcc321b24b070827 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 12:22:59 -0400 Subject: [PATCH 09/12] Squash #1897 - Rename down_revision --- migrations/versions/0369a_va_profile_cache_fields.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index 664d7ba002..6430ed5735 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -1,7 +1,7 @@ """ Revision ID:0369a_va_profile_cache_fields -Revises: 0369_vaprofile_cache_fields +Revises: 0369_va_profile_cache_fields Create Date: 2024-08-05 15:10:01 """ @@ -9,7 +9,7 @@ import sqlalchemy as sa revision = '0369a_va_profile_cache_fields' -down_revision = '0369_vaprofile_cache_fields' +down_revision = '0369_va_profile_cache_fields' def upgrade(): From 68ccd12a38f14e92bdb0e908d508b060f95b7740 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 12:30:44 -0400 Subject: [PATCH 10/12] Squash #1897 - Remove talisman update, not needed since new migration file paired down --- .talismanrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/.talismanrc b/.talismanrc index eebcd57583..64bd7d7e7d 100644 --- a/.talismanrc +++ b/.talismanrc @@ -17,8 +17,6 @@ fileignoreconfig: checksum: e06cc6abd755fa5cb5c2b1deceb1a40f87bf9f2b8be73102623cbfe0f28a20cd - filename: ci/.local.env checksum: a2dca7e8e15af2a98112a405725e0b6f07c6adcb61507d8d32715ee17c383b6b -- filename: migrations/versions/0369a_va_profile_cache_fields.py - checksum: 46fc08a846152dde6173054c447d5abbf78708bdbdf2af5dc003c5439f12c618 - filename: poetry.lock checksum: 7a495ebe704b7723f9abfe67d965e53fb3ae830ba537b36a1aa07de4eeecb4fa - filename: tests/app/celery/test_scheduled_tasks.py From 576f081ad4591343441578fabd60ccc74008e46b Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 15:31:34 -0400 Subject: [PATCH 11/12] Squash #1897 - Update to delete items that do not fit downgraded schema --- migrations/versions/0369a_va_profile_cache_fields.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index 6430ed5735..e228d97984 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -26,6 +26,12 @@ def upgrade(): def downgrade(): + + # Delete data that will not fit into the downgraded schema + op.execute(""" + DELETE FROM va_profile_local_cache WHERE va_profile_id > 2147483647 OR participant_id > 2147483647 + """) + # ### commands auto generated by Alembic - please adjust! ### op.alter_column('va_profile_local_cache', 'participant_id', existing_type=sa.BigInteger(), From 5b973f09f2833aa31520a7f543a91f4eb44c3069 Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Mon, 5 Aug 2024 16:14:00 -0400 Subject: [PATCH 12/12] Squash #1897 - Update participant_id to -1 and delete vaprofile_id if cannot be converted to INT --- .../versions/0369a_va_profile_cache_fields.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/migrations/versions/0369a_va_profile_cache_fields.py b/migrations/versions/0369a_va_profile_cache_fields.py index e228d97984..0073078350 100644 --- a/migrations/versions/0369a_va_profile_cache_fields.py +++ b/migrations/versions/0369a_va_profile_cache_fields.py @@ -27,11 +27,20 @@ def upgrade(): def downgrade(): - # Delete data that will not fit into the downgraded schema + # Update participant_id to -1 where it cannot be converted back to INTEGER op.execute(""" - DELETE FROM va_profile_local_cache WHERE va_profile_id > 2147483647 OR participant_id > 2147483647 + 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(),