1 """add_index_on_log
2
3 Revision ID: 553920ec20e9
4 Revises: 422f8ba9541d
5 Create Date: 2023-04-04 11:51:50.514999
6
7 """
8
9 from alembic import op 1 ctx 1a
10
11 # revision identifiers, used by Alembic.
12 revision = "553920ec20e9" 1 ctx 1a
13 down_revision = "422f8ba9541d" 1 ctx 1a
14 branch_labels = None 1 ctx 1a
15 depends_on = None 1 ctx 1a
16
17
18 def upgrade ( ) : 1 ctx 1a
19 op . execute ( "PRAGMA foreign_keys=OFF" ) 1 ctx 1a
20
21 with op . batch_alter_table ( "log" , schema = None ) as batch_op : 1 ctx 1a
22 batch_op . create_index ( 1 ctx 1a
23 "ix_log__flow_run_id_timestamp" , [ "flow_run_id" , "timestamp" ] , unique = False
24 )
25
26 op . execute ( "PRAGMA foreign_keys=ON" ) 1 ctx 1a
27
28
29 def downgrade ( ) : 1 ctx 1a
30 op . execute ( "PRAGMA foreign_keys=OFF" )
31
32 with op . batch_alter_table ( "log" , schema = None ) as batch_op :
33 batch_op . drop_index ( "ix_log__flow_run_id_timestamp" )
34
35 op . execute ( "PRAGMA foreign_keys=ON" )