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


Python op.alter_column方法代码示例

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


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

示例1: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    op.add_column('compute_node',
                  sa.Column('rp_uuid', sa.String(length=36), nullable=True))
    op.create_unique_constraint('uniq_compute_node0rp_uuid',
                                'compute_node', ['rp_uuid'])

    # perform data migration between tables
    session = sa.orm.Session(bind=op.get_bind())
    with session.begin(subtransactions=True):
        for row in session.query(COMPUTE_NODE_TABLE):
            session.execute(
                COMPUTE_NODE_TABLE.update().values(
                    rp_uuid=row.uuid).where(
                        COMPUTE_NODE_TABLE.c.uuid == row.uuid)
            )
    # this commit is necessary to allow further operations
    session.commit()

    op.alter_column('compute_node', 'rp_uuid',
                    nullable=False,
                    existing_type=sa.String(length=36),
                    existing_nullable=True,
                    existing_server_default=False) 
开发者ID:openstack,项目名称:zun,代码行数:25,代码来源:d502ce8fb705_add_rp_uuid_to_compute_node.py

示例2: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('apple_subscription',
    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('user_id', sa.Integer(), nullable=False),
    sa.Column('expires_date', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
    sa.Column('original_transaction_id', sa.String(length=256), nullable=False),
    sa.Column('receipt_data', sa.Text(), nullable=False),
    sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum_apple'), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('user_id')
    )
    op.alter_column('file', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    # ### end Alembic commands ### 
开发者ID:simple-login,项目名称:app,代码行数:21,代码来源:2020_041911_dd911f880b75_.py

示例3: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('domains',
                  sa.Column('allowed_docker_registries',
                            postgresql.ARRAY(sa.String()), nullable=True))
    # ### end Alembic commands ###

    print('\nSet default allowed_docker_registries.')
    allowed_registries = os.environ.get('ALLOWED_DOCKER_REGISTRIES', None)
    if allowed_registries:
        allowed_registries = allowed_registries.replace(' ', '')
        allowed_registries = '{index.docker.io,' + allowed_registries + '}'
    else:
        allowed_registries = '{index.docker.io}'
    connection = op.get_bind()
    query = ("UPDATE domains SET allowed_docker_registries = '{}';".format(allowed_registries))
    connection.execute(query)

    op.alter_column('domains', column_name='allowed_docker_registries',
                    nullable=False) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:22,代码来源:22e52d03fc61_add_allowed_docker_registries_in_domains.py

示例4: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [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

示例5: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [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

示例6: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    userstatus.create(op.get_bind())
    op.add_column(
        'users',
        sa.Column('status', sa.Enum(*userstatus_choices, name='userstatus'), nullable=True)
    )
    op.add_column('users', sa.Column('status_info', sa.Unicode(), nullable=True))

    # Set user's status field.
    conn = op.get_bind()
    query = textwrap.dedent(
        "UPDATE users SET status = 'active', status_info = 'migrated' WHERE is_active = 't';"
    )
    conn.execute(query)
    query = textwrap.dedent(
        "UPDATE users SET status = 'inactive', status_info = 'migrated' WHERE is_active <> 't';"
    )
    conn.execute(query)

    op.alter_column('users', column_name='status', nullable=False)
    op.drop_column('users', 'is_active') 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:23,代码来源:0d553d59f369_users_replace_is_active_to_status_and_its_info.py

示例7: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    agentstatus.create(op.get_bind())
    kernelstatus.create(op.get_bind())
    op.add_column('agents', sa.Column('lost_at', sa.DateTime(timezone=True), nullable=True))
    op.add_column('agents', sa.Column('status', sa.Enum('ALIVE', 'LOST', 'RESTARTING', 'TERMINATED', name='agentstatus'), nullable=False))
    op.create_index(op.f('ix_agents_status'), 'agents', ['status'], unique=False)
    op.add_column('kernels', sa.Column('agent_addr', sa.String(length=128), nullable=False))
    op.add_column('kernels', sa.Column('cpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('gpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('mem_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_in_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_out_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdin_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdout_port', sa.Integer(), nullable=False))
    op.drop_column('kernels', 'allocated_cores')
    op.add_column('kernels', sa.Column('cpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.add_column('kernels', sa.Column('gpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.alter_column('kernels', column_name='status', type_=sa.Enum(*kernelstatus_choices, name='kernelstatus'),
                    postgresql_using='status::kernelstatus') 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:21,代码来源:0f3bc98edaa0_more_status.py

示例8: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def downgrade():
    op.drop_column('kernels', 'stdout_port')
    op.drop_column('kernels', 'stdin_port')
    op.drop_column('kernels', 'repl_out_port')
    op.drop_column('kernels', 'repl_in_port')
    op.drop_column('kernels', 'mem_slot')
    op.drop_column('kernels', 'gpu_slot')
    op.drop_column('kernels', 'cpu_slot')
    op.drop_column('kernels', 'agent_addr')
    op.drop_index(op.f('ix_agents_status'), table_name='agents')
    op.drop_column('agents', 'status')
    op.drop_column('agents', 'lost_at')
    op.alter_column('kernels', column_name='status', type_=sa.String(length=64))
    op.add_column('kernels', sa.Column('allocated_cores', sa.ARRAY(sa.Integer), nullable=True))
    op.drop_column('kernels', 'cpu_set')
    op.drop_column('kernels', 'gpu_set')
    agentstatus.drop(op.get_bind())
    kernelstatus.drop(op.get_bind()) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:20,代码来源:0f3bc98edaa0_more_status.py

示例9: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('domains', sa.Column('integration_id', sa.String(length=512), nullable=True))
    op.alter_column('domains', 'total_resource_slots',
                    existing_type=postgresql.JSONB(astext_type=sa.Text()),
                    nullable=True)
    op.add_column('groups', sa.Column('integration_id', sa.String(length=512), nullable=True))
    op.add_column('groups', sa.Column('total_resource_slots',
                                      postgresql.JSONB(astext_type=sa.Text()), nullable=True))
    op.add_column('users', sa.Column('integration_id', sa.String(length=512), nullable=True))
    # ### end Alembic commandk ###

    print('\nSet group\'s total_resource_slots with empty dictionary.')
    query = textwrap.dedent('''\
        UPDATE groups SET total_resource_slots = '{}'::jsonb;
    ''')
    connection = op.get_bind()
    connection.execute(query) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:20,代码来源:22964745c12b_add_total_resource_slots_to_group.py

示例10: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('domains', sa.Column('allowed_vfolder_hosts',
                                       postgresql.ARRAY(sa.String()), nullable=True))
    op.add_column('groups', sa.Column('allowed_vfolder_hosts',
                                      postgresql.ARRAY(sa.String()), nullable=True))
    # ### end Alembic commands ###

    print('\nSet domain and group\'s allowed_vfolder_hosts with empty array.')
    connection = op.get_bind()
    query = ("UPDATE domains SET allowed_vfolder_hosts = '{}';")
    connection.execute(query)
    query = ("UPDATE groups SET allowed_vfolder_hosts = '{}';")
    connection.execute(query)

    op.alter_column('domains', column_name='allowed_vfolder_hosts', nullable=False)
    op.alter_column('groups', column_name='allowed_vfolder_hosts', nullable=False) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:19,代码来源:c401d78cc7b9_add_allowed_vfolder_hosts_to_domain_and_.py

示例11: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('unavailable_room_report',
                    sa.Column('record_id', sa.Integer(), nullable=False),
                    sa.Column('room_id', sa.String(), nullable=True),
                    sa.Column('date', sa.Date(), nullable=True),
                    sa.Column('time', sa.String(length=4), nullable=True),
                    sa.Column('reporter', sa.String(length=15), nullable=True),
                    sa.Column('reporter_type', sa.String(), nullable=True),
                    sa.PrimaryKeyConstraint('record_id'),
                    sa.UniqueConstraint('room_id', 'date', 'time', 'reporter', 'reporter_type', name='unavailable_room_report_uniq')
                    )
    op.drop_index('idx_token', table_name='calendar_tokens')
    op.alter_column('identity_verify_requests', 'create_time',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    nullable=True)
    op.create_index(op.f('ix_simple_passwords_time'), 'simple_passwords', ['time'], unique=False)
    op.drop_index('idx_host_time', table_name='visit_tracks')
    op.create_index('idx_host_time', 'visit_tracks', ['host_id', 'last_visit_time'], unique=False)
    # ### end Alembic commands ### 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:22,代码来源:5e04dbf30fb0_first_commit_for_prod.py

示例12: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('idx_host_time', table_name='visit_tracks')
    op.create_index('idx_host_time', 'visit_tracks', ['host_id', 'last_visit_time'], unique=True)
    op.drop_index(op.f('ix_simple_passwords_time'), table_name='simple_passwords')
    op.alter_column('identity_verify_requests', 'create_time',
                    existing_type=postgresql.TIMESTAMP(timezone=True),
                    nullable=False)
    op.create_index('idx_token', 'calendar_tokens', ['token'], unique=True)
    op.drop_table('unavailable_room_report')
    # ### end Alembic commands ### 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:13,代码来源:5e04dbf30fb0_first_commit_for_prod.py

示例13: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('beat', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('division', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('office_weapon_used', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('officer_force_type', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('officer_race', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('precinct', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_hospitalized', sa.Boolean(), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_injured', sa.Boolean(), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_race', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_resist_type', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('resident_weapon_used', sa.String(length=255), nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('shift', sa.String(length=255), nullable=True))
    op.alter_column('use_of_force_incidents', 'department_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.drop_column('use_of_force_incidents', 'month')
    op.drop_column('use_of_force_incidents', 'hour')
    op.drop_column('use_of_force_incidents', 'year')
    op.drop_column('use_of_force_incidents', 'citizen_hospitalized')
    op.drop_column('use_of_force_incidents', 'citizen_weapon')
    op.drop_column('use_of_force_incidents', 'citizen_injured')
    op.drop_column('use_of_force_incidents', 'received_date')
    op.drop_column('use_of_force_incidents', 'day_of_week')
    op.drop_column('use_of_force_incidents', 'status')
    ### end Alembic commands ### 
开发者ID:codeforamerica,项目名称:comport,代码行数:29,代码来源:21dd34bbb19_.py

示例14: downgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('use_of_force_incidents', sa.Column('status', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('day_of_week', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('received_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_injured', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_weapon', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('citizen_hospitalized', sa.BOOLEAN(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('hour', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('use_of_force_incidents', sa.Column('month', sa.INTEGER(), autoincrement=False, nullable=True))
    op.alter_column('use_of_force_incidents', 'department_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_column('use_of_force_incidents', 'shift')
    op.drop_column('use_of_force_incidents', 'resident_weapon_used')
    op.drop_column('use_of_force_incidents', 'resident_resist_type')
    op.drop_column('use_of_force_incidents', 'resident_race')
    op.drop_column('use_of_force_incidents', 'resident_injured')
    op.drop_column('use_of_force_incidents', 'resident_hospitalized')
    op.drop_column('use_of_force_incidents', 'precinct')
    op.drop_column('use_of_force_incidents', 'officer_race')
    op.drop_column('use_of_force_incidents', 'officer_force_type')
    op.drop_column('use_of_force_incidents', 'office_weapon_used')
    op.drop_column('use_of_force_incidents', 'division')
    op.drop_column('use_of_force_incidents', 'beat')
    ### end Alembic commands ### 
开发者ID:codeforamerica,项目名称:comport,代码行数:29,代码来源:21dd34bbb19_.py

示例15: upgrade

# 需要导入模块: from alembic import op [as 别名]
# 或者: from alembic.op import alter_column [as 别名]
def upgrade():
    bind = op.get_bind()
    session = Session(bind=bind)

    department_query = text("SELECT * FROM departments")
    for department in session.execute(department_query):
        short_name = "".join([x[0] for x in department.name.split(" ")])
        department.short_name = short_name
    session.commit()

    op.alter_column('departments', 'short_name', existing_type=sa.VARCHAR(length=80), nullable=False) 
开发者ID:codeforamerica,项目名称:comport,代码行数:13,代码来源:51524883509_.py


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