Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2025_06_13_164506_8bb517bae6f9_drop_task_run_state_id_foreign_key_.py: 82%

11 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 11:21 +0000

1"""Drop task_run state_id foreign key constraint 

2 

3Revision ID: 8bb517bae6f9 

4Revises: bb2345678901 

5Create Date: 2025-06-13 16:45:06.404249 

6 

7""" 

8 

9from alembic import op 1a

10 

11# revision identifiers, used by Alembic. 

12revision = "8bb517bae6f9" 1a

13down_revision = "bb2345678901" 1a

14branch_labels = None 1a

15depends_on = None 1a

16 

17 

18def upgrade(): 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: 1a

21 batch_op.drop_constraint("fk_task_run__state_id__task_run_state") 1a

22 

23 

24def downgrade(): 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 )