本文整理匯總了Python中alembic.op.add_column方法的典型用法代碼示例。如果您正苦於以下問題:Python op.add_column方法的具體用法?Python op.add_column怎麽用?Python op.add_column使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類alembic.op
的用法示例。
在下文中一共展示了op.add_column方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
for table_name in ("resource", "resource_history", "metric"):
creator_col = sa.Column("creator", sa.String(255))
created_by_user_id_col = sa.Column("created_by_user_id",
sa.String(255))
created_by_project_id_col = sa.Column("created_by_project_id",
sa.String(255))
op.add_column(table_name, creator_col)
t = sa.sql.table(
table_name, creator_col,
created_by_user_id_col, created_by_project_id_col)
op.execute(
t.update().values(
creator=(
created_by_user_id_col + ":" + created_by_project_id_col
)).where((created_by_user_id_col is not None)
| (created_by_project_id_col is not None)))
op.drop_column(table_name, "created_by_user_id")
op.drop_column(table_name, "created_by_project_id")
示例2: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
op.add_column("resource_type", sa.Column('tablename', sa.String(18),
nullable=True))
resource_type = sa.Table(
'resource_type', sa.MetaData(),
sa.Column('name', sa.String(255), nullable=False),
sa.Column('tablename', sa.String(18), nullable=True)
)
op.execute(resource_type.update().where(
resource_type.c.name == "instance_network_interface"
).values({'tablename': op.inline_literal("'instance_net_int'")}))
op.execute(resource_type.update().where(
resource_type.c.name != "instance_network_interface"
).values({'tablename': resource_type.c.name}))
op.alter_column("resource_type", "tablename", type_=sa.String(18),
nullable=False)
op.create_unique_constraint("uniq_resource_type0tablename",
"resource_type", ["tablename"])
示例3: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
op.add_column('container',
sa.Column('cpu', sa.Float(),
nullable=True))
op.add_column('container',
sa.Column('workdir', sa.String(length=255),
nullable=True))
op.add_column('container',
sa.Column('ports',
zun.db.sqlalchemy.models.JSONEncodedList(),
nullable=True))
op.add_column('container',
sa.Column('hostname', sa.String(length=255),
nullable=True))
op.add_column('container',
sa.Column('labels',
zun.db.sqlalchemy.models.JSONEncodedDict(),
nullable=True))
示例4: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
for c in tables.Tasks.__add_result_links__:
op.add_column(tables.Tasks.__tablename__, c)
示例5: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('chart_block_defaults',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('caption', sa.String(length=255), nullable=True),
sa.Column('slug', sa.String(length=255), nullable=False),
sa.Column('dataset', sa.String(length=255), nullable=False),
sa.Column('content', sa.Text(convert_unicode=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('chart_blocks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('department_id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('caption', sa.String(length=255), nullable=True),
sa.Column('slug', sa.String(length=255), nullable=False),
sa.Column('dataset', sa.String(length=255), nullable=False),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('date_updated', sa.DateTime(), nullable=True),
sa.Column('date_edited', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['department_id'], ['departments.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.add_column('use_of_force_incidents', sa.Column('received_date', sa.DateTime(), nullable=True))
### end Alembic commands ###
示例6: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
op.add_column('officer_involved_shootings_bpd', sa.Column('case_number', sa.String(length=255), nullable=True))
示例7: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('citizen_complaint', sa.Column('officer_age', sa.String(length=255), nullable=True))
op.add_column('citizen_complaint', sa.Column('resident_age', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('officer_age', sa.String(length=255), nullable=True))
op.add_column('use_of_force_incidents', sa.Column('resident_age', sa.String(length=255), nullable=True))
### end Alembic commands ###
示例8: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('citizen_complaints', sa.Column('allegation', sa.String(length=255), nullable=True))
op.add_column('citizen_complaints', sa.Column('allegation_type', sa.String(length=255), nullable=True))
op.drop_column('citizen_complaints', 'category')
### end Alembic commands ###
示例9: downgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('citizen_complaints', sa.Column('category', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.drop_column('citizen_complaints', 'allegation_type')
op.drop_column('citizen_complaints', 'allegation')
### end Alembic commands ###
示例10: downgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('denominator_values', sa.Column('arrests', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_column('denominator_values', 'officers_out_on_service')
### end Alembic commands ###
示例11: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('use_of_force_incidents', sa.Column('received_date', sa.DateTime(), nullable=True))
### end Alembic commands ###
示例12: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
# create the has_disposition column
op.add_column('officer_involved_shootings_bpd', sa.Column('has_disposition', sa.Boolean(), nullable=True))
# update the has_disposition column based on values in the disposition column
db_bind = op.get_bind()
db_bind.execute(sa.sql.text('''
UPDATE officer_involved_shootings_bpd SET has_disposition = (disposition != '' AND disposition IS NOT NULL)
'''))
# drop the disposition column
op.drop_column('officer_involved_shootings_bpd', 'disposition')
示例13: downgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def downgrade():
op.add_column('officer_involved_shootings_bpd', sa.Column('disposition', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.drop_column('officer_involved_shootings_bpd', 'has_disposition')
示例14: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
op.add_column('chart_blocks', sa.Column('order', sa.Integer(), server_default='0', nullable=True))
示例15: upgrade
# 需要導入模塊: from alembic import op [as 別名]
# 或者: from alembic.op import add_column [as 別名]
def upgrade():
op.add_column('use_of_force_incidents_bpd', sa.Column('case_number', sa.String(length=128), nullable=True))
op.add_column('use_of_force_incidents_bpd', sa.Column('completed_date', sa.DateTime(), nullable=True))
op.add_column('use_of_force_incidents_bpd', sa.Column('received_date', sa.DateTime(), nullable=True))
op.drop_column('use_of_force_incidents_bpd', 'division')
op.drop_column('use_of_force_incidents_bpd', 'bureau')
op.drop_column('use_of_force_incidents_bpd', 'resident_weapon_used')