From 5be5e17e466f71ddfc0534b87f2254fb37eab4d8 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 5 Jan 2018 15:55:02 +0000 Subject: [PATCH 1/2] Because life is difficult today... Need to alter the column to nullable and remove reference to the column in any code. Next PR will drop column --- app/models.py | 4 ---- tests/app/template/test_rest.py | 1 - 2 files changed, 5 deletions(-) diff --git a/app/models.py b/app/models.py index 4f4a6cafc..214979611 100644 --- a/app/models.py +++ b/app/models.py @@ -582,10 +582,6 @@ class TemplateBase(db.Model): content = db.Column(db.Text, nullable=False) archived = db.Column(db.Boolean, nullable=False, default=False) subject = db.Column(db.Text) - is_letter_contact_blank = db.Column(db.Boolean, nullable=False, default=False) - - # if is_letter_contact = True then service_letter_contact must be null. - CheckConstraint("Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)") @declared_attr def service_id(cls): diff --git a/tests/app/template/test_rest.py b/tests/app/template/test_rest.py index ab2533e0f..89830827e 100644 --- a/tests/app/template/test_rest.py +++ b/tests/app/template/test_rest.py @@ -625,7 +625,6 @@ def test_get_template_reply_to(client, sample_letter_template): assert 'service_letter_contact_id' not in json_resp['data'] assert json_resp['data']['reply_to'] == str(letter_contact.id) assert json_resp['data']['reply_to_text'] == letter_contact.contact_block - assert not json_resp['data']['is_letter_contact_blank'] def test_update_template_reply_to(client, sample_letter_template): From 0bc42d18736864f4044f948f589a375a12f134f9 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 5 Jan 2018 15:58:13 +0000 Subject: [PATCH 2/2] Forgot script --- migrations/versions/0154_nullable_is_blank.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 migrations/versions/0154_nullable_is_blank.py diff --git a/migrations/versions/0154_nullable_is_blank.py b/migrations/versions/0154_nullable_is_blank.py new file mode 100644 index 000000000..6a2a214b2 --- /dev/null +++ b/migrations/versions/0154_nullable_is_blank.py @@ -0,0 +1,23 @@ +""" + +Revision ID: 0154_nullable_is_blank +Revises: 0153_add_is_letter_contact_blank +Create Date: 2018-01-05 15:49:36.522210 + +""" +from alembic import op +import sqlalchemy as sa + + +revision = '0154_nullable_is_blank' +down_revision = '0153_add_is_letter_contact_blank' + + +def upgrade(): + op.alter_column('templates', 'is_letter_contact_blank', nullable=True) + op.alter_column('templates_history', 'is_letter_contact_blank', nullable=True) + + +def downgrade(): + op.alter_column('templates', 'is_letter_contact_blank', nullable=True) + op.alter_column('templates_history', 'is_letter_contact_blank', nullable=True)