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

18 statements  

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

1"""Adding scope to followers 

2 

3Revision ID: 354f1ede7e9f 

4Revises: 2ac65f1758c2 

5Create Date: 2024-07-15 14:53:50.718831 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10from alembic import op 1a

11 

12# revision identifiers, used by Alembic. 

13revision = "354f1ede7e9f" 1a

14down_revision = "2ac65f1758c2" 1a

15branch_labels = None 1a

16depends_on = None 1a

17 

18 

19def upgrade(): 1a

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

21 batch_op.add_column(sa.Column("scope", sa.String(), nullable=False)) 1a

22 batch_op.drop_constraint( 1a

23 "uq_automation_event_follower__follower_event_id", type_="unique" 

24 ) 

25 batch_op.create_index( 1a

26 batch_op.f("ix_automation_event_follower__scope"), ["scope"], unique=False 

27 ) 

28 batch_op.create_index( 1a

29 "uq_follower_for_scope", ["scope", "follower_event_id"], unique=True 

30 ) 

31 

32 

33def downgrade(): 1a

34 with op.batch_alter_table("automation_event_follower", schema=None) as batch_op: 

35 batch_op.drop_index("uq_follower_for_scope") 

36 batch_op.drop_index(batch_op.f("ix_automation_event_follower__scope")) 

37 batch_op.create_unique_constraint( 

38 "uq_automation_event_follower__follower_event_id", ["follower_event_id"] 

39 ) 

40 batch_op.drop_column("scope")