当前位置: 首页>>代码示例>>Python>>正文


Python UniqueConstraint.drop方法代码示例

本文整理汇总了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()
开发者ID:azmikamis,项目名称:raggregate,代码行数:9,代码来源:004_Add_slug_column_on_Submissions.py

示例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()
开发者ID:NeCTAR-RC,项目名称:designate,代码行数:31,代码来源:017_drop_unique_domain_name_index.py

示例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)
开发者ID:Adrian-Turjak,项目名称:ceilometer,代码行数:11,代码来源:014_add_event_message_id.py

示例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()
开发者ID:akshatknsl,项目名称:designate,代码行数:14,代码来源:035_add_unique_record_sqlite.py

示例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()
开发者ID:AnatolyZimin,项目名称:designate,代码行数:16,代码来源:054_allow_duplicate_domains.py

示例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()
开发者ID:NeCTAR-RC,项目名称:designate,代码行数:21,代码来源:018_add_back_unique_name_deleted_sqlite.py

示例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)
开发者ID:raychorn,项目名称:designate,代码行数:22,代码来源:016_add_deleted_columns.py

示例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)
开发者ID:openstack,项目名称:designate,代码行数:22,代码来源:test_upgrade_checks.py

示例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()
开发者ID:AnatolyZimin,项目名称:designate,代码行数:24,代码来源:045_add_uniqueconstraint_to_pool_attributes.py

示例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()
开发者ID:ironcamel,项目名称:nova,代码行数:22,代码来源:076_remove_unique_constraints.py

示例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()
开发者ID:faysalhossain2007,项目名称:passwd.io,代码行数:6,代码来源:005_files_owner_hash_unique_second_try.py

示例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
开发者ID:ISCAS-VDI,项目名称:designate-base,代码行数:8,代码来源:080_domain_to_zone_rename.py


注:本文中的migrate.changeset.constraint.UniqueConstraint.drop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。