From 743acf71e4351a0d422d106a5d8435b6a9af1b74 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Wed, 12 Feb 2020 14:38:09 +0000 Subject: [PATCH] add nullable document_count field to Notifications intention is for this to be null, 1, or many, based on how many documents were linked to within the message. nullable column, so that it doesn't require a lengthy access exclusive lock on the table when creating. --- app/models.py | 4 ++++ .../versions/0315_document_download_count.py | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 migrations/versions/0315_document_download_count.py diff --git a/app/models.py b/app/models.py index d11f83cc6..23c0f9cd6 100644 --- a/app/models.py +++ b/app/models.py @@ -1407,6 +1407,8 @@ class Notification(db.Model): reply_to_text = db.Column(db.String, nullable=True) + document_download_count = db.Column(db.Integer, nullable=True) + postage = db.Column(db.String, nullable=True) CheckConstraint(""" CASE WHEN notification_type = 'letter' THEN @@ -1683,6 +1685,8 @@ class NotificationHistory(db.Model, HistoryModel): END """) + document_download_count = db.Column(db.Integer, nullable=True) + __table_args__ = ( db.ForeignKeyConstraint( ['template_id', 'template_version'], diff --git a/migrations/versions/0315_document_download_count.py b/migrations/versions/0315_document_download_count.py new file mode 100644 index 000000000..b59307a8c --- /dev/null +++ b/migrations/versions/0315_document_download_count.py @@ -0,0 +1,23 @@ +""" + +Revision ID: 0315_document_download_count +Revises: 0314_populate_email_access +Create Date: 2020-02-12 14:19:18.066425 + +""" +from alembic import op +import sqlalchemy as sa + + +revision = '0315_document_download_count' +down_revision = '0314_populate_email_access' + + +def upgrade(): + op.add_column('notifications', sa.Column('document_download_count', sa.Integer(), nullable=True)) + op.add_column('notification_history', sa.Column('document_download_count', sa.Integer(), nullable=True)) + + +def downgrade(): + op.drop_column('notifications', 'document_download_count') + op.drop_column('notification_history', 'document_download_count')