def downgrade():
table_prefix = context.config.get_main_option('table_prefix')
table_name = table_prefix + 'resource_values'
with op.batch_alter_table(table_name) as batch:
batch.drop_constraint(table_name + '_resource_definition_id_fkey',
'foreignkey')
op.create_table(
table_prefix + 'namespace',
sa.Column('id', sa.Integer(), nullable=False, primary_key=True),
sa.Column('name', sa.String(length=128), nullable=True),
)
table_name = table_prefix + 'schema'
op.rename_table(table_prefix + 'resource_definition', table_name)
with op.batch_alter_table(table_name) as batch:
batch.add_column(
sa.Column('namespace_id', sa.Integer(), nullable=True))
table_name = table_prefix + 'environment_schema_values'
op.rename_table(table_prefix + 'resource_values', table_name)
with op.batch_alter_table(table_name) as batch:
batch.alter_column(
'resource_definition_id',
new_column_name='schema_id',
existing_type=sa.Integer(),
)
batch.create_foreign_key(
table_name + '_schema_id_fkey',
table_prefix + 'schema',
['schema_id'],
['id'],
)
table_name = table_prefix + 'template'
op.create_table(
table_name,
sa.Column('id', sa.Integer(), nullable=False, primary_key=True),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('component_id', sa.Integer(), nullable=True),
sa.Column('content', tuning_box.db.Json(), nullable=True),
sa.ForeignKeyConstraint(
['component_id'], [table_prefix + 'component.id'],
name=table_name + '_component_id_fkey',
),
)
3b2a0f134e45_switch_to_new_api.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录