Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2022_05_30_100855_d76326ed0d06_rename_run_alerts_to_run_notifications.py: 59%

37 statements  

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

1"""Rename run alerts to run notifications 

2 

3Revision ID: d76326ed0d06 

4Revises: 33439667aeea 

5Create Date: 2022-05-30 10:08:55.886326 

6 

7""" 

8 

9from alembic import op 1a

10 

11# revision identifiers, used by Alembic. 

12revision = "d76326ed0d06" 1a

13down_revision = "e73c6f1fe752" 1a

14branch_labels = None 1a

15depends_on = None 1a

16 

17 

18def upgrade(): 1a

19 # policy table 

20 op.rename_table("flow_run_alert_policy", "flow_run_notification_policy") 1a

21 with op.batch_alter_table("flow_run_notification_policy") as batch_op: 1a

22 batch_op.drop_index("ix_flow_run_alert_policy__name") 1a

23 batch_op.create_index( 1a

24 op.f("ix_flow_run_notification_policy__name"), 

25 ["name"], 

26 unique=False, 

27 ) 

28 batch_op.drop_index("ix_flow_run_alert_policy__updated") 1a

29 batch_op.create_index( 1a

30 op.f("ix_flow_run_notification_policy__updated"), 

31 ["updated"], 

32 unique=False, 

33 ) 

34 batch_op.drop_constraint("pk_flow_run_alert") 1a

35 batch_op.create_primary_key("pk_flow_run_notification_policy", ["id"]) 1a

36 

37 # queue table 

38 op.rename_table("flow_run_alert_queue", "flow_run_notification_queue") 1a

39 with op.batch_alter_table("flow_run_notification_queue") as batch_op: 1a

40 batch_op.alter_column( 1a

41 "flow_run_alert_policy_id", 

42 new_column_name="flow_run_notification_policy_id", 

43 ) 

44 batch_op.drop_index("ix_flow_run_alert_queue__updated") 1a

45 batch_op.create_index( 1a

46 op.f("ix_flow_run_notification_queue__updated"), 

47 ["updated"], 

48 unique=False, 

49 ) 

50 batch_op.drop_constraint("pk_flow_run_alert_queue") 1a

51 batch_op.create_primary_key("pk_flow_run_notification_queue", ["id"]) 1a

52 

53 

54def downgrade(): 1a

55 # queue table 

56 op.rename_table("flow_run_notification_queue", "flow_run_alert_queue") 

57 with op.batch_alter_table("flow_run_alert_queue") as batch_op: 

58 batch_op.alter_column( 

59 "flow_run_notification_policy_id", 

60 new_column_name="flow_run_alert_policy_id", 

61 ) 

62 batch_op.drop_index("ix_flow_run_notification_queue__updated") 

63 batch_op.create_index( 

64 op.f("ix_flow_run_alert_queue__updated"), 

65 ["updated"], 

66 unique=False, 

67 ) 

68 batch_op.drop_constraint("pk_flow_run_notification_queue") 

69 batch_op.create_primary_key("pk_flow_run_alert_queue", ["id"]) 

70 

71 # policy table 

72 op.rename_table("flow_run_notification_policy", "flow_run_alert_policy") 

73 with op.batch_alter_table("flow_run_alert_policy") as batch_op: 

74 batch_op.drop_index("ix_flow_run_notification_policy__name") 

75 batch_op.create_index( 

76 op.f("ix_flow_run_alert_policy__name"), 

77 ["name"], 

78 unique=False, 

79 ) 

80 batch_op.drop_index("ix_flow_run_notification_policy__updated") 

81 batch_op.create_index( 

82 op.f("ix_flow_run_alert_policy__updated"), 

83 ["updated"], 

84 unique=False, 

85 ) 

86 batch_op.drop_constraint("pk_flow_run_notification_policy") 

87 batch_op.create_primary_key("pk_flow_run_alert", ["id"])