1717branch_labels : str | Sequence [str ] | None = None
1818depends_on : str | Sequence [str ] | None = None
1919
20- # get naming convention from the context
21- migration_context = context .get_context ()
22- target_metadata = migration_context .opts .get ("target_metadata" )
23- assert target_metadata is not None , "Target metadata must be set in the migration context"
24- naming_convention = target_metadata .naming_convention
20+
21+ def get_naming_convention ():
22+ # get naming convention from the context
23+ migration_context = context .get_context ()
24+ target_metadata = migration_context .opts .get ("target_metadata" )
25+ assert target_metadata is not None , "Target metadata must be set in the migration context"
26+ return target_metadata .naming_convention
2527
2628
2729def upgrade () -> None :
30+ naming_convention = get_naming_convention ()
31+
2832 with op .batch_alter_table ('test_minted_blocks' , schema = None , naming_convention = naming_convention ) as batch_op :
2933 batch_op .drop_constraint ('test_minted_blocks_vcs_project_id_fkey' , type_ = 'foreignkey' )
3034 batch_op .create_foreign_key (batch_op .f ('test_minted_blocks_vcs_project_id_fkey' ), 'test_vcs_projects' , ['vcs_project_id' ], ['id' ])
@@ -51,6 +55,8 @@ def upgrade() -> None:
5155
5256
5357def downgrade () -> None :
58+ naming_convention = get_naming_convention ()
59+
5460 with op .batch_alter_table ('test_sinking_txs' , schema = None , naming_convention = naming_convention ) as batch_op :
5561 batch_op .drop_constraint (batch_op .f ('test_sinking_txs_vcs_project_id_fkey' ), type_ = 'foreignkey' )
5662 batch_op .create_foreign_key (None , 'vcs_projects' , ['vcs_project_id' ], ['id' ])
0 commit comments