Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2024_11_15_151042_5952a5498b51_add_labels_column_to_flow_flowrun_.py: 68%

25 statements  

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

1"""Add `labels` column to Flow, FlowRun, TaskRun, and Deployment 

2 

3Revision ID: 5952a5498b51 

4Revises: 4ad4658cbefe 

5Create Date: 2024-11-15 15:10:42.138653 

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 = "5952a5498b51" 1a

16down_revision = "4ad4658cbefe" 1a

17branch_labels = None 1a

18depends_on = None 1a

19 

20 

21def upgrade(): 1a

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

23 batch_op.add_column( 1a

24 sa.Column( 

25 "labels", 

26 prefect.server.utilities.database.JSON(astext_type=sa.Text()), 

27 nullable=True, 

28 ) 

29 ) 

30 

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

32 batch_op.add_column( 1a

33 sa.Column( 

34 "labels", 

35 prefect.server.utilities.database.JSON(astext_type=sa.Text()), 

36 nullable=True, 

37 ) 

38 ) 

39 

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

41 batch_op.add_column( 1a

42 sa.Column( 

43 "labels", 

44 prefect.server.utilities.database.JSON(astext_type=sa.Text()), 

45 nullable=True, 

46 ) 

47 ) 

48 

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

50 batch_op.add_column( 1a

51 sa.Column( 

52 "labels", 

53 prefect.server.utilities.database.JSON(astext_type=sa.Text()), 

54 nullable=True, 

55 ) 

56 ) 

57 

58 

59def downgrade(): 1a

60 with op.batch_alter_table("task_run", schema=None) as batch_op: 

61 batch_op.drop_column("labels") 

62 

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

64 batch_op.drop_column("labels") 

65 

66 with op.batch_alter_table("flow", schema=None) as batch_op: 

67 batch_op.drop_column("labels") 

68 

69 with op.batch_alter_table("deployment", schema=None) as batch_op: 

70 batch_op.drop_column("labels")