

def upgrade():
    migration_context = context.get_context()
    insp = reflection.Inspector(migration_context.bind)
    indx_names = [x['name'] for x in migration_context.get_indexes('test_metadata')]
    if (migration_context.dialect.name == 'sqlite'):
        if ('ix_test_key_value' in indx_names):
            op.drop_index('ix_test_key_value', 'test_metadata')
    if (migration_context.dialect.name == 'mysql'):
        op.drop_constraint('test_metadata_ibfk_1', 'test_metadata', 'foreignkey')
    with op.batch_alter_table('test_metadata') as batch_op:
        batch_op.alter_column('test_run_id', existing_type=sa.String(36), existing_nullable=False, new_column_name='test_id')
    if (migration_context.dialect.name == 'mysql'):
        op.create_foreign_key('test_metadata_ibfk_1', 'test_metadata', 'tests', ['test_id'], ['id'])

dataset/ETHPy150Open openstack-infra/subunit2sql/subunit2sql/migrations/versions/2fb76f1a1393_rename_test_id_column_in_test_metadata_.py upgrade/VarMisuse@38/53 `insp`->`migration_context`