From 63f6bee162bb4322641b10db9ec462b785516932 Mon Sep 17 00:00:00 2001 From: Rob Lambell Date: Wed, 18 Dec 2024 01:10:40 +0000 Subject: [PATCH] fix(db): make migration statement conditional (#5625) * fix: make migration statement conditional * Update src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py Co-authored-by: David Whittaker <84562015+whitdog47@users.noreply.github.com> Signed-off-by: Rob Lambell --------- Signed-off-by: Rob Lambell Co-authored-by: David Whittaker <84562015+whitdog47@users.noreply.github.com> --- .../revisions/tenant/versions/2024-11-04_928b725d64f6.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py b/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py index 72a8a2829b82..2489456fed8e 100644 --- a/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py +++ b/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py @@ -52,7 +52,12 @@ def upgrade(): if column_exists: op.drop_column("plugin_instance", "configuration") - op.drop_constraint("project_stable_priority_id_fkey", "project", type_="foreignkey") + foreign_keys = inspector.get_foreign_keys("project") + + constraint_name = "project_stable_priority_id_fkey" + constraint_exists = any(fk["name"] == constraint_name for fk in foreign_keys) + if constraint_exists: + op.drop_constraint(constraint_name, "project", type_="foreignkey") # ### end Alembic commands ###