From 2a5b0f8f173f3585bb2fe0f19d193b7cbe6d614e Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Fri, 28 Jun 2019 11:22:12 +0100 Subject: [PATCH] Change the order of delete statements to respect foreign key constraint --- migrations/versions/0134_add_email_2fa_template_.py | 2 +- migrations/versions/0171_add_org_invite_template.py | 2 +- migrations/versions/0265_add_confirm_edit_templates.py | 4 ++-- migrations/versions/0294_add_verify_reply_to_.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/migrations/versions/0134_add_email_2fa_template_.py b/migrations/versions/0134_add_email_2fa_template_.py index c03faaafb..fcb51840f 100644 --- a/migrations/versions/0134_add_email_2fa_template_.py +++ b/migrations/versions/0134_add_email_2fa_template_.py @@ -79,6 +79,6 @@ def upgrade(): def downgrade(): op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id)) op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id)) + op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id)) op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id)) op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id)) - op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id)) diff --git a/migrations/versions/0171_add_org_invite_template.py b/migrations/versions/0171_add_org_invite_template.py index c49c27afa..a8ba5c39a 100644 --- a/migrations/versions/0171_add_org_invite_template.py +++ b/migrations/versions/0171_add_org_invite_template.py @@ -89,7 +89,7 @@ def upgrade(): def downgrade(): op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(template_id)) op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(template_id)) + op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id)) op.execute("DELETE FROM templates_history WHERE id = '{}'".format(template_id)) op.execute("DELETE FROM templates WHERE id = '{}'".format(template_id)) - op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(template_id)) op.create_unique_constraint('organisation_to_service_service_id_organisation_id_key', 'organisation_to_service', ['service_id', 'organisation_id']) diff --git a/migrations/versions/0265_add_confirm_edit_templates.py b/migrations/versions/0265_add_confirm_edit_templates.py index 20b1df52d..044487d33 100644 --- a/migrations/versions/0265_add_confirm_edit_templates.py +++ b/migrations/versions/0265_add_confirm_edit_templates.py @@ -130,12 +130,12 @@ def upgrade(): def downgrade(): op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(email_template_id)) op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(email_template_id)) + op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(email_template_id)) op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id)) op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id)) - op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(email_template_id)) op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(mobile_template_id)) op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(mobile_template_id)) + op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(mobile_template_id)) op.execute("DELETE FROM templates_history WHERE id = '{}'".format(mobile_template_id)) op.execute("DELETE FROM templates WHERE id = '{}'".format(mobile_template_id)) - op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(mobile_template_id)) diff --git a/migrations/versions/0294_add_verify_reply_to_.py b/migrations/versions/0294_add_verify_reply_to_.py index c3ee0fc20..5455983bc 100644 --- a/migrations/versions/0294_add_verify_reply_to_.py +++ b/migrations/versions/0294_add_verify_reply_to_.py @@ -90,6 +90,6 @@ def upgrade(): def downgrade(): op.execute("DELETE FROM notifications WHERE template_id = '{}'".format(email_template_id)) op.execute("DELETE FROM notification_history WHERE template_id = '{}'".format(email_template_id)) - op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id)) - op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id)) op.execute("DELETE FROM template_redacted WHERE template_id = '{}'".format(email_template_id)) + op.execute("DELETE FROM templates_history WHERE id = '{}'".format(email_template_id)) + op.execute("DELETE FROM templates WHERE id = '{}'".format(email_template_id))