1 """Drop task_run state_id foreign key constraint
2
3 Revision ID: 8bb517bae6f9
4 Revises: bb2345678901
5 Create Date: 2025-06-13 16:45:06.404249
6
7 """
8
9 from alembic import op 1 ctx 1a
10
11 # revision identifiers, used by Alembic.
12 revision = "8bb517bae6f9" 1 ctx 1a
13 down_revision = "bb2345678901" 1 ctx 1a
14 branch_labels = None 1 ctx 1a
15 depends_on = None 1 ctx 1a
16
17
18 def upgrade ( ) : 1 ctx 1a
19 # Drop the foreign key constraint from task_run.state_id to task_run_state.id
20 with op . batch_alter_table ( "task_run" ) as batch_op : 1 ctx 1a
21 batch_op . drop_constraint ( "fk_task_run__state_id__task_run_state" ) 1 ctx 1a
22
23
24 def downgrade ( ) : 1 ctx 1a
25 # Re-add the foreign key constraint
26 with op . batch_alter_table ( "task_run" ) as batch_op :
27 batch_op . create_foreign_key (
28 "fk_task_run__state_id__task_run_state" ,
29 "task_run_state" ,
30 [ "state_id" ] ,
31 [ "id" ] ,
32 ondelete = "SET NULL" ,
33 )