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

15 statements  

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

1"""Remove Artifact foreign keys 

2 

3Revision ID: 8d148e44e669 

4Revises: bfe42b7090d6 

5Create Date: 2023-02-08 15:20:28.289591 

6 

7""" 

8 

9from alembic import op 1a

10 

11# revision identifiers, used by Alembic. 

12revision = "8d148e44e669" 1a

13down_revision = "bfe42b7090d6" 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("artifact", schema=None) as batch_op: 1a

22 batch_op.drop_constraint( 1a

23 "fk_artifact__flow_run_id__flow_run", type_="foreignkey" 

24 ) 

25 batch_op.drop_constraint( 1a

26 "fk_artifact__task_run_id__task_run", type_="foreignkey" 

27 ) 

28 

29 

30def downgrade(): 1a

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

32 

33 with op.batch_alter_table("artifact", schema=None) as batch_op: 

34 batch_op.create_foreign_key( 

35 "fk_artifact__task_run_id__task_run", "task_run", ["task_run_id"], ["id"] 

36 ) 

37 batch_op.create_foreign_key( 

38 "fk_artifact__flow_run_id__flow_run", "flow_run", ["flow_run_id"], ["id"] 

39 )