Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def upgrade():
with op.batch_alter_table('ps_endpoints') as batch_op:
batch_op.alter_column('accountcode', type_=sa.String(80))
with op.batch_alter_table('sippeers') as batch_op:
batch_op.alter_column('accountcode', type_=sa.String(80))
with op.batch_alter_table('iaxfriends') as batch_op:
batch_op.alter_column('accountcode', type_=sa.String(80))
pass
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', server_default="80.")
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)
def downgrade():
### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.add_column(sa.Column('chunk_start', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('current_frame', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('chunk_end', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
batch_op.drop_column('type')
batch_op.drop_column('settings')
batch_op.drop_column('name')
batch_op.drop_column('log')
batch_op.drop_column('activity')
with op.batch_alter_table('manager', schema=None) as batch_op:
batch_op.add_column(sa.Column('running_tasks', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False))
batch_op.add_column(sa.Column('total_workers', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
with op.batch_alter_table('job', schema=None) as batch_op:
batch_op.add_column(sa.Column('frame_start', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('current_frame', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
def upgrade():
with op.batch_alter_table('score', naming_convention=convention) as batch_op:
batch_op.add_column(sa.Column('scoring_algorithm', EnumType(ScoringAlgorithm), nullable=True))
batch_op.add_column(sa.Column('variable1', sa.Float(), nullable=True))
batch_op.add_column(sa.Column('variable2', sa.Float(), nullable=True))
batch_op.add_column(sa.Column('loses', sa.Integer(), nullable=False, default='0', server_default='0'))
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('storage_replication', schema=None) as batch_op:
batch_op.add_column(sa.Column('repl_dedup', sa.BOOLEAN(), nullable=False))
with op.batch_alter_table(ATTRIBUTES,
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(fk_constraint, type_='foreignkey')
rows = connection.execute(sa.select([attributes.c.uuid,
attributes.c.node_uuid]))
for row in rows:
# move uuid to node_uuid, reuse uuid as a new primary key
connection.execute(
attributes.update().where(attributes.c.uuid == row.uuid).
values(node_uuid=row.uuid, uuid=uuidutils.generate_uuid())
)
with op.batch_alter_table(ATTRIBUTES,
naming_convention=naming_convention) as batch_op:
batch_op.drop_constraint(pk_constraint, type_='primary')
batch_op.create_primary_key(pk_constraint, [UUID])
batch_op.create_foreign_key('fk_node_attribute', NODES,
[NODE_UUID], [UUID])
batch_op.alter_column('name', nullable=False, type_=name_type)
batch_op.alter_column('value', nullable=True, type_=value_type)
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user') as batch_op:
batch_op.drop_column('avatar')
# ### end Alembic commands ###
def downgrade():
with op.batch_alter_table('feature') as batch_op:
batch_op.drop_column('staff')
with op.batch_alter_table('user') as batch_op:
batch_op.drop_column('staff')
def downgrade():
# drop uuid unique constraint and column for each table
for table_name in table_names:
with op.batch_alter_table(table_name, naming_convention=convention) as batch_op:
batch_op.drop_constraint("uq_"+table_name+"_uuid", type_='unique')
batch_op.drop_column('uuid')