From 3486355354800fea5caa6e26412b7ee65333dd26 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 6 Jul 2020 16:52:04 +0100 Subject: [PATCH] remove any broadcast templates in downgrade step --- migrations/versions/0323_broadcast_message.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migrations/versions/0323_broadcast_message.py b/migrations/versions/0323_broadcast_message.py index 7228d6aaf..39f93948d 100644 --- a/migrations/versions/0323_broadcast_message.py +++ b/migrations/versions/0323_broadcast_message.py @@ -85,6 +85,11 @@ def upgrade(): def downgrade(): + op.execute("DELETE FROM template_folder_map WHERE template_id IN (SELECT id FROM templates WHERE template_type = 'broadcast')") + op.execute("DELETE FROM template_redacted WHERE template_id IN (SELECT id FROM templates WHERE template_type = 'broadcast')") + op.execute("DELETE FROM templates WHERE template_type = 'broadcast'") + op.execute("DELETE FROM templates_history WHERE template_type = 'broadcast'") + op.execute(f'ALTER TYPE {name} RENAME TO {tmp_name}') old_type.create(op.get_bind())