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

27 statements  

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

1"""Add cols to artifact_collection 

2 

3Revision ID: 3e1eb8281d5e 

4Revises: 553920ec20e9 

5Create Date: 2023-04-04 17:25:55.589739 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10from alembic import op 1a

11 

12import prefect 1a

13 

14# revision identifiers, used by Alembic. 

15revision = "3e1eb8281d5e" 1a

16down_revision = "553920ec20e9" 1a

17branch_labels = None 1a

18depends_on = None 1a

19 

20 

21def upgrade(): 1a

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

23 

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

25 batch_op.add_column( 1a

26 sa.Column( 

27 "task_run_id", prefect.server.utilities.database.UUID(), nullable=True 

28 ) 

29 ) 

30 batch_op.add_column( 1a

31 sa.Column( 

32 "flow_run_id", prefect.server.utilities.database.UUID(), nullable=True 

33 ) 

34 ) 

35 batch_op.add_column(sa.Column("type", sa.String(), nullable=True)) 1a

36 batch_op.add_column(sa.Column("data", sa.JSON(), nullable=True)) 1a

37 batch_op.add_column(sa.Column("description", sa.String(), nullable=True)) 1a

38 batch_op.add_column(sa.Column("metadata_", sa.JSON(), nullable=True)) 1a

39 

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

41 

42 

43def downgrade(): 1a

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

45 

46 with op.batch_alter_table("artifact_collection", schema=None) as batch_op: 

47 batch_op.drop_column("metadata_") 

48 batch_op.drop_column("description") 

49 batch_op.drop_column("data") 

50 batch_op.drop_column("type") 

51 batch_op.drop_column("flow_run_id") 

52 batch_op.drop_column("task_run_id") 

53 

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