From 6356a5320a07b5c8b5fcebbad041a9936c8552f3 Mon Sep 17 00:00:00 2001 From: Richard Chapman Date: Wed, 27 Sep 2017 10:36:25 +0100 Subject: [PATCH] Updated model with a new table notification_to_email_sender and created db migration script --- app/models.py | 21 +++++++++++++ .../versions/0123_add_noti_to_email_sender.py | 31 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 migrations/versions/0123_add_noti_to_email_sender.py diff --git a/app/models.py b/app/models.py index be6d54cf1..e0c56f36a 100644 --- a/app/models.py +++ b/app/models.py @@ -1414,3 +1414,24 @@ class ServiceLetterContact(db.Model): 'created_at': self.created_at.strftime(DATETIME_FORMAT), 'updated_at': self.updated_at.strftime(DATETIME_FORMAT) if self.updated_at else None } + + +class NotificationSmsSender(db.Model): + __tablename__ = "notification_to_email_sender" + + notification_id = db.Column( + UUID(as_uuid=True), + db.ForeignKey('notifications.id'), + unique=False, + 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 + ) diff --git a/migrations/versions/0123_add_noti_to_email_sender.py b/migrations/versions/0123_add_noti_to_email_sender.py new file mode 100644 index 000000000..2a49df3da --- /dev/null +++ b/migrations/versions/0123_add_noti_to_email_sender.py @@ -0,0 +1,31 @@ +""" + +Revision ID: 0123_add_noti_to_email_sender +Revises: 0122_add_service_letter_contact +Create Date: 2017-09-27 09:42:39.412731 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +revision = '0123_add_noti_to_email_sender' +down_revision = '0122_add_service_letter_contact' + + +def upgrade(): + op.create_table('notification_to_email_sender', + sa.Column('notification_id', postgresql.UUID(as_uuid=True), nullable=False), + sa.Column('service_email_reply_to_id', postgresql.UUID(as_uuid=True), nullable=False), + sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], ), + sa.ForeignKeyConstraint(['service_email_reply_to_id'], ['service_email_reply_to.id'], ), + sa.PrimaryKeyConstraint('notification_id', 'service_email_reply_to_id') + ) + op.create_index(op.f('ix_notification_to_email_sender_notification_id'), 'notification_to_email_sender', ['notification_id'], unique=False) + op.create_index(op.f('ix_notification_to_email_sender_service_email_reply_to_id'), 'notification_to_email_sender', ['service_email_reply_to_id'], unique=False) + + +def downgrade(): + op.drop_index(op.f('ix_notification_to_email_sender_service_email_reply_to_id'), table_name='notification_to_email_sender') + op.drop_index(op.f('ix_notification_to_email_sender_notification_id'), table_name='notification_to_email_sender') + op.drop_table('notification_to_email_sender')