python类batch_alter_table()的实例源码

aae44dcdaf52_add_edition_mode_column.py 文件源码 项目:ltd-keeper 作者: lsst-sqre 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('editions', schema=None) as batch_op:
        batch_op.add_column(sa.Column('mode', sa.Integer(), nullable=True))
aae44dcdaf52_add_edition_mode_column.py 文件源码 项目:ltd-keeper 作者: lsst-sqre 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('editions', schema=None) as batch_op:
        batch_op.drop_column('mode')
ffdd80058eed_add_surrogate_key_to_product.py 文件源码 项目:ltd-keeper 作者: lsst-sqre 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('products', schema=None) as batch_op:
        batch_op.add_column(sa.Column('surrogate_key',
                                      sa.String(length=32),
                                      nullable=True))
6af6b8665ff1_store_price_as_integer_cents.py 文件源码 项目:flask-react-redux-demo 作者: eddowh 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('restaurants_menuitem', schema=None) as batch_op:
        batch_op.alter_column('price',
               existing_type=sa.NUMERIC(precision=2, scale=0),
               type_=sa.Integer(),
               existing_nullable=False)

    ### end Alembic commands ###
6af6b8665ff1_store_price_as_integer_cents.py 文件源码 项目:flask-react-redux-demo 作者: eddowh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('restaurants_menuitem', schema=None) as batch_op:
        batch_op.alter_column('price',
               existing_type=sa.Integer(),
               type_=sa.NUMERIC(precision=2, scale=0),
               existing_nullable=False)

    ### end Alembic commands ###
2e541a1dcfed_task_duration.py 文件源码 项目:airflow 作者: apache-airflow 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def upgrade():
    # use batch_alter_table to support SQLite workaround
    with op.batch_alter_table("task_instance") as batch_op:
        batch_op.alter_column('duration',
                              existing_type=mysql.INTEGER(display_width=11),
                              type_=sa.Float(),
                              existing_nullable=True)
8b0b3bbd0cac_state_is_active_last_active_at_fields_.py 文件源码 项目:todoist_bot 作者: ihoru 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('user') as batch_op:
        batch_op.drop_column('state')
        batch_op.drop_column('last_active_at')
        batch_op.drop_column('is_active')
        # ### end Alembic commands ###
20160831125422_add_drug_name_active_ingredients_and_company_to_fda_dap.py 文件源码 项目:collectors 作者: opentrials 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('fda_dap') as batch_op:
        batch_op.add_column(sa.Column('drug_name', sa.Text))
        batch_op.add_column(sa.Column('active_ingredients', sa.Text))
        batch_op.add_column(sa.Column('company', sa.Text))
20160831125422_add_drug_name_active_ingredients_and_company_to_fda_dap.py 文件源码 项目:collectors 作者: opentrials 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('fda_dap') as batch_op:
        batch_op.drop_column('drug_name')
        batch_op.drop_column('active_ingredients')
        batch_op.drop_column('company')
278b30622af6_add_status_to_upgrade_tasks.py 文件源码 项目:kostyor 作者: Mirantis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('upgrade_tasks') as batch_op:
        batch_op.add_column(
            sa.Column('status', sa.Enum(*constants.UPGRADE_STATUSES)))
278b30622af6_add_status_to_upgrade_tasks.py 文件源码 项目:kostyor 作者: Mirantis 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('upgrade_tasks') as batch_op:
        batch_op.drop_column('status')
232c38fec944_service_host_many_to_many.py 文件源码 项目:kostyor 作者: Mirantis 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def upgrade():
    op.create_table(
        'hosts_services',
        sa.Column('host_id', sa.String(36), sa.ForeignKey('hosts.id')),
        sa.Column('service_id', sa.String(36), sa.ForeignKey('services.id')),
        sa.UniqueConstraint('host_id', 'service_id'))

    with op.batch_alter_table('services') as batch_op:
        batch_op.drop_constraint('fk_services_host_id_hosts')
        batch_op.drop_column('host_id')
27ae2f102682_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def upgrade():
    connection = op.get_bind()
    # spam_threshold is a X/15 based value, we're converting it to percent.
    for user in connection.execute(user_table.select()):
         connection.execute(
            user_table.update().where(
                user_table.c.email == user.email
            ).values(
                spam_threshold=int(100. * float(user.spam_threshold or 0.) / 15.)
            )
         )
    # set default to 80%
    with op.batch_alter_table('user') as batch:
        batch.alter_column('spam_threshold', default=80.)
27ae2f102682_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def downgrade():
    connection = op.get_bind()
    # spam_threshold is a X/15 based value, we're converting it from percent.
    for user in connection.execute(user_table.select()):
         connection.execute(
            user_table.update().where(
                user_table.c.email == user.email
            ).values(
                spam_threshold=int(15. * float(user.spam_threshold or 0.) / 100.)
            )
         )
    # set default to 10/15
    with op.batch_alter_table('user') as batch:
        batch.alter_column('spam_threshold', default=10.)
2335c80a6bc3_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('domain') as batch:
        batch.drop_column('max_quota_bytes')
73e56bad5ec5_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('user') as batch:
        batch.add_column(sa.Column('forward_keep', sa.Boolean(), nullable=False, server_default=sa.sql.expression.true()))
73e56bad5ec5_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('user') as batch:
        batch.drop_column('forward_keep')
9c28df23f77e_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def upgrade():
    with op.batch_alter_table('user') as batch:
        batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
    with op.batch_alter_table('alias') as batch:
        batch.alter_column('email', type_=sa.String(length=255, collation="NOCASE"))
9c28df23f77e_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('user') as batch:
        batch.alter_column('email', type_=sa.String(length=255))
    with op.batch_alter_table('alias') as batch:
        batch.alter_column('email', type_=sa.String(length=255))
3f6994568962_.py 文件源码 项目:Mailu 作者: Mailu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def downgrade():
    with op.batch_alter_table('fetch') as batch:
        batch.drop_column('keep')


问题


面经


文章

微信
公众号

扫码关注公众号