From a01838e833eeff19cd550508ca3025dee2d23dfb Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 30 Nov 2017 15:53:08 +0000 Subject: [PATCH 1/2] Drop the Notification to sender mapping tables. We no longer need them because we record the text value of the sender on the notification. --- app/models.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/app/models.py b/app/models.py index f78466b85..fb3a2610d 100644 --- a/app/models.py +++ b/app/models.py @@ -1572,48 +1572,6 @@ class ServiceLetterContact(db.Model): } -class NotificationEmailReplyTo(db.Model): - __tablename__ = "notification_to_email_reply_to" - - notification_id = db.Column( - UUID(as_uuid=True), - db.ForeignKey('notifications.id'), - unique=True, - index=True, - nullable=False, - primary_key=True - ) - service_email_reply_to_id = db.Column( - UUID(as_uuid=True), - db.ForeignKey('service_email_reply_to.id'), - unique=False, - index=True, - nullable=False, - primary_key=True - ) - - -class NotificationSmsSender(db.Model): - __tablename__ = "notification_to_sms_sender" - - notification_id = db.Column( - UUID(as_uuid=True), - db.ForeignKey('notifications.id'), - unique=True, - index=True, - nullable=False, - primary_key=True - ) - service_sms_sender_id = db.Column( - UUID(as_uuid=True), - db.ForeignKey('service_sms_senders.id'), - unique=False, - index=True, - nullable=False, - primary_key=True - ) - - class AuthType(db.Model): __tablename__ = 'auth_type' From 12dd58d2817bfec8d1c052282cd99c7f59915da2 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 30 Nov 2017 16:51:26 +0000 Subject: [PATCH 2/2] Script to drop the tables. --- .../versions/0147_drop_mapping_tables.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 migrations/versions/0147_drop_mapping_tables.py diff --git a/migrations/versions/0147_drop_mapping_tables.py b/migrations/versions/0147_drop_mapping_tables.py new file mode 100644 index 000000000..82d337f3a --- /dev/null +++ b/migrations/versions/0147_drop_mapping_tables.py @@ -0,0 +1,41 @@ +""" + +Revision ID: 0147_drop_mapping_tables +Revises: 0146_add_service_callback_api +Create Date: 2017-11-30 15:48:44.588438 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0147_drop_mapping_tables' +down_revision = '0146_add_service_callback_api' + + +def upgrade(): + op.drop_table('notification_to_sms_sender') + op.drop_table('notification_to_email_reply_to') + + +def downgrade(): + op.create_table('notification_to_email_reply_to', + sa.Column('notification_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.Column('service_email_reply_to_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], + name='notification_to_email_reply_to_notification_id_fkey'), + sa.ForeignKeyConstraint(['service_email_reply_to_id'], ['service_email_reply_to.id'], + name='notification_to_email_reply_to_service_email_reply_to_id_fkey'), + sa.PrimaryKeyConstraint('notification_id', 'service_email_reply_to_id', + name='notification_to_email_reply_to_pkey') + ) + op.create_table('notification_to_sms_sender', + sa.Column('notification_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.Column('service_sms_sender_id', postgresql.UUID(), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], + name='notification_to_sms_sender_notification_id_fkey'), + sa.ForeignKeyConstraint(['service_sms_sender_id'], ['service_sms_senders.id'], + name='notification_to_sms_sender_service_sms_sender_id_fkey'), + sa.PrimaryKeyConstraint('notification_id', 'service_sms_sender_id', + name='notification_to_sms_sender_pkey') + )