Change the order of delete statements to respect foreign key constraint

This commit is contained in:
Pea Tyczynska
2019-06-28 11:22:12 +01:00
parent 9782b08982
commit 2a5b0f8f17
4 changed files with 6 additions and 6 deletions

View File

@@ -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))

View File

@@ -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'])

View File

@@ -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))

View File

@@ -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))