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

19 statements  

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

1"""Worker status field 

2 

3Revision ID: a8e62d4c72cf 

4Revises: 75c8f17b8b51 

5Create Date: 2024-04-25 15:51:20.234353 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10from alembic import op 1a

11 

12from prefect.server.utilities.database import UUID, Timestamp 1a

13 

14# revision identifiers, used by Alembic. 

15revision = "a8e62d4c72cf" 1a

16down_revision = "75c8f17b8b51" 1a

17branch_labels = None 1a

18depends_on = None 1a

19 

20 

21def upgrade(): 1a

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

23 batch_op.add_column( 1a

24 sa.Column( 

25 "last_transitioned_status_at", Timestamp(timezone=True), nullable=True 

26 ), 

27 ) 

28 batch_op.add_column(sa.Column("last_status_event_id", UUID(), nullable=True)) 1a

29 

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

31 batch_op.add_column( 1a

32 sa.Column( 

33 "status", 

34 sa.Enum("ONLINE", "OFFLINE", name="worker_status"), 

35 server_default="OFFLINE", 

36 nullable=False, 

37 ) 

38 ) 

39 

40 

41def downgrade(): 1a

42 with op.batch_alter_table("worker", schema=None) as batch_op: 

43 batch_op.drop_column("status") 

44 

45 with op.batch_alter_table("work_pool", schema=None) as batch_op: 

46 batch_op.drop_column("last_transitioned_status_at") 

47 batch_op.drop_column("last_status_event_id")