Skip to content
Snippets Groups Projects

Feature/update v3 migrations

Merged Karel van Klink requested to merge feature/update-v3-migrations into develop
2 files
+ 81
1
Compare changes
  • Side-by-side
  • Inline
Files
2
"""Update wf in process table and delete old workflows
"""Update workflows in process table and delete old processes and workflows
Revision ID: c38adde1a18e
Revision ID: c38adde1a18e
Revises: 9fbb3c4411ea
Revises: 9fbb3c4411ea
@@ -85,7 +85,49 @@ WHERE pr.pid = ps.pid
@@ -85,7 +85,49 @@ WHERE pr.pid = ps.pid
for mapping in update_mappings:
for mapping in update_mappings:
conn.execute(sa.text(sql_template), mapping)
conn.execute(sa.text(sql_template), mapping)
 
# Delete input states referencing to orphaned workflows.
 
conn.execute(
 
sa.text(
 
"""
 
DELETE FROM input_states
 
WHERE input_states.pid IN (SELECT p.pid
 
FROM processes p
 
JOIN workflows w
 
ON p.workflow_id = w.workflow_id
 
JOIN processes_subscriptions ps
 
ON ps.pid = p.pid
 
JOIN subscriptions s
 
ON s.subscription_id = ps.subscription_id
 
JOIN products pro
 
ON s.product_id = pro.product_id
 
WHERE w."name" = 'validate_prefix_list'
 
AND pro."name" != 'GÉANT IP');
 
"""
 
)
 
)
 
 
# Delete processes refering to orphaned workflows.
 
conn.execute(
 
sa.text(
 
"""
 
DELETE FROM processes
 
WHERE processes.pid IN (SELECT p.pid
 
FROM processes p
 
JOIN workflows w
 
ON p.workflow_id = w.workflow_id
 
JOIN processes_subscriptions ps
 
ON ps.pid = p.pid
 
JOIN subscriptions s
 
ON s.subscription_id = ps.subscription_id
 
JOIN products pro
 
ON s.product_id = pro.product_id
 
WHERE w."name" = 'validate_prefix_list'
 
AND pro."name" != 'GÉANT IP');
 
"""
 
)
 
)
 
# Delete workflows for products that no longer exist.
conn.execute(
conn.execute(
sa.text(
sa.text(
"""
"""
Loading