Skip to content

Commit db068cd

Browse files
committed
Add migration to backfill is_task=true on core tasks
1 parent 545df4f commit db068cd

4 files changed

+43
-1
lines changed

orchestrator/migrations/versions/schema/2020-10-19_a76b9185b334_add_generic_workflows_to_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
branch_labels = None
1818
depends_on = None
1919

20+
# NOTE: this migration forgot to insert these workflows with is_task=true. Make sure to correct that if you copy this.
2021
workflows = [
2122
{"name": "modify_note", "description": "Modify Note", "workflow_id": uuid4(), "target": "MODIFY"},
2223
{"name": "task_clean_up_tasks", "description": "Clean up old tasks", "workflow_id": uuid4(), "target": "SYSTEM"},

orchestrator/migrations/versions/schema/2021-04-06_3c8b9185c221_add_validate_products_task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
branch_labels = None
1818
depends_on = None
1919

20+
# NOTE: this migration forgot to insert these workflows with is_task=true. Make sure to correct that if you copy this.
2021
workflows = [
2122
{"name": "task_validate_products", "description": "Validate products", "workflow_id": uuid4(), "target": "SYSTEM"},
2223
]

orchestrator/migrations/versions/schema/2025-11-18_961eddbd4c13_create_linker_table_workflow_apscheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
branch_labels = None
1818
depends_on = None
1919

20-
20+
# NOTE: this migration forgot to insert these workflows with is_task=true. Make sure to correct that if you copy this.
2121
workflows = [
2222
{
2323
"name": "task_validate_subscriptions",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Set is_task=true on certain tasks.
2+
3+
This is required to make them appear in the completed tasks in the UI, and for the cleanup task to be able to
4+
remove them.
5+
6+
Revision ID: 9736496e3eba
7+
Revises: 961eddbd4c13
8+
Create Date: 2025-12-10 16:42:29.060382
9+
10+
"""
11+
12+
import sqlalchemy as sa
13+
from alembic import op
14+
15+
# revision identifiers, used by Alembic.
16+
revision = "9736496e3eba"
17+
down_revision = "961eddbd4c13"
18+
branch_labels = None
19+
depends_on = None
20+
21+
task_names = [
22+
# Added in a76b9185b334
23+
"task_clean_up_tasks",
24+
"task_resume_workflows",
25+
# Added in 3c8b9185c221
26+
"task_validate_products",
27+
# Added in 961eddbd4c13
28+
"task_validate_subscriptions",
29+
]
30+
31+
32+
def upgrade() -> None:
33+
conn = op.get_bind()
34+
query = sa.text("UPDATE workflows SET is_task=true WHERE name = :task_name and is_task=false")
35+
for task_name in task_names:
36+
conn.execute(query, parameters={"task_name": task_name})
37+
38+
39+
def downgrade() -> None:
40+
pass # Does not make sense to downgrade back to a 'bad' state.

0 commit comments

Comments
 (0)