From 0ca7d4a20c8a65e45ddb7c61ca72c0e6c464a80e Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Fri, 7 Jun 2019 17:36:06 +0100 Subject: [PATCH] Create template_redacted entry for templates created by migration So that we can edit those templates --- .../versions/0296_template_redacted_fix.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 migrations/versions/0296_template_redacted_fix.py diff --git a/migrations/versions/0296_template_redacted_fix.py b/migrations/versions/0296_template_redacted_fix.py new file mode 100644 index 000000000..cb56f8776 --- /dev/null +++ b/migrations/versions/0296_template_redacted_fix.py @@ -0,0 +1,26 @@ +""" + +Revision ID: 0296_template_redacted_fix +Revises: 0295_api_key_constraint +Create Date: 2019-06-07 17:02:14.350064 + +""" +from alembic import op + + +revision = '0296_template_redacted_fix' +down_revision = '0295_api_key_constraint' + + +def upgrade(): + op.execute(""" + INSERT INTO template_redacted (template_id, redact_personalisation, updated_at, updated_by_id) + SELECT templates.id, FALSE, now(), templates.created_by_id + FROM templates + WHERE templates.id NOT IN (SELECT template_id FROM template_redacted WHERE template_id = templates.id) + ; + """) + + +def downgrade(): + pass