本文整理汇总了Python中migrate.changeset.constraint.UniqueConstraint.drop方法的典型用法代码示例。如果您正苦于以下问题:Python UniqueConstraint.drop方法的具体用法?Python UniqueConstraint.drop怎么用?Python UniqueConstraint.drop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类migrate.changeset.constraint.UniqueConstraint
的用法示例。
在下文中一共展示了UniqueConstraint.drop方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
# Operations to reverse the above upgrade go here.
meta = MetaData(bind=migrate_engine)
submissions = Table('submissions', meta, autoload=True)
slugu = UniqueConstraint(submissions.c.slug)
slugu.drop()
submissions.c.slug.drop()
示例2: upgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def upgrade(migrate_engine):
meta.bind = migrate_engine
dialect = migrate_engine.url.get_dialect().name
domains_table = Table('domains', meta, autoload=True)
if dialect.startswith('sqlite'):
# SQLite can't drop a constraint. Yay. This will be fun..
# Create a new name column without the unique index
name_tmp_column = Column('name_tmp', String(255))
name_tmp_column.create(domains_table)
# Copy the data over.
query = update(domains_table).values(name_tmp=domains_table.c.name)
migrate_engine.execute(query)
# Delete the name column
domains_table.c.name.drop()
# Rename the name_tmp column to name
domains_table.c.name_tmp.alter(name='name')
elif dialect.startswith('postgresql'):
constraint = UniqueConstraint('name', name='domains_name_key',
table=domains_table)
constraint.drop()
else:
constraint = UniqueConstraint('name', name='name', table=domains_table)
constraint.drop()
示例3: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta = sqlalchemy.MetaData(bind=migrate_engine)
event = sqlalchemy.Table('event', meta, autoload=True)
message_id = sqlalchemy.Column('message_id', sqlalchemy.String(50))
cons = UniqueConstraint('message_id', table=event)
cons.drop()
index = sqlalchemy.Index('idx_event_message_id', models.Event.message_id)
index.drop(bind=migrate_engine)
event.drop_column(message_id)
示例4: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta.bind = migrate_engine
dialect = migrate_engine.url.get_dialect().name
if dialect.startswith('sqlite'):
records_table = Table('records', meta, autoload=True)
# Drop the unique index
constraint = UniqueConstraint('hash',
name='unique_recordset',
table=records_table)
constraint.drop()
示例5: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta.bind = migrate_engine
domains_table = Table('domains', meta, autoload=True)
constraint = UniqueConstraint('name', 'deleted', 'pool_id',
name=CONSTRAINT_NAME,
table=domains_table)
constraint.drop()
constraint = UniqueConstraint('name', 'deleted',
name=CONSTRAINT_NAME,
table=domains_table)
constraint.create()
示例6: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta.bind = migrate_engine
dialect = migrate_engine.url.get_dialect().name
if dialect.startswith('sqlite'):
domains_table = Table('domains', meta, autoload=True)
servers_table = Table('servers', meta, autoload=True)
# Add a new multi-column unique index
constraint = UniqueConstraint('name', 'deleted',
name='unique_domain_name',
table=domains_table)
constraint.drop()
# Add a missing unique index
constraint = UniqueConstraint('name',
name='unique_server_name',
table=servers_table)
constraint.drop()
示例7: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta.bind = migrate_engine
domains_table = Table("domains", meta, autoload=True)
# Drop the multi-column unique index
constraint = UniqueConstraint("name", "deleted", name="unique_domain_name", table=domains_table)
constraint.drop()
# Revert to single column unique
# NOTE(kiall): It appears this does nothing. Miration 17 has been added.
# leaving this here for reference.
domains_table.c.name.alter(unique=True)
# Drop the deleted columns
deleted_column = Column("deleted", CHAR(32), nullable=True, default=None)
deleted_column.drop(domains_table)
deleted_at_column = Column("deleted_at", DateTime, nullable=True, default=None)
deleted_at_column.drop(domains_table)
示例8: test_failure
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def test_failure(self):
# Drop unique constraint so we can test error cases
constraint = UniqueConstraint('service_name', 'hostname',
table=self.service_statuses_table,
name="unique_service_status")
constraint.drop()
fake_record = {'id': '1',
'service_name': 'worker',
'hostname': 'localhost',
'status': 'UP',
'stats': '',
'capabilities': '',
}
self.service_statuses_table.insert().execute(fake_record)
fake_record['id'] = '2'
self.service_statuses_table.insert().execute(fake_record)
checks = status.Checks()
self.assertEqual(upgradecheck.Code.FAILURE,
checks._duplicate_service_status().code)
示例9: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta.bind = migrate_engine
pool_attributes_table = Table('pool_attributes', meta, autoload=True)
# pools = Table('pools', meta, autoload=True)
constraint = UniqueConstraint('pool_id', 'key', 'value',
name='unique_pool_attribute',
table=pool_attributes_table)
fk_constraint = ForeignKeyConstraint(columns=['pool_id'],
refcolumns=['pools.id'],
ondelete='CASCADE',
table=pool_attributes_table)
# First have to drop the ForeignKeyConstraint
fk_constraint.drop()
# Then drop the UniqueConstraint
constraint.drop()
# Then recreate the ForeignKeyConstraint
fk_constraint.create()
示例10: upgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def upgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine
c_names = _get_constraint_names(migrate_engine.name)
table = Table('instance_types', meta, autoload=True)
for constraint_name in c_names['instance_types_name']:
cons = UniqueConstraint('name',
name=constraint_name,
table=table)
cons.drop()
cons = UniqueConstraint('flavorid',
name=c_names['instance_types_flavorid'],
table=table)
cons.drop()
table = Table('volume_types', meta, autoload=True)
cons = UniqueConstraint('name',
name=c_names['volume_types_name'],
table=table)
cons.drop()
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:22,代码来源:076_remove_unique_constraints.py
示例11: upgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def upgrade(migrate_engine):
meta.bind = migrate_engine
table = Table('instance_types', meta, autoload=True)
# NOTE(vish): These constraint names may be dependent on the backend, but
# there doesn't seem to be we a way to determine the proper
# name for existing constraints. These names are correct for
# mysql.
cons = UniqueConstraint('name',
name='name',
table=table)
cons.drop()
cons = UniqueConstraint('flavorid',
name='instance_types_flavorid_str_key',
table=table)
cons.drop()
table = Table('volume_types', meta, autoload=True)
cons = UniqueConstraint('name',
name='name',
table=table)
cons.drop()
示例12: downgrade
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def downgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
cons = UniqueConstraint('owner_hash', table=files)
cons.drop()
示例13: drop_unique_constraint
# 需要导入模块: from migrate.changeset.constraint import UniqueConstraint [as 别名]
# 或者: from migrate.changeset.constraint.UniqueConstraint import drop [as 别名]
def drop_unique_constraint(uc_def):
uc = UniqueConstraint(*uc_def[2], table=uc_def[0], name=uc_def[1])
try:
uc.drop()
except PathNotFoundError:
pass