本文整理汇总了Python中alembic.op.drop_constraint方法的典型用法代码示例。如果您正苦于以下问题:Python op.drop_constraint方法的具体用法?Python op.drop_constraint怎么用?Python op.drop_constraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alembic.op
的用法示例。
在下文中一共展示了op.drop_constraint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
conn = op.get_bind()
insp = inspect(conn)
fk_names = [fk['name'] for fk in insp.get_foreign_keys('host')]
if ("fk_hypervisor_id_resource_id" not in fk_names and
"fk_host_id_resource_id" in fk_names):
# NOTE(sileht): we are already good, the BD have been created from
# scratch after "a54c57ada3f5"
return
op.drop_constraint("fk_hypervisor_id_resource_id", "host",
type_="foreignkey")
op.drop_constraint("fk_hypervisor_history_resource_history_revision",
"host_history", type_="foreignkey")
op.create_foreign_key("fk_host_id_resource_id", "host", "resource",
["id"], ["id"], ondelete="CASCADE")
op.create_foreign_key("fk_host_history_resource_history_revision",
"host_history", "resource_history",
["revision"], ["revision"], ondelete="CASCADE")
示例2: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
bind = op.get_bind()
# NOTE(sileht): mysql can't delete an index on a foreign key
# even this one is not the index used by the foreign key itself...
# In our case we have two indexes fk_resource_history_id_resource_id and
# and ix_resource_history_id, we want to delete only the second, but mysql
# can't do that with a simple DROP INDEX ix_resource_history_id...
# so we have to remove the constraint and put it back...
if bind.engine.name == "mysql":
op.drop_constraint("fk_resource_history_id_resource_id",
type_="foreignkey", table_name="resource_history")
for table, colname in resource_tables + history_tables + other_tables:
op.drop_index("ix_%s_%s" % (table, colname), table_name=table)
if bind.engine.name == "mysql":
op.create_foreign_key("fk_resource_history_id_resource_id",
"resource_history", "resource", ["id"], ["id"],
ondelete="CASCADE")
示例3: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
bind = op.get_bind()
session = Session(bind=bind)
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('pull_mirror', sa.Column('gitlab_id', sa.INTEGER(), nullable=True))
for pull_mirror in session.query(PullMirror):
pull_mirror.gitlab_id = pull_mirror.project.gitlab_id
session.add(pull_mirror)
session.commit()
op.drop_constraint(None, 'pull_mirror', type_='foreignkey')
op.drop_index(op.f('ix_pull_mirror_project_id'), table_name='pull_mirror')
op.drop_column('pull_mirror', 'project_id')
op.drop_index(op.f('ix_push_mirror_user_id'), table_name='push_mirror')
op.drop_index(op.f('ix_push_mirror_project_id'), table_name='push_mirror')
op.drop_table('push_mirror')
op.drop_table('project')
# ### end Alembic commands ###
示例4: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('fido',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
sa.Column('credential_id', sa.String(), nullable=False),
sa.Column('uuid', sa.String(), nullable=False),
sa.Column('public_key', sa.String(), nullable=False),
sa.Column('sign_count', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=False),
sa.ForeignKeyConstraint(['uuid'], ['users.fido_uuid'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('public_key')
)
op.create_index(op.f('ix_fido_credential_id'), 'fido', ['credential_id'], unique=True)
op.drop_constraint('users_fido_credential_id_key', 'users', type_='unique')
op.drop_constraint('users_fido_pk_key', 'users', type_='unique')
op.drop_column('users', 'fido_sign_count')
op.drop_column('users', 'fido_pk')
op.drop_column('users', 'fido_credential_id')
# ### end Alembic commands ###
示例5: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
op.drop_constraint('fk_vfolder_attachment_vfolder_vfolders', 'vfolder_attachment', type_='foreignkey')
op.drop_constraint('fk_vfolder_attachment_kernel_kernels', 'vfolder_attachment', type_='foreignkey')
op.drop_constraint('pk_kernels', 'kernels', type_='primary')
op.add_column('kernels',
sa.Column('id', GUID(),
server_default=sa.text('uuid_generate_v4()'),
nullable=False))
op.add_column('kernels', sa.Column('role', sa.String(length=16), nullable=False, default='master'))
op.create_primary_key('pk_kernels', 'kernels', ['id'])
op.alter_column(
'kernels', 'sess_id',
existing_type=postgresql.UUID(),
type_=sa.String(length=64),
nullable=True,
existing_server_default=sa.text('uuid_generate_v4()'))
op.create_index(op.f('ix_kernels_sess_id'), 'kernels', ['sess_id'], unique=False)
op.create_index(op.f('ix_kernels_sess_id_role'), 'kernels', ['sess_id', 'role'], unique=False)
op.create_foreign_key('fk_vfolder_attachment_vfolder_vfolders',
'vfolder_attachment', 'vfolders',
['vfolder'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
op.create_foreign_key('fk_vfolder_attachment_kernel_kernels',
'vfolder_attachment', 'kernels',
['kernel'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
示例6: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
op.drop_constraint('fk_vfolder_attachment_vfolder_vfolders', 'vfolder_attachment', type_='foreignkey')
op.drop_constraint('fk_vfolder_attachment_kernel_kernels', 'vfolder_attachment', type_='foreignkey')
op.drop_constraint('pk_kernels', 'kernels', type_='primary')
op.drop_index(op.f('ix_kernels_sess_id'), table_name='kernels')
op.drop_index(op.f('ix_kernels_sess_id_role'), table_name='kernels')
op.alter_column(
'kernels', 'sess_id',
existing_type=sa.String(length=64),
type_=postgresql.UUID(),
nullable=False,
existing_server_default=sa.text('uuid_generate_v4()'),
postgresql_using='sess_id::uuid')
op.create_primary_key('pk_kernels', 'kernels', ['sess_id'])
op.drop_column('kernels', 'id')
op.drop_column('kernels', 'role')
op.create_foreign_key('fk_vfolder_attachment_vfolder_vfolders',
'vfolder_attachment', 'vfolders',
['vfolder'], ['id'])
op.create_foreign_key('fk_vfolder_attachment_kernel_kernels',
'vfolder_attachment', 'kernels',
['kernel'], ['sess_id'])
示例7: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(op.f('fk_kernels_scaling_group_scaling_groups'), 'kernels', type_='foreignkey')
op.drop_index(op.f('ix_kernels_scaling_group'), table_name='kernels')
op.drop_column('kernels', 'scaling_group')
op.drop_constraint(op.f('fk_agents_scaling_group_scaling_groups'), 'agents', type_='foreignkey')
op.drop_index(op.f('ix_agents_scaling_group'), table_name='agents')
op.drop_column('agents', 'scaling_group')
op.drop_index(op.f('ix_sgroups_for_keypairs_scaling_group'), table_name='sgroups_for_keypairs')
op.drop_index(op.f('ix_sgroups_for_keypairs_access_key'), table_name='sgroups_for_keypairs')
op.drop_table('sgroups_for_keypairs')
op.drop_index(op.f('ix_sgroups_for_groups_scaling_group'), table_name='sgroups_for_groups')
op.drop_index(op.f('ix_sgroups_for_groups_group'), table_name='sgroups_for_groups')
op.drop_table('sgroups_for_groups')
op.drop_index(op.f('ix_sgroups_for_domains_scaling_group'), table_name='sgroups_for_domains')
op.drop_index(op.f('ix_sgroups_for_domains_domain'), table_name='sgroups_for_domains')
op.drop_table('sgroups_for_domains')
op.drop_index(op.f('ix_scaling_groups_is_active'), table_name='scaling_groups')
op.drop_table('scaling_groups')
# ### end Alembic commands ###
示例8: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
""" Alter the pull_requests table to update the foreign key to set null
on delete.
"""
op.drop_constraint(
'pull_requests_project_id_from_fkey',
'pull_requests',
type_='foreignkey')
op.create_foreign_key(
name='pull_requests_project_id_from_fkey',
source_table='pull_requests',
referent_table='projects',
local_cols=['project_id_from'],
remote_cols=['id'],
onupdate='cascade',
ondelete='set null',
)
示例9: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
""" Alter the pull_requests table to update the foreign key to cascade
on delete.
"""
op.drop_constraint(
'pull_requests_project_id_from_fkey',
'pull_requests',
type_='foreignkey')
op.create_foreign_key(
name='pull_requests_project_id_from_fkey',
source_table='pull_requests',
referent_table='projects',
local_cols=['project_id_from'],
remote_cols=['id'],
onupdate='cascade',
ondelete='cascade',
)
示例10: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('rss_parser_feed_name_lut', sa.Column('feed_id', sa.BigInteger(), nullable=False))
op.create_index(op.f('ix_rss_parser_feed_name_lut_feed_id'), 'rss_parser_feed_name_lut', ['feed_id'], unique=False)
op.drop_index('ix_rss_parser_feed_name_lut_feed_name', table_name='rss_parser_feed_name_lut')
op.drop_constraint('rss_parser_feed_name_lut_feed_netloc_feed_name_key', 'rss_parser_feed_name_lut', type_='unique')
op.create_unique_constraint(None, 'rss_parser_feed_name_lut', ['feed_netloc', 'feed_id'])
op.drop_constraint('rss_parser_feed_name_lut_feed_name_fkey', 'rss_parser_feed_name_lut', type_='foreignkey')
op.create_foreign_key(None, 'rss_parser_feed_name_lut', 'rss_parser_funcs', ['feed_id'], ['id'])
op.drop_column('rss_parser_feed_name_lut', 'feed_name')
op.add_column('rss_parser_feed_name_lut_version', sa.Column('feed_id', sa.BigInteger(), autoincrement=False, nullable=True))
op.create_index(op.f('ix_rss_parser_feed_name_lut_version_feed_id'), 'rss_parser_feed_name_lut_version', ['feed_id'], unique=False)
op.drop_index('ix_rss_parser_feed_name_lut_version_feed_name', table_name='rss_parser_feed_name_lut_version')
op.drop_column('rss_parser_feed_name_lut_version', 'feed_name')
op.alter_column('rss_parser_funcs', 'func',
existing_type=sa.TEXT(),
nullable=True)
### end Alembic commands ###
示例11: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.alter_column('rss_parser_funcs', 'func',
existing_type=sa.TEXT(),
nullable=False)
op.add_column('rss_parser_feed_name_lut_version', sa.Column('feed_name', sa.TEXT(), autoincrement=False, nullable=True))
op.create_index('ix_rss_parser_feed_name_lut_version_feed_name', 'rss_parser_feed_name_lut_version', ['feed_name'], unique=False)
op.drop_index(op.f('ix_rss_parser_feed_name_lut_version_feed_id'), table_name='rss_parser_feed_name_lut_version')
op.drop_column('rss_parser_feed_name_lut_version', 'feed_id')
op.add_column('rss_parser_feed_name_lut', sa.Column('feed_name', sa.TEXT(), autoincrement=False, nullable=False))
op.drop_constraint(None, 'rss_parser_feed_name_lut', type_='foreignkey')
op.create_foreign_key('rss_parser_feed_name_lut_feed_name_fkey', 'rss_parser_feed_name_lut', 'rss_parser_funcs', ['feed_name'], ['feed_name'])
op.drop_constraint(None, 'rss_parser_feed_name_lut', type_='unique')
op.create_unique_constraint('rss_parser_feed_name_lut_feed_netloc_feed_name_key', 'rss_parser_feed_name_lut', ['feed_netloc', 'feed_name'])
op.create_index('ix_rss_parser_feed_name_lut_feed_name', 'rss_parser_feed_name_lut', ['feed_name'], unique=False)
op.drop_index(op.f('ix_rss_parser_feed_name_lut_feed_id'), table_name='rss_parser_feed_name_lut')
op.drop_column('rss_parser_feed_name_lut', 'feed_id')
### end Alembic commands ###
示例12: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('web_pages_version', sa.Column('is_delta', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'web_pages_version', type_='foreignkey')
op.drop_column('web_pages_version', 'parent_hash')
op.drop_column('web_pages_version', 'data_hash')
op.add_column('rss_parser_funcs_version', sa.Column('is_delta', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'rss_parser_funcs_version', type_='foreignkey')
op.drop_column('rss_parser_funcs_version', 'parent_hash')
op.drop_column('rss_parser_funcs_version', 'data_hash')
op.add_column('rss_parser_feed_name_lut_version', sa.Column('is_delta', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'rss_parser_feed_name_lut_version', type_='foreignkey')
op.drop_column('rss_parser_feed_name_lut_version', 'parent_hash')
op.drop_column('rss_parser_feed_name_lut_version', 'data_hash')
op.add_column('raw_web_pages_version', sa.Column('is_delta', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.drop_constraint(None, 'raw_web_pages_version', type_='foreignkey')
op.drop_column('raw_web_pages_version', 'parent_hash')
op.drop_column('raw_web_pages_version', 'data_hash')
# ### end Alembic commands ###
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:21,代码来源:2019-09-08_c225ea8fbf5e_add_hash_and_parent_hash_columns.py
示例13: upgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('citizen_complaint_opaque_id_key', 'citizen_complaint', type_='unique')
op.drop_constraint('use_of_force_incidents_opaque_id_key', 'use_of_force_incidents', type_='unique')
### end Alembic commands ###
示例14: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'users', type_='foreignkey')
op.drop_column('users', 'department_id')
### end Alembic commands ###
示例15: downgrade
# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import drop_constraint [as 别名]
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'users', type_='unique')
op.drop_column('users', 'password_reset_uuid')
### end Alembic commands ###