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


Python op.create_primary_key方法代码示例

本文整理汇总了Python中alembic.op.create_primary_key方法的典型用法代码示例。如果您正苦于以下问题:Python op.create_primary_key方法的具体用法?Python op.create_primary_key怎么用?Python op.create_primary_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在alembic.op的用法示例。


在下文中一共展示了op.create_primary_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [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') 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:26,代码来源:854bd902b1bc_change_kernel_identification.py

示例2: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [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']) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:24,代码来源:854bd902b1bc_change_kernel_identification.py

示例3: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():
    ''' Remove column access_id from user_projects and projects_groups '''

    # this removes the current constraints as well.
    op.drop_column('user_projects', 'access')
    op.drop_column('projects_groups', 'access')

    # recreate the previous constraints
    op.create_unique_constraint(
            None,
            'user_projects',
            ['project_id', 'user_id'],
    )
    op.create_primary_key(
            None,
            'projects_groups',
            ['project_id', 'group_id'],
    )
    op.drop_table('access_levels') 
开发者ID:Pagure,项目名称:pagure,代码行数:21,代码来源:987edda096f5_access_id_in_user_projects.py

示例4: batch_create_primary_key

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def batch_create_primary_key(cls, operations, constraint_name, columns):
        """Issue a "create primary key" instruction using the
        current batch migration context.

        The batch form of this call omits the ``table_name`` and ``schema``
        arguments from the call.

        .. seealso::

            :meth:`.Operations.create_primary_key`

        """
        op = cls(
            constraint_name, operations.impl.table_name, columns,
            schema=operations.impl.schema
        )
        return operations.invoke(op) 
开发者ID:jpush,项目名称:jbox,代码行数:19,代码来源:ops.py

示例5: create_followers_to_followings_table

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def create_followers_to_followings_table() -> None:
    op.create_table(
        "followers_to_followings",
        sa.Column(
            "follower_id",
            sa.Integer,
            sa.ForeignKey("users.id", ondelete="CASCADE"),
            nullable=False,
        ),
        sa.Column(
            "following_id",
            sa.Integer,
            sa.ForeignKey("users.id", ondelete="CASCADE"),
            nullable=False,
        ),
    )
    op.create_primary_key(
        "pk_followers_to_followings",
        "followers_to_followings",
        ["follower_id", "following_id"],
    ) 
开发者ID:nsidnev,项目名称:fastapi-realworld-example-app,代码行数:23,代码来源:fdf8821871d7_main_tables.py

示例6: create_articles_to_tags_table

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def create_articles_to_tags_table() -> None:
    op.create_table(
        "articles_to_tags",
        sa.Column(
            "article_id",
            sa.Integer,
            sa.ForeignKey("articles.id", ondelete="CASCADE"),
            nullable=False,
        ),
        sa.Column(
            "tag",
            sa.Text,
            sa.ForeignKey("tags.tag", ondelete="CASCADE"),
            nullable=False,
        ),
    )
    op.create_primary_key(
        "pk_articles_to_tags", "articles_to_tags", ["article_id", "tag"]
    ) 
开发者ID:nsidnev,项目名称:fastapi-realworld-example-app,代码行数:21,代码来源:fdf8821871d7_main_tables.py

示例7: create_favorites_table

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def create_favorites_table() -> None:
    op.create_table(
        "favorites",
        sa.Column(
            "user_id",
            sa.Integer,
            sa.ForeignKey("users.id", ondelete="CASCADE"),
            nullable=False,
        ),
        sa.Column(
            "article_id",
            sa.Integer,
            sa.ForeignKey("articles.id", ondelete="CASCADE"),
            nullable=False,
        ),
    )
    op.create_primary_key("pk_favorites", "favorites", ["user_id", "article_id"]) 
开发者ID:nsidnev,项目名称:fastapi-realworld-example-app,代码行数:19,代码来源:fdf8821871d7_main_tables.py

示例8: batch_create_primary_key

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def batch_create_primary_key(cls, operations, constraint_name, columns):
        """Issue a "create primary key" instruction using the
        current batch migration context.

        The batch form of this call omits the ``table_name`` and ``schema``
        arguments from the call.

        .. seealso::

            :meth:`.Operations.create_primary_key`

        """
        op = cls(
            constraint_name,
            operations.impl.table_name,
            columns,
            schema=operations.impl.schema,
        )
        return operations.invoke(op) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:21,代码来源:ops.py

示例9: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():
    """Down migration."""
    # Drop all the new stuff
    op.drop_index(op.f('ix_change_removed_tags_tag_name'), table_name='change_removed_tags')
    op.drop_index(op.f('ix_change_removed_tags_change_id'), table_name='change_removed_tags')
    op.drop_table('change_removed_tags')
    op.drop_index(op.f('ix_change_added_tags_tag_name'), table_name='change_added_tags')
    op.drop_index(op.f('ix_change_added_tags_change_id'), table_name='change_added_tags')
    op.drop_table('change_added_tags')

    # Restore the old tag primary key constraint stuff
    op.drop_constraint('sticker_tag_tag_name_fkey', 'sticker_tag', type_='foreignkey')
    op.drop_column('sticker_tag', 'tag_is_default_language')
    op.drop_constraint('tag_pkey', 'tag')
    op.create_primary_key('tag_pkey', 'tag', ['name'])

    op.create_foreign_key(
        'sticker_tag_tag_name_fkey',
        'sticker_tag', 'tag',
        ['tag_name'], ['name'],
        onupdate='CASCADE', ondelete='CASCADE', deferrable=True
    )

    # ### end Alembic commands ### 
开发者ID:Nukesor,项目名称:sticker-finder,代码行数:26,代码来源:2019_04_13_69d10714ee45_rewrite_changes_and_tags.py

示例10: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():
	# Drop New Index
	op.drop_index('ix_user_email', 'user')

	# Rename email column
	op.alter_column('user', 'email', new_column_name='user_id')

	# Rename admin column
	op.alter_column('user', 'is_admin', new_column_name='admin')

	# Drop date columns
	op.drop_column('user', 'created_at')
	op.drop_column('user', 'updated_at')

	# Drop new ID Column
	op.drop_column('user', 'id')

	# Reinstate OLD PKey
	op.create_primary_key("user_pkey", "user", ["user_id", ]) 
开发者ID:Murali-group,项目名称:GraphSpace,代码行数:21,代码来源:77a2637f243c_update_user_table.py

示例11: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():

	# Remove new foreign key reference
	op.drop_constraint('group_owner_email_fkey', 'group', type_='foreignkey')

	# Drop New Index
	op.drop_index('_group_uc_name_owner_email', 'group')

	# Rename email column
	op.alter_column('group', 'owner_email', new_column_name='owner_id')

	# Drop date columns
	op.drop_column('group', 'created_at')
	op.drop_column('group', 'updated_at')

	# Drop new ID Column
	op.drop_column('group', 'id')

	# Reinstate OLD PKey
	op.create_primary_key("group_pkey", "group", ["group_id", "owner_id" ])

	pass 
开发者ID:Murali-group,项目名称:GraphSpace,代码行数:24,代码来源:bb85d8864dfa_update_group_table.py

示例12: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def upgrade():
    op.add_column('container_secret',
                  sa.Column('created_at', sa.DateTime(), nullable=False))
    op.add_column('container_secret',
                  sa.Column('deleted', sa.Boolean(), nullable=False))
    op.add_column('container_secret',
                  sa.Column('deleted_at', sa.DateTime(), nullable=True))
    op.add_column('container_secret',
                  sa.Column('id', sa.String(length=36), nullable=False))
    op.add_column('container_secret',
                  sa.Column('status', sa.String(length=20), nullable=False))
    op.add_column('container_secret',
                  sa.Column('updated_at', sa.DateTime(), nullable=False))

    op.create_primary_key('pk_container_secret', 'container_secret', ['id'])
    op.create_unique_constraint(
        '_container_secret_name_uc',
        'container_secret',
        ['container_id', 'secret_id', 'name']
    ) 
开发者ID:openstack,项目名称:barbican,代码行数:22,代码来源:2ab3f5371bde_dsa_in_container_type_modelbase_to.py

示例13: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():
    op.drop_constraint('fk_vuln', 'vulnerability_git_commits', type_='foreignkey')
    op.create_index('uk_ver_cve_id', 'vulnerability', ['version', 'cve_id'], unique=True)
    op.drop_constraint('uk_vcdb_id_version', 'vulnerability', type_='unique')
    op.drop_column('vulnerability', 'vcdb_id')
    op.drop_column('vulnerability', 'prev_version')
    op.alter_column('vulnerability', 'version',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=False)
    # Drop all foreign keys on vulnerability.id as we intend to update it.
    op.drop_constraint('vulnerability_git_commits_ibfk_1', 'vulnerability_git_commits', type_='foreignkey')
    ##############
    # Update the vulnerability primary key.
    # Remove autoincrement from the PK as there can only be one auto key and it has to be the PK.
    op.alter_column('vulnerability', 'id', existing_type=sa.Integer(), autoincrement=False, nullable=False)
    op.drop_constraint('id', 'vulnerability', type_='primary')
    # Now we can define a new primary key.
    op.create_primary_key('pk', 'vulnerability', ['id', 'version'])
    # Re-enable auto incrementing for the id column, too.
    op.alter_column('vulnerability', 'id', existing_type=sa.Integer(), autoincrement=True, nullable=False)
    # ----------------------------------------------------------------------------------------------------
    op.add_column('vulnerability_git_commits', sa.Column('version', sa.Integer(), nullable=False))
    op.create_foreign_key('fk_vuln', 'vulnerability_git_commits', 'vulnerability', ['vulnerability_details_id', 'version'], ['id', 'version'])
    # ### end Alembic commands ### 
开发者ID:google,项目名称:vulncode-db,代码行数:26,代码来源:13b73f6d1082_restructuring_vulnerability_pk_and_.py

示例14: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def downgrade():
    op.drop_constraint('fk_vuln', 'vulnerability_git_commits', type_='foreignkey')
    op.alter_column('vulnerability_git_commits', 'vulnerability_details_id',
                    existing_type=mysql.INTEGER(display_width=11),
                    nullable=True)
    op.drop_column('vulnerability_git_commits', 'version')

    op.drop_index(op.f('ix_vulnerability_cve_id'), table_name='vulnerability')
    op.drop_constraint('uk_ver_cve_id', 'vulnerability', type_='unique')
    op.create_index('cve_id', 'vulnerability', ['cve_id'], unique=True)
    # Remove autoincrement from the PK as there can only be one auto key and it has to be the PK.
    op.alter_column('vulnerability', 'id', existing_type=sa.Integer(), autoincrement=False, nullable=False)
    op.drop_constraint('pk', 'vulnerability', type_='primary')
    op.create_primary_key('id', 'vulnerability', ['id'])
    op.alter_column('vulnerability', 'id', existing_type=sa.Integer(), autoincrement=True, nullable=False)

    op.drop_column('vulnerability', 'version')
    op.drop_column('vulnerability', 'state')
    op.drop_constraint('fk_reviewer_id', 'vulnerability', type_='foreignkey')
    op.drop_column('vulnerability', 'reviewer_id')
    op.drop_column('vulnerability', 'review_feedback')

    op.add_column('vulnerability_resources', sa.Column('vulnerability_details_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_foreign_key('vulnerability_resources_ibfk_1', 'vulnerability_resources', 'vulnerability', ['vulnerability_details_id'], ['id'])
    op.create_foreign_key('vulnerability_git_commits_ibfk_1', 'vulnerability_git_commits', 'vulnerability', ['vulnerability_details_id'], ['id']) 
开发者ID:google,项目名称:vulncode-db,代码行数:27,代码来源:611733367157_adding_new_fields_and_keys_indices_to_.py

示例15: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import create_primary_key [as 别名]
def upgrade():
    op.add_column('listener_statistics',
                  sa.Column('amphora_id',
                            sa.String(36),
                            nullable=False)
                  )

    op.drop_constraint('fk_listener_statistics_listener_id',
                       'listener_statistics',
                       type_='foreignkey')
    op.drop_constraint('PRIMARY',
                       'listener_statistics',
                       type_='primary')

    op.create_primary_key('pk_listener_statistics', 'listener_statistics',
                          ['listener_id', 'amphora_id'])
    op.create_foreign_key('fk_listener_statistics_listener_id',
                          'listener_statistics',
                          'listener',
                          ['listener_id'],
                          ['id'])
    op.create_foreign_key('fk_listener_statistic_amphora_id',
                          'listener_statistics',
                          'amphora',
                          ['amphora_id'],
                          ['id']) 
开发者ID:openstack,项目名称:octavia,代码行数:28,代码来源:9bf4d21caaea_adding_amphora_id_to_listener_.py


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