Skip to content
Snippets Groups Projects
Verified Commit 8717231e authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Fix a cascading delete in a db migration

parent 529a61f5
No related branches found
No related tags found
No related merge requests found
Pipeline #95174 canceled
......@@ -7,6 +7,7 @@ Create Date: 2025-06-20 11:34:08.439370
"""
import sqlalchemy as sa
from alembic import op
from orchestrator.migrations.helpers import create_task, delete_workflow
# revision identifiers, used by Alembic.
revision = '7c3094cd282a'
......@@ -14,18 +15,34 @@ down_revision = '24858fd1d805'
branch_labels = None
depends_on = None
from orchestrator.migrations.helpers import create_task, delete_workflow
old_task = {
"name": "task_validate_geant_products",
"description": "Validate GEANT products"
}
def upgrade() -> None:
conn = op.get_bind()
conn.execute(sa.text(f"""
DELETE FROM processes WHERE workflow_id = (SELECT workflow_id FROM workflows WHERE name = '{old_task["name"]}')
DO $$DECLARE wf_id UUID;BEGIN
SELECT workflow_id
INTO wf_id
FROM workflows
WHERE NAME = '{old_task["name"]}';
DELETE
FROM input_states
WHERE pid IN
(
SELECT pid
FROM processes
WHERE workflow_id = wf_id);
DELETE
FROM processes
WHERE workflow_id = wf_id;
END$$;
"""))
delete_workflow(conn, old_task["name"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment