Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def downgrade():
op.drop_index(op.f('ix_cache_key'), table_name='cache')
op.create_unique_constraint('cache_key_key', 'cache', ['key'])
def downgrade():
"""The downgrade migration actions."""
# dropping
op.drop_constraint('db_dbgroup_label_type_string_key', 'db_dbgroup')
op.drop_index('ix_db_dbgroup_label', 'db_dbgroup')
op.drop_index('ix_db_dbgroup_type_string', 'db_dbgroup')
# renaming
op.alter_column('db_dbgroup', 'label', new_column_name='name')
op.alter_column('db_dbgroup', 'type_string', new_column_name='type')
# creating
op.create_unique_constraint('db_dbgroup_name_type_key', 'db_dbgroup', ['name', 'type'])
op.create_index('ix_db_dbgroup_name', 'db_dbgroup', ['name'])
op.create_index('ix_db_dbgroup_type', 'db_dbgroup', ['type'])
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint('uni_user_code', 'password_reset', ['user', 'code'])
### end Alembic commands ###
def _update_managers_table():
op.add_column('managers', sa.Column('node_id', sa.Text(), nullable=True))
op.add_column('managers',
sa.Column('last_seen', UTCDateTime(), nullable=False,
server_default=sa.func.current_timestamp()))
op.add_column('managers',
sa.Column('status_report_frequency', sa.Integer(),
nullable=True))
op.execute("""
UPDATE managers
SET node_id = hostname;
""")
op.alter_column('managers', 'node_id', nullable=False)
op.create_unique_constraint(op.f('managers_node_id_key'), 'managers',
['node_id'])
op.create_index(op.f('managers_last_seen_idx'), 'managers', ['last_seen'],
unique=False)
def downgrade():
op.drop_constraint('ps_contacts_uq', 'ps_contacts', type_='unique')
op.drop_column('ps_contacts', 'reg_server')
op.create_unique_constraint(None, 'ps_contacts', 'id')
def upgrade():
"""Add unique key constraint to the UUID column."""
op.create_unique_constraint('db_dblog_uuid_key', 'db_dblog', ['uuid'])
sa.Column('volume_type_id', sa.String(length=36),
sa.ForeignKey('share_types.id'), nullable=False),
sa.Column('key', sa.String(length=255)),
sa.Column('value', sa.String(length=255)),
mysql_engine='InnoDB')
LOG.info(_LI("Migrating share_type_extra_specs to "
"volume_type_extra_specs"))
_copy_records(destination_table=vt_es, up_migration=False)
LOG.info(_LI("Dropping share_type_extra_specs table"))
op.drop_table("share_type_extra_specs")
LOG.info(_LI("Renaming share_types table to volume_types"))
op.drop_constraint('st_name_uc', 'share_types', type_='unique')
op.create_unique_constraint('vt_name_uc', 'share_types',
['name', 'deleted'])
op.rename_table("share_types", "volume_types")
LOG.info(_LI("Renaming column name shares.share_type_id to "
"shares.volume_type.id"))
op.alter_column("shares", "share_type_id",
new_column_name="volume_type_id",
type_=sa.String(length=36))
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(
"vote_user_id_poll_id_poll_option_id_key",
"vote",
["user_id", "poll_id", "poll_option_id"],
)
op.drop_constraint("one_vote_per_option_and_user", "vote", type_="unique")
op.alter_column(
"poll",
"results_visible",
existing_type=sa.BOOLEAN(),
server_default=sa.text("true"),
existing_nullable=False,
)
op.drop_column("poll", "show_percentage")
# ### end Alembic commands ###
def downgrade():
"""Restore the fields, enums, and constraints removed in the upgrade() function."""
op.add_column('builds', sa.Column('scm_url', sa.Unicode(length=256), nullable=True))
op.create_unique_constraint('uq_scm_url', 'builds', ['scm_url'])
op.execute(
"CREATE TYPE ck_ci_status AS ENUM "
"('ignored', 'queued', 'running', 'passed', 'failed', 'waiting')")
op.add_column(
'builds',
sa.Column(
'ci_status',
sa.Enum(
'ignored', 'queued', 'running', 'passed', 'failed', 'waiting',
name='ck_ci_status'),
nullable=True
)
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_unique_constraint(None, "users", ["guid"])
# op.drop_constraint('agency_users_user_guid_fkey', 'agency_users', type_='foreignkey')
# op.create_foreign_key(None, 'agency_users', 'users', ['user_guid'], ['guid'])
op.drop_column("agency_users", "auth_user_type")
op.create_foreign_key(
None, "agency_users", "users", ["user_guid"], ["guid"], onupdate="CASCADE"
)
# op.drop_constraint('events_user_guid_fkey', 'events', type_='foreignkey')
op.drop_column("events", "auth_user_type")
op.create_foreign_key(
None, "events", "users", ["user_guid"], ["guid"], onupdate="CASCADE"
)
# op.drop_constraint('user_requests_user_guid_fkey', 'user_requests', type_='foreignkey')
op.drop_column("user_requests", "auth_user_type")
op.create_foreign_key(
None, "user_requests", "users", ["user_guid"], ["guid"], onupdate="CASCADE"
)