Python alembic.op 模块,alter_column() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用alembic.op.alter_column()

项目:kuberdock-platform    作者:cloudlinux    | 项目源码 | 文件源码
def upgrade():
    op.execute(sa.schema.CreateSequence(sa.Sequence('pod_states_id_seq')))
    op.add_column('pod_states', sa.Column('id', sa.Integer(), nullable=False,
                  server_default=sa.text("nextval('pod_states_id_seq'::regclass)")))
    op.execute("ALTER TABLE pod_states DROP CONSTRAINT pod_states_pkey, "
               "ADD CONSTRAINT pod_states_pkey PRIMARY KEY (id);")

    op.add_column('container_states', sa.Column('exit_code', sa.Integer(), nullable=True))
    op.add_column('container_states', sa.Column('pod_state_id', sa.Integer(), nullable=True))
    op.add_column('container_states', sa.Column('reason', sa.Text(), nullable=True))
    op.create_index('ix_pod_id_start_time', 'pod_states', ['pod_id', 'start_time'], unique=True)
    op.create_foreign_key('container_states_pod_state_id_fkey', 'container_states',
                          'pod_states', ['pod_state_id'], ['id'])

    upgrade_data()

    op.alter_column('container_states', 'pod_state_id',
                    existing_type=sa.INTEGER(), nullable=False)
    op.drop_constraint(u'container_states_pod_id_fkey', 'container_states',
                       type_='foreignkey')
    op.drop_column('container_states', 'pod_id')
项目:kuberdock-platform    作者:cloudlinux    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('kubes', 'name', existing_type=sa.VARCHAR(length=64),
                    nullable=False)
    op.create_index('one_default', 'kubes', ['is_default'], unique=True,
                    postgresql_where=sa.text(u'kubes.is_default IS true'))
    op.drop_constraint(u'kubes_is_default_key', 'kubes', type_='unique')
    op.alter_column('packages', 'name', existing_type=sa.VARCHAR(length=64),
                    nullable=False)
    op.alter_column('packages', 'prefix', existing_type=sa.VARCHAR(),
                    nullable=False)
    op.alter_column('packages', 'suffix', existing_type=sa.VARCHAR(),
                    nullable=False)

    session = Session(bind=op.get_bind())
    session.query(PackageKube).filter(sa.or_(
        PackageKube.package_id.is_(None), PackageKube.kube_id.is_(None),
    )).delete()
    session.commit()

    op.alter_column('package_kube', 'kube_id', existing_type=sa.INTEGER(),
                    nullable=False)
    op.alter_column('package_kube', 'package_id', existing_type=sa.INTEGER(),
                    nullable=False)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('body_html', sa.Text(), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('disabled', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_comments_timestamp'), 'comments', ['timestamp'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ###
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('machine_statistic',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=64), nullable=True),
    sa.Column('timestamp', sa.String(length=64), nullable=True),
    sa.Column('userid', sa.String(length=64), nullable=True),
    sa.Column('netcode', sa.String(length=64), nullable=True),
    sa.Column('login_time', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('id')
    )
    op.create_index(op.f('ix_machine_statistic_login_time'), 'machine_statistic', ['login_time'], unique=False)
    op.alter_column(u'statistic_visitor', 'referred',
               existing_type=mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128),
               nullable=True,
               existing_server_default=sa.text(u"''"))
    ### end Alembic commands ###
项目:FlaskBackend    作者:iamrajhans    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(u'users', 'user_id',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column(u'users', 'updated_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=True)
    op.alter_column(u'users', 'name',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column(u'users', 'last_name',
               existing_type=sa.VARCHAR(length=200),
               nullable=True)
    op.alter_column(u'users', 'email',
               existing_type=sa.VARCHAR(length=150),
               nullable=True)
    op.alter_column(u'users', 'created_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=True)
    op.drop_table('request_referral')
    ### end Alembic commands ###
项目:vk-channelify    作者:reo7sp    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('channels', 'owner_id',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('disabled_channels', 'channel_id',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('disabled_channels', 'last_vk_post_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.alter_column('disabled_channels', 'owner_id',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('disabled_channels', 'vk_group_id',
               existing_type=sa.VARCHAR(),
               nullable=False)
    # ### end Alembic commands ###
项目:vk-channelify    作者:reo7sp    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('disabled_channels', 'vk_group_id',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('disabled_channels', 'owner_id',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('disabled_channels', 'last_vk_post_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.alter_column('disabled_channels', 'channel_id',
               existing_type=sa.VARCHAR(),
               nullable=True)
    op.alter_column('channels', 'owner_id',
               existing_type=sa.VARCHAR(),
               nullable=True)
    # ### end Alembic commands ###
项目:neutron-dynamic-routing    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    """Code reused from

    Change-Id: I87a8ef342ccea004731ba0192b23a8e79bc382dc
    """

    inspector = get_inspector()

    data = get_data()
    for table, column in data:
        alter_column(table, column)

        indexes = inspector.get_indexes(table)
        for index in indexes:
            if 'tenant_id' in index['name']:
                recreate_index(index, table)
项目:biweeklybudget    作者:jantman    | 项目源码 | 文件源码
def upgrade():
    # When making changes to a column that has a foreign key, we need to drop
    # and then re-add the constraint
    op.execute('DELETE FROM txn_reconciles WHERE txn_id IS NULL;')
    op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;')
    op.drop_constraint('fk_txn_reconciles_txn_id_transactions',
                       'txn_reconciles', type_='foreignkey')
    op.alter_column(
        'txn_reconciles',
        'txn_id',
        existing_type=mysql.INTEGER(display_width=11),
        nullable=False
    )
    op.create_foreign_key('fk_txn_reconciles_txn_id_transactions',
                          'txn_reconciles', 'transactions', ['txn_id'], ['id'])
    op.execute('UNLOCK TABLES;')
项目:mini    作者:JJWSSS    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('comments', sa.Column('goodsID', sa.Integer(), nullable=True))
    op.alter_column('comments', 'commentatorID',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=True)
    op.drop_constraint('comments_ibfk_2', 'comments', type_='foreignkey')
    op.create_foreign_key(None, 'comments', 'goods', ['goodsID'], ['goodID'])
    op.drop_column('comments', 'goodID')
    op.add_column('goods', sa.Column('address', sa.String(length=128), nullable=False))
    op.add_column('goods', sa.Column('poster', sa.String(length=128), nullable=False))
    op.add_column('goods', sa.Column('times', sa.Integer(), nullable=True))
    op.alter_column('orders', 'createDate',
               existing_type=mysql.DATETIME(),
               nullable=False)
    ### end Alembic commands ###
项目:mini    作者:JJWSSS    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('orders', 'createDate',
               existing_type=mysql.DATETIME(),
               nullable=True)
    op.drop_column('goods', 'times')
    op.drop_column('goods', 'poster')
    op.drop_column('goods', 'address')
    op.add_column('comments', sa.Column('goodID', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False))
    op.drop_constraint(None, 'comments', type_='foreignkey')
    op.create_foreign_key('comments_ibfk_2', 'comments', 'goods', ['goodID'], ['goodID'])
    op.alter_column('comments', 'commentatorID',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=False)
    op.drop_column('comments', 'goodsID')
    ### end Alembic commands ###
项目:reahl    作者:reahl    | 项目源码 | 文件源码
def change_task(self):
        # Task in elixir did not generate a row_type for use as discriminator
        self.schedule('alter', op.add_column, 'task', Column('row_type', String(40)))

        # Task in elixir's queue_id was NULLABLE, but should not be (Tasks HAVE to be in a Queue now)
        self.schedule('alter', op.alter_column, 'task', 'queue_id', nullable=True)

        # Rename of relationship foreign key Task.reserved_by_id -> reserved_by_party_id
        old_name = 'reserved_by_id'
        new_name = 'reserved_by_party_id'
        self.schedule('drop_fk', op.drop_constraint, '%s_%s_fk' % ('task', old_name), 'task')
        self.schedule('alter', op.alter_column, 'task', old_name, new_column_name=new_name)
        self.schedule('create_fk', op.create_foreign_key, fk_name('task', new_name, 'party'), 'task', 'party', [new_name], ['id'])

        self.schedule('drop_pk', op.drop_index, ix_name('task', 'reserved_by_id'))
        self.schedule('indexes', op.create_index, ix_name('task','reserved_by_party_id'), 'task', ['reserved_by_party_id'])
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('dataset', 'collection_date',
               existing_type=mysql.DATETIME(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=mysql.FLOAT(),
               type_=sa.Text(),
               existing_nullable=True)
    op.alter_column('user', 'admin',
               existing_type=mysql.TINYINT(display_width=1),
               type_=sa.Boolean(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:metaseek    作者:ahoarfrost    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'admin',
               existing_type=sa.Boolean(),
               type_=mysql.TINYINT(display_width=1),
               existing_nullable=True)
    op.alter_column('dataset', 'longitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'latitude',
               existing_type=sa.Text(),
               type_=mysql.FLOAT(),
               existing_nullable=True)
    op.alter_column('dataset', 'collection_date',
               existing_type=sa.Text(),
               type_=mysql.DATETIME(),
               existing_nullable=True)
    # ### end Alembic commands ###
项目:hotface    作者:linhanqiuinc24    | 项目源码 | 文件源码
def downgrade():
    connection = op.get_bind()

    if connection.engine.dialect.name != "sqlite":
        # user/models.py
        op.alter_column('users', 'date_joined', type_=sa.DateTime(), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('users', 'lastseen', type_=sa.DateTime(), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('users', 'birthday', type_=sa.DateTime(), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('users', 'last_failed_login', type_=sa.DateTime(), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)

        # message/models.py
        op.alter_column('conversations', 'date_created', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('messages', 'date_created', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)

        # forum/models.py
        op.alter_column('topicsread', 'last_read', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('forumsread', 'last_read', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('forumsread', 'cleared', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('reports', 'reported', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('reports', 'zapped', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('posts', 'date_created', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('posts', 'date_modified', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('topics', 'date_created', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('topics', 'last_updated', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
        op.alter_column('forums', 'last_post_created', type_=sa.DateTime(timezone=False), existing_type=flaskbb.utils.database.UTCDateTime(timezone=True), existing_nullable=True)
项目:dila    作者:socialwifi    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute("UPDATE translated_string SET base_string='' WHERE base_string is NULL")
    op.alter_column('translated_string', 'base_string',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET comment='' WHERE comment is NULL")
    op.alter_column('translated_string', 'comment',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET context='' WHERE context is NULL")
    op.alter_column('translated_string', 'context',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET translation='' WHERE translation is NULL")
    op.alter_column('translated_string', 'translation',
               existing_type=sa.TEXT(),
               nullable=False)
    op.execute("UPDATE translated_string SET translator_comment='' WHERE translator_comment is NULL")
    op.alter_column('translated_string', 'translator_comment',
               existing_type=sa.TEXT(),
               nullable=False)
    # ### end Alembic commands ###
项目:dila    作者:socialwifi    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('translated_string', 'translator_comment',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'translation',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'context',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'comment',
               existing_type=sa.TEXT(),
               nullable=True)
    op.alter_column('translated_string', 'base_string',
               existing_type=sa.TEXT(),
               nullable=True)
    # ### end Alembic commands ###
项目:fuel-nailgun-extension-iac    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.create_unique_constraint('_repo_name_unique',
                                table_prefix + 'repos',
                                ['repo_name'])

    op.alter_column(table_prefix + 'repos',
                    'user_key',
                    type_=sa.UnicodeText(),
                    existing_type=sa.String(255))
项目:fuel-nailgun-extension-iac    作者:openstack    | 项目源码 | 文件源码
def downgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.drop_constraint('_repo_name_unique',
                       table_prefix + 'repos')

    op.alter_column(table_prefix + 'repos',
                    'user_key',
                    existing_type=sa.UnicodeText(),
                    type_=sa.String(255))
项目:BookCloud    作者:livro-aberto    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'email',
               existing_type=mysql.VARCHAR(length=255),
               type_=sa.String(length=75),
               existing_nullable=False)
    # ### end Alembic commands ###
项目:BookCloud    作者:livro-aberto    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'email',
               existing_type=sa.String(length=75),
               type_=mysql.VARCHAR(length=255),
               existing_nullable=False)
    # ### end Alembic commands ###
项目:gloss    作者:openhealthcare    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        'inpatientadmission',
        'visit_number',
        new_column_name='external_identifier'
    )
    ### end Alembic commands ###
项目:gloss    作者:openhealthcare    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        'inpatientadmission',
        'external_identifier',
        new_column_name='visit_number'
    )
    ### end Alembic commands ###
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    # First, create column and fill all records with default value.
    # To avoid integrity error, the constraint non-nullable will be set after that
    op.add_column('app', sa.Column('featured', sa.Boolean, default=False))
    query = 'UPDATE "app" SET featured=false;'
    op.execute(query)
    op.alter_column('app', 'featured', nullable=False)
    query = 'UPDATE "app" SET featured=true WHERE app.id IN (SELECT app_id FROM FEATURED);'
    op.execute(query)
    op.drop_table('featured')
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def downgrade():
    op.add_column('project', sa.Column('completed', sa.Boolean, default=False))
    query = 'UPDATE project SET completed=false;'
    op.execute(query)
    op.alter_column('project', 'completed', nullable=False)

    update_completed = '''
        WITH completed_tasks AS (
        SELECT project.id, COUNT(task.id) as n_completed_tasks FROM project, task
        WHERE task.state='completed' AND task.project_id=project.id
        GROUP BY project.id
        ), total_tasks AS (
        SELECT project.id, COUNT(task.id) as n_tasks FROM project, task
        WHERE task.project_id=project.id
        GROUP BY project.id
        )
        UPDATE project SET completed=true WHERE project.id IN (
            SELECT total_tasks.id
            FROM completed_tasks INNER JOIN total_tasks ON completed_tasks.id=total_tasks.id
        );
    '''

    op.execute(update_completed)
    # sql = sa.sql.text('''SELECT COUNT(task.id) AS n_completed_tasks FROM task
    #             WHERE task.project_id=:project_id AND task.state=\'completed\';''')
    # sql = sa.sql.text('''SELECT COUNT(task.id) AS n_tasks FROM task
    #               WHERE task.project_id=:project_id''')
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    # App table
    op.alter_column('app', 'name', nullable=False)
    op.alter_column('app', 'short_name', nullable=False)
    op.alter_column('app', 'description', nullable=False)
    op.alter_column('app', 'owner_id', nullable=False)
    # Task
    op.alter_column('task', 'app_id', nullable=False)

    # TaskRun
    op.alter_column('task_run', 'app_id', nullable=False)
    op.alter_column('task_run', 'task_id', nullable=False)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def downgrade():
    op.alter_column('app', 'name', nullable=True)
    op.alter_column('app', 'short_name', nullable=True)
    op.alter_column('app', 'description', nullable=True)
    op.alter_column('app', 'owner_id', nullable=True)
    # Task
    op.alter_column('task', 'app_id', nullable=True)

    # TaskRun
    op.alter_column('task_run', 'app_id', nullable=True)
    op.alter_column('task_run', 'task_id', nullable=True)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    query = 'UPDATE "user" SET locale=\'en\';'
    op.execute(query)
    op.alter_column('user', 'locale', nullable=False)
    op.alter_column('user', 'privacy_mode', nullable=False)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('user', 'facebook_user_id', type_=sa.BigInteger)
    op.alter_column('user', 'twitter_user_id', type_=sa.BigInteger)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def downgrade():
    op.alter_column('user', 'facebook_user_id', type_=sa.Integer)
    op.alter_column('user', 'twitter_user_id', type_=sa.Integer)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('app', 'long_description', type_=sa.UnicodeText)
    pass
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def downgrade():
    op.alter_column('app', 'long_description', type_=sa.Unicode)
    pass
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    query = 'UPDATE app SET category_id=(SELECT id FROM category ORDER BY id asc limit 1) WHERE app.category_id is NULL;'
    op.execute(query)
    op.alter_column('app', 'category_id', nullable=False)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def upgrade():
    op.add_column('project', sa.Column('published', sa.Boolean, default=False))
    query = 'UPDATE "project" SET published=false;'
    op.execute(query)
    op.alter_column('project', 'published', nullable=False)
    query = """UPDATE "project" SET published=true
               WHERE project.id IN
               (SELECT project.id FROM project, task WHERE
               project.id=task.project_id AND
               (project.info->>'task_presenter') IS NOT NULL AND
               (project.info->>'task_presenter')!=''
               GROUP BY project.id);"""
    op.execute(query)
项目:sitrep    作者:bittorrent    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('component_update', 'time', existing_type=sa.Integer(), type_=sa.Float(precision=53))
    op.alter_column('component_update', 'lifetime', existing_type=sa.Integer(), type_=sa.Float(precision=53))
项目:sitrep    作者:bittorrent    | 项目源码 | 文件源码
def downgrade():
    op.alter_column('component_update', 'time', existing_type=sa.Float(precision=53), type_=sa.Integer())
    op.alter_column('component_update', 'lifetime', existing_type=sa.Float(precision=53), type_=sa.Integer())
项目:panko    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('trait_int', "value", type_=sa.BigInteger)
项目:triage    作者:dssg    | 项目源码 | 文件源码
def upgrade():
    op.alter_column('evaluations', 'example_frequency', new_column_name='as_of_date_frequency')
    op.alter_column('models', 'train_label_window', new_column_name='training_label_timespan')
    op.alter_column('predictions', 'test_label_window', new_column_name='test_label_timespan')
    op.alter_column('list_predictions', 'test_label_window', new_column_name='test_label_timespan')
项目:triage    作者:dssg    | 项目源码 | 文件源码
def downgrade():
    op.alter_column('evaluations', 'as_of_date_frequency', new_column_name='example_frequency')
    op.alter_column('models', 'training_label_timespan', new_column_name='train_label_window')
    op.alter_column('predictions', 'test_label_timespan', new_column_name='test_label_window')
    op.alter_column('list_predictions', 'test_label_timespan', new_column_name='test_label_window')
项目:triage    作者:dssg    | 项目源码 | 文件源码
def upgrade():
    op.alter_column(
        table_name='individual_importances',
        column_name='importance_score',
        type_=sa.Float(),
        schema='results',
        postgresql_using='importance_score::double precision'
    )
项目:triage    作者:dssg    | 项目源码 | 文件源码
def downgrade():
    op.alter_column(
        table_name='individual_importances',
        column_name='importance_score',
        type_=sa.Text(),
        schema='results'
    )
项目:occrp-timeline-tool    作者:datamade    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('event', 'description',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.create_unique_constraint(None, 'event', ['description'])
    # ### end Alembic commands ###
项目:occrp-timeline-tool    作者:datamade    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'event', type_='unique')
    op.alter_column('event', 'description',
               existing_type=sa.VARCHAR(),
               nullable=True)
    # ### end Alembic commands ###
项目:occrp-timeline-tool    作者:datamade    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('person', 'email',
               existing_type=sa.VARCHAR(),
               nullable=True)
    # ### end Alembic commands ###
项目:occrp-timeline-tool    作者:datamade    | 项目源码 | 文件源码
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('person', 'email',
               existing_type=sa.VARCHAR(),
               nullable=False)
    # ### end Alembic commands ###
项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('episode', 'title',
               existing_type=sa.VARCHAR(),
               nullable=True)
    ### end Alembic commands ###
项目:podigger    作者:perna    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('episode', 'title',
               existing_type=sa.VARCHAR(),
               nullable=False)
    ### end Alembic commands ###
项目:podigger    作者:perna    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('episode', 'title',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.create_index(op.f('ix_episode_link'), 'episode', ['link'], unique=True)
    op.drop_constraint('episode_link_key', 'episode', type_='unique')
    ### end Alembic commands ###
项目:podigger    作者:perna    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('episode_link_key', 'episode', ['link'])
    op.drop_index(op.f('ix_episode_link'), table_name='episode')
    op.alter_column('episode', 'title',
               existing_type=sa.VARCHAR(),
               nullable=True)
    ### end Alembic commands ###
项目:wank.party    作者:Streetwalrus    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('upload', 'hash',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('upload', 'path',
               existing_type=sa.VARCHAR(),
               nullable=False)
    op.alter_column('upload', 'shorthash',
               existing_type=sa.VARCHAR(),
               nullable=False)
    ### end Alembic commands ###