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

16 statements  

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

1"""Add indices for coalesced `start time` sorts 

2 

3Revision ID: 4f90ad6349bd 

4Revises: a0284438370e 

5Create Date: 2022-11-10 16:59:21.884051 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10from alembic import op 1a

11 

12# revision identifiers, used by Alembic. 

13revision = "4f90ad6349bd" 1a

14down_revision = "a0284438370e" 1a

15branch_labels = None 1a

16depends_on = None 1a

17 

18 

19def upgrade(): 1a

20 # ### commands auto generated by Alembic - please adjust! ### 

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

22 batch_op.drop_index( 1a

23 "ix_flow_run__scheduler_deployment_id_auto_scheduled_next_scheduled_start_time" 

24 ) 

25 batch_op.create_index( 1a

26 "ix_flow_run__coalesce_start_time_expected_start_time_asc", 

27 [sa.text("coalesce('start_time', 'expected_start_time') ASC")], 

28 unique=False, 

29 ) 

30 batch_op.create_index( 1a

31 "ix_flow_run__coalesce_start_time_expected_start_time_desc", 

32 [sa.text("coalesce('start_time', 'expected_start_time') DESC")], 

33 unique=False, 

34 ) 

35 

36 # ### end Alembic commands ### 

37 

38 

39def downgrade(): 1a

40 # ### commands auto generated by Alembic - please adjust! ### 

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

42 batch_op.execute( 

43 "DROP INDEX IF EXISTS" 

44 " ix_flow_run__coalesce_start_time_expected_start_time_desc" 

45 ) 

46 batch_op.execute( 

47 "DROP INDEX IF EXISTS" 

48 " ix_flow_run__coalesce_start_time_expected_start_time_asc" 

49 ) 

50 batch_op.create_index( 

51 "ix_flow_run__scheduler_deployment_id_auto_scheduled_next_scheduled_start_time", 

52 ["deployment_id", "auto_scheduled", "next_scheduled_start_time"], 

53 unique=False, 

54 ) 

55 # ### end Alembic commands ###