Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2023_03_01_165551_f3df94dca3cc_remove_flowrun_deployment_fk.py: 73%

15 statements  

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

1"""remove_flowrun_deployment_fk 

2 

3Revision ID: f3df94dca3cc 

4Revises: 8d148e44e669 

5Create Date: 2023-03-01 16:55:51.274067 

6 

7""" 

8 

9from alembic import op 1a

10 

11# revision identifiers, used by Alembic. 

12revision = "f3df94dca3cc" 1a

13down_revision = "8d148e44e669" 1a

14branch_labels = None 1a

15depends_on = None 1a

16 

17 

18def upgrade(): 1a

19 op.execute("PRAGMA foreign_keys=OFF") 1a

20 

21 with op.batch_alter_table("flow_run", schema=None) as batch_op: 1a

22 batch_op.drop_constraint( 1a

23 "fk_flow_run__deployment_id__deployment", type_="foreignkey" 

24 ) 

25 

26 op.execute("PRAGMA foreign_keys=ON") 1a

27 

28 

29def downgrade(): 1a

30 op.execute("PRAGMA foreign_keys=OFF") 

31 

32 with op.batch_alter_table("flow_run", schema=None) as batch_op: 

33 batch_op.create_foreign_key( 

34 "fk_flow_run__deployment_id__deployment", 

35 "deployment", 

36 ["deployment_id"], 

37 ["id"], 

38 ) 

39 

40 op.execute("PRAGMA foreign_keys=ON")