コード例 #1
0
ファイル: 002-reg_info.py プロジェクト: avelosa/bonzai-reg
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "users", type_="foreignkey")
    op.drop_column("users", "team_id")
    op.drop_column("users", "shirt_size")
    op.drop_column("users", "allergies")
    op.drop_table("teams")
def downgrade():
    connection = op.get_bind()

    # Create old AZ fields
    op.add_column('services', Column('availability_zone', String(length=255)))
    op.add_column('share_instances',
                  Column('availability_zone', String(length=255)))

    # Migrate data
    az_table = utils.load_table('availability_zones', connection)
    share_instances_table = utils.load_table('share_instances', connection)
    services_table = utils.load_table('services', connection)

    for az in connection.execute(az_table.select()):
        op.execute(
            share_instances_table.update().where(
                share_instances_table.c.availability_zone_id == az.id
            ).values({'availability_zone': az.name})
        )
        op.execute(
            services_table.update().where(
                services_table.c.availability_zone_id == az.id
            ).values({'availability_zone': az.name})
        )

    # Remove AZ_id columns and AZ table
    op.drop_constraint('service_az_id_fk', 'services', type_='foreignkey')
    op.drop_column('services', 'availability_zone_id')
    op.drop_constraint('si_az_id_fk', 'share_instances', type_='foreignkey')
    op.drop_column('share_instances', 'availability_zone_id')
    op.drop_table('availability_zones')
コード例 #3
0
def upgrade():
    conn = op.get_bind()
    op.add_column('external_identities', sa.Column('local_user_id',
                                                   sa.Integer()))

    external_identities_t = table('external_identities',
                                  sa.Column('local_user_name', sa.Unicode(50)),
                                  sa.Column('local_user_id', sa.Integer))
    users_t = table('users',
                    sa.Column('user_name', sa.Unicode(50)),
                    sa.Column('id', sa.Integer))

    stmt = external_identities_t.update().values(local_user_id=users_t.c.id). \
        where(users_t.c.user_name == external_identities_t.c.local_user_name)
    conn.execute(stmt)
    op.drop_constraint('pk_external_identities', 'external_identities',
                       type='primary')
    op.drop_constraint('fk_external_identities_local_user_name_users',
                       'external_identities', type='foreignkey')
    op.drop_column('external_identities', 'local_user_name')
    op.create_primary_key('pk_external_identities', 'external_identities',
                          cols=['external_id', 'local_user_id',
                                'provider_name'])
    op.create_foreign_key(None, 'external_identities', 'users',
                          remote_cols=['id'],
                          local_cols=['local_user_id'], onupdate='CASCADE',
                          ondelete='CASCADE')
コード例 #4
0
def downgrade():
    op.drop_column("metrics", "created_on")
    op.drop_column("metrics", "created_by_fk")
    op.drop_column("metrics", "changed_on")
    op.drop_column("metrics", "changed_by_fk")
    try:
        op.alter_column("url", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("url", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("tables", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("tables", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("table_columns", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("table_columns", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("sql_metrics", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("sql_metrics", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("slices", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("slices", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.drop_constraint(None, "metrics", type_="foreignkey")
        op.drop_constraint(None, "metrics", type_="foreignkey")
        op.alter_column("dbs", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("dbs", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("datasources", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("datasources", "created_by_fk", existing_type=sa.INTEGER(), nullable=False)
        op.alter_column("datasources", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("datasources", "changed_by_fk", existing_type=sa.INTEGER(), nullable=False)
        op.alter_column("dashboards", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("dashboards", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("css_templates", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("css_templates", "changed_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("columns", "created_on", existing_type=sa.DATETIME(), nullable=False)
        op.alter_column("columns", "changed_on", existing_type=sa.DATETIME(), nullable=False)
    except:
        pass
コード例 #5
0
ファイル: 1f10ba784ed8_.py プロジェクト: genmon/glanc1ng
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'whoyoulookinat')
    op.create_unique_constraint(u'whoyoulookinat_user_id_looking_at_twitter_display_name_key', 'whoyoulookinat', [u'looking_at_twitter_display_name', u'user_id'])
    op.drop_constraint(None, 'twitter_friends_cache')
    op.create_unique_constraint(u'twitter_friends_cache_twitter_id_friend_twitter_id_key', 'twitter_friends_cache', [u'friend_twitter_id', u'twitter_id'])
    op.drop_table('received_transitory_glance')
def downgrade():
    op.drop_constraint("reportunknownpackages_report_id_key", t)
    op.drop_constraint("reportunknownpackages_arch_id_fkey", t)

    op.add_column(t, sa.Column('running_epoch', sa.Integer(),
                               nullable=True))
    op.add_column(t, sa.Column('running_version', sa.String(64),
                               nullable=True))
    op.add_column(t, sa.Column('running_release', sa.String(64),
                               nullable=True))
    op.add_column(t, sa.Column('running_arch_id', sa.Integer(),
                               sa.ForeignKey('archs.id'),
                               nullable=True))

    op.alter_column(t, "epoch", new_column_name="installed_epoch")
    op.alter_column(t, "version", new_column_name="installed_version")
    op.alter_column(t, "release", new_column_name="installed_release")
    op.alter_column(t, "arch_id", new_column_name="installed_arch_id")

    fields = ["report_id", "type", "name", "installed_epoch",
              "installed_version", "installed_release", "installed_arch_id",
              "running_epoch", "running_version", "running_release",
              "running_arch_id"]

    op.create_unique_constraint("reportunknownpackages_report_id_key", t,
                                fields)

    op.create_foreign_key("reportunknownpackages_installed_arch_id_fkey", t,
                          "archs", ["installed_arch_id"], ["id"])
コード例 #7
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column(u'tracks', 'location')
    op.drop_constraint(None, 'sponsors', type_='foreignkey')
    op.drop_column(u'sponsors', 'sponsor_type_id')
    op.drop_column(u'sponsors', 'description')
    op.drop_table('sponsor_type')
def downgrade():
  """Downgrade database schema and/or data back to the previous revision."""
  op.drop_constraint("fk_assessments_audits", "assessments",
                     type_="foreignkey")
  op.drop_constraint("fk_issues_audits", "issues", type_="foreignkey")
  op.drop_column("assessments", "audit_id")
  op.drop_column("issues", "audit_id")
コード例 #9
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(u'notes_section_id_fkey', 'notes', type_='foreignkey')
    op.drop_column('notes', 'section_id')
    op.drop_table('sections')
    op.add_column('notes', sa.Column('notebook_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'notes', 'notebooks', ['notebook_id'], ['id'])
コード例 #10
0
def upgrade():
    # OpenStack has decided that "down" migrations are not supported.
    # The downgrade() method has been omitted for this reason.
    op.add_column('listener_statistics',
                  sa.Column('amphora_id',
                            sa.String(36),
                            nullable=False)
                  )

    op.drop_constraint('fk_listener_statistics_listener_id',
                       'listener_statistics',
                       type_='foreignkey')
    op.drop_constraint('PRIMARY',
                       'listener_statistics',
                       type_='primary')

    op.create_primary_key('pk_listener_statistics', 'listener_statistics',
                          ['listener_id', 'amphora_id'])
    op.create_foreign_key('fk_listener_statistics_listener_id',
                          'listener_statistics',
                          'listener',
                          ['listener_id'],
                          ['id'])
    op.create_foreign_key('fk_listener_statistic_amphora_id',
                          'listener_statistics',
                          'amphora',
                          ['amphora_id'],
                          ['id'])
コード例 #11
0
ファイル: 563495edabd3_.py プロジェクト: Rdbaker/Rank
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f('ix_games_api_key'), 'games', ['api_key'], unique=True)
    op.drop_constraint(u'games_api_key_key', 'games', type_='unique')
    op.alter_column('users', 'game_id',
               existing_type=sa.INTEGER(),
               nullable=True)
コード例 #12
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('releases_uniq', 'releases', type_='unique')
    op.create_unique_constraint('releases_name_group_id_posted_key', 'releases', ['name', 'group_id', 'posted'])
    op.drop_column('releases', 'uniqhash')
    op.drop_constraint('pres_uniq', 'pres', type_='unique')
    op.create_unique_constraint('pres_name_key', 'pres', ['name'])
コード例 #13
0
def upgrade():
    conn = op.get_bind()
    # Minimal examples of the tables we need to manipulate
    listener = sa.sql.table(
        'listener',
        sa.sql.column('load_balancer_id', sa.String),
        sa.sql.column('default_pool_id', sa.String))
    pool = sa.sql.table(
        'pool',
        sa.sql.column('load_balancer_id', sa.String),
        sa.sql.column('id', sa.String))

    # This foreign key does not need to be unique anymore. To remove the
    # uniqueness but keep the foreign key we have to do some juggling.
    op.drop_constraint('fk_listener_pool_id', 'listener',
                       type_='foreignkey')
    op.drop_constraint('uq_listener_default_pool_id', 'listener',
                       type_='unique')
    op.create_foreign_key('fk_listener_pool_id', 'listener',
                          'pool', ['default_pool_id'], ['id'])

    op.add_column(u'pool',
                  sa.Column('load_balancer_id', sa.String(36),
                            sa.ForeignKey('load_balancer.id'), nullable=True))

    # Populate this new column appropriately
    select_obj = sa.select([listener.c.load_balancer_id,
                           listener.c.default_pool_id]).where(
                               listener.c.default_pool_id is not None)
    result = conn.execute(select_obj)
    for row in result:
        stmt = pool.update().values(load_balancer_id=row[0]).where(
            pool.c.id == row[1])
        op.execute(stmt)
def downgrade():
    op.drop_constraint(
        'fk_environments_zone_id_zones',
        'environments',
        type_='foreignkey'
    )
    op.drop_column('environments', 'zone_id')
コード例 #15
0
def upgrade():
    # drop duplicate pres
    conn = op.get_bind()

    conn.execute('''
        DELETE FROM pres
        WHERE id IN (SELECT id
                      FROM (SELECT id,
                                row_number() over (partition BY requestid, pretime, requestgroup ORDER BY id) AS rnum
                             FROM pres) t
                      WHERE t.rnum > 1);
    ''')

    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('pres_name_key', 'pres', type_='unique')
    op.create_unique_constraint('pres_uniq', 'pres', ['requestid', 'pretime', 'requestgroup'])
    op.add_column('releases', sa.Column('uniqhash', sa.String(length=40), nullable=True))
    op.drop_constraint('releases_name_group_id_posted_key', 'releases', type_='unique')
    op.create_unique_constraint('releases_uniq', 'releases', ['uniqhash'])

    session = sessionmaker(bind=conn)()
    # update the hashes
    q = session.query(Release.id, Release.name, Release.group_id, Release.posted)
    for release in windowed_query(q, Release.id, 1000):
        uniqhash = hashlib.sha1(
            '{}.{}.{}'.format(
                release.name,
                release.group_id,
                release.posted,
            ).encode('utf-8')
        ).hexdigest()

        session.query(Release).filter(Release.id==release.id).update({Release.uniqhash: uniqhash})

    session.commit()
コード例 #16
0
def downgrade():
    # Was unable to find a way to use op.alter_column() to remove the
    # unique index property.
    if op.get_context().bind.dialect.name == 'mssql':
        op.drop_constraint('uq_queue_members_uniqueid', 'queue_members')
    op.drop_column('queue_members', 'uniqueid')
    op.add_column('queue_members', sa.Column(name='uniqueid', type_=sa.String(80), nullable=False))
コード例 #17
0
def downgrade():
    if 'easfoldersync' in Base.metadata.tables:
        op.create_unique_constraint('account_id',
                                    'easfoldersync',
                                    ['account_id', 'folder_name'])
        op.drop_constraint('uq_account_id_eas_folder_id', 'easfoldersync',
                           type_='unique')
コード例 #18
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('gene', sa.Column('reference_assembly_id', sa.Integer(), nullable=True))
    op.create_unique_constraint('gene_within_assembly_unique', 'gene', ['name', 'reference_assembly_id'])
    op.drop_constraint('gene_reference_assemlby_id_fkey', 'gene', type_='foreignkey')
    op.create_foreign_key(None, 'gene', 'reference_assembly', ['reference_assembly_id'], ['id'])
    op.drop_column('gene', 'reference_assemlby_id')
コード例 #19
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('gene', sa.Column('reference_assemlby_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'gene', type_='foreignkey')
    op.create_foreign_key('gene_reference_assemlby_id_fkey', 'gene', 'reference_assembly', ['reference_assemlby_id'], ['id'])
    op.drop_constraint('gene_within_assembly_unique', 'gene', type_='unique')
    op.drop_column('gene', 'reference_assembly_id')
コード例 #20
0
def upgrade():
    op.drop_constraint('fk_organization_owners_id', 'organization', type_='foreignkey')
    op.create_foreign_key('organization_owners_id_fkey', 'organization', 'team', ['owners_id'], ['id'])
    op.add_column('organization', sa.Column('members_id', sa.Integer(), nullable=True))
    op.create_foreign_key('organization_members_id_fkey', 'organization', 'team', ['members_id'], ['id'])
    op.add_column('team', sa.Column('domain', sa.Unicode(length=253), nullable=True))
    op.create_index(op.f('ix_team_domain'), 'team', ['domain'], unique=False)
コード例 #21
0
def downgrade():
    op.drop_index(op.f('ix_team_domain'), table_name='team')
    op.drop_column('team', 'domain')
    op.drop_constraint('organization_members_id_fkey', 'organization', type_='foreignkey')
    op.drop_column('organization', 'members_id')
    op.drop_constraint('organization_owners_id_fkey', 'organization', type_='foreignkey')
    op.create_foreign_key('fk_organization_owners_id', 'organization', 'team', ['owners_id'], ['id'])
コード例 #22
0
ファイル: 1217e5fbdbd9_.py プロジェクト: OspreyX/pgcontents
def downgrade():
    op.drop_constraint(
        u'uix_filepath_username',
        'files',
        schema='pgcontents',
        type_='unique'
    )
コード例 #23
0
def upgrade():
    op.create_table('risk_assessment_control_mappings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('control_strength', sa.Text(), nullable=True),
    sa.Column('residual_risk', sa.Text(), nullable=True),
    sa.Column('risk_assessment_mapping_id', sa.Integer(), nullable=False),
    sa.Column('threat_id', sa.Integer(), nullable=False),
    sa.Column('control_id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('modified_by_id', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('context_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['context_id'], ['contexts.id'], ),
    sa.ForeignKeyConstraint(['control_id'], ['controls.id'], ),
    sa.ForeignKeyConstraint(['risk_assessment_mapping_id'], ['risk_assessment_mappings.id'], ),
    sa.ForeignKeyConstraint(['threat_id'], ['threats.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_constraint(
        'risk_assessment_mappings_ibfk_2',
        'risk_assessment_mappings',
        type_='foreignkey')
    op.drop_column('risk_assessment_mappings', u'control_id')
    op.drop_column('risk_assessment_mappings', u'residual_risk')
    op.drop_column('risk_assessment_mappings', u'control_strength')
コード例 #24
0
def upgrade():

    if migration.schema_has_table('nsxv3_lbaas_l7rules'):
        op.drop_constraint('fk_nsxv3_lbaas_l7rules_id', 'nsxv3_lbaas_l7rules',
                           'foreignkey')
        op.drop_constraint('l7rule_id', 'nsxv3_lbaas_l7rules', 'primary')
        op.drop_column('nsxv3_lbaas_l7rules', 'loadbalancer_id')
        op.drop_column('nsxv3_lbaas_l7rules', 'l7rule_id')
        op.rename_table('nsxv3_lbaas_l7rules', 'nsxv3_lbaas_l7policies')

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key(
                'fk_nsxv3_lbaas_l7policies_id', 'nsxv3_lbaas_l7policies',
                'lbaas_l7policies', ['l7policy_id'], ['id'],
                ondelete='CASCADE')
    else:
        op.create_table(
            'nsxv3_lbaas_l7policies',
            sa.Column('l7policy_id', sa.String(36), nullable=False),
            sa.Column('lb_rule_id', sa.String(36), nullable=False),
            sa.Column('lb_vs_id', sa.String(36), nullable=False),
            sa.Column('created_at', sa.DateTime(), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('l7policy_id'))

        if migration.schema_has_table('lbaas_l7policies'):
            op.create_foreign_key(
                'fk_nsxv3_lbaas_l7policies_id', 'nsxv3_lbaas_l7policies',
                'lbaas_l7policies', ['l7policy_id'], ['id'],
                ondelete='CASCADE')
コード例 #25
0
ファイル: __init__.py プロジェクト: openstack/neutron
def remove_foreign_keys(table, foreign_keys):
    for fk in foreign_keys:
        op.drop_constraint(
            constraint_name=fk['name'],
            table_name=table,
            type_='foreignkey'
        )
コード例 #26
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'email',
               existing_type=sa.VARCHAR(length=254),
               nullable=False)
    op.drop_constraint('category_name_unique', 'category', type_='unique')
    op.drop_table('item')
コード例 #27
0
def downgrade():
    from inbox.ignition import main_engine
    engine = main_engine(pool_size=1, max_overflow=0)
    if not engine.has_table('easaccount'):
        return
    op.drop_constraint('easaccount_ibfk_2', 'easaccount', type_='foreignkey')
    op.drop_column('easaccount', 'password_id')
コード例 #28
0
def index_cleanup(engine_names, table_name, uniq_name, columns, create,
                  unique, limited):
    bind = op.get_bind()
    engine = bind.engine
    if engine.name not in engine_names:
        return
    if create:
        if limited and engine.name == 'mysql':
            # For some versions of mysql we can get an error
            # "Specified key was too long; max key length is 1000 bytes".
            # We should create an index by hand in this case with limited
            # length of columns.
            meta = sa.MetaData()
            meta.bind = engine
            table = sa.Table(table_name, meta, autoload=True)
            columns_mysql = ",".join((c + "(100)" for c in columns))
            sql = ("create index %s ON %s (%s)" % (uniq_name, table,
                                                   columns_mysql))
            engine.execute(sql)
        else:
            op.create_index(uniq_name, table_name, columns, unique=unique)
    else:
        if unique:
            op.drop_constraint(uniq_name, table_name, type='unique')
        else:
            op.drop_index(uniq_name, table_name=table_name)
コード例 #29
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column(u'user', sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.create_foreign_key(u'user_org_id_fkey', 'user', 'org', ['org_id'], ['id'])
    op.drop_column(u'user', 'team_id')
    op.drop_table('team')
コード例 #30
0
def drop_foreign_key_constraint(table_name, fk_constraints):
    for fk in fk_constraints:
        op.drop_constraint(
            constraint_name=fk['name'],
            table_name=table_name,
            type_='foreignkey'
        )
コード例 #31
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'users', type_='foreignkey')
    op.drop_index(op.f('ix_users_username'), table_name='users')
    op.drop_column('users', 'roles_id')
コード例 #32
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='unique')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.create_index('ix_user_username', 'user', ['username'], unique=True)
    op.drop_column('user', 'social_id')
コード例 #33
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'todos', type_='foreignkey')
    op.drop_column('todos', 'list_id')
    op.drop_table('todolists')
コード例 #34
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user_o2m_role', type_='foreignkey')
    op.drop_constraint(None, 'user_o2m_role', type_='foreignkey')
    op.drop_constraint(None, 'switch', type_='foreignkey')
    op.drop_constraint(None, 'server', type_='foreignkey')
    op.drop_constraint(None, 'role_o2m_permission', type_='foreignkey')
    op.drop_constraint(None, 'role_o2m_permission', type_='foreignkey')
    op.drop_constraint(None, 'cabinet', type_='foreignkey')
コード例 #35
0
def downgrade():
    op.drop_constraint(op.f('fk_admin_account_access_group_id_access_group'),
                       'admin_account',
                       type_='foreignkey')
    op.drop_column('admin_account', 'access_group_id')
    op.drop_table('access_group')
コード例 #36
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('job_names_must_be_unique_within_user',
                       'jobs',
                       type_='unique')
コード例 #37
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='unique')
コード例 #38
0
ファイル: 4a6c012f67e8_.py プロジェクト: stelega/Project_IO
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('seat_hall_id_fkey', 'seat', type_='foreignkey')
    op.create_foreign_key(None, 'seat', 'hall', ['hall_id'], ['hall_id'])
    op.create_unique_constraint('unique_ticket_seat_and_seance', 'ticket', ['seat_id', 'seance_id'])
コード例 #39
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'products', type_='foreignkey')
    op.drop_column('products', 'seller_id')
コード例 #40
0
ファイル: 4a6c012f67e8_.py プロジェクト: stelega/Project_IO
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('unique_ticket_seat_and_seance', 'ticket', type_='unique')
    op.drop_constraint(None, 'seat', type_='foreignkey')
    op.create_foreign_key('seat_hall_id_fkey', 'seat', 'hall', ['hall_id'], ['hall_id'], ondelete='CASCADE')
def upgrade():
    op.add_column('core_plugin_config', sa.Column('type', sa.Unicode(length=30), nullable=False))
    op.drop_constraint('PRIMARY', 'core_plugin_config', type_='primary')
    op.create_primary_key('prim', 'core_plugin_config', ['id', 'type', 'hostname', 'key']) 
コード例 #42
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'Clubs', type_='unique')
    op.drop_column('Clubs', 'public_id')
def downgrade():
    op.drop_constraint("uq__token__refresh_token", "token")
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('post', sa.Column('user_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'post', 'user', ['user_id'], ['user_id'])
    op.drop_constraint('user_posts_fkey', 'user', type_='foreignkey')
    op.drop_column('user', 'posts')
コード例 #45
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "workflow", type_="foreignkey")
    op.drop_column("workflow", "project_id")
    op.drop_constraint(None, "term", type_="foreignkey")
    op.drop_column("term", "project_id")
    op.drop_constraint(None, "team_contact", type_="foreignkey")
    op.drop_column("team_contact", "project_id")
    op.drop_constraint(None, "tag_type", type_="foreignkey")
    op.drop_column("tag_type", "project_id")
    op.drop_constraint(None, "tag", type_="foreignkey")
    op.drop_column("tag", "project_id")
    op.drop_constraint(None, "service", type_="foreignkey")
    op.drop_column("service", "project_id")
    op.drop_constraint(None, "search_filter", type_="foreignkey")
    op.drop_column("search_filter", "project_id")
    op.drop_constraint(None, "plugin", type_="foreignkey")
    op.drop_column("plugin", "project_id")
    op.drop_constraint(None, "notification", type_="foreignkey")
    op.drop_column("notification", "project_id")
    op.drop_constraint(None, "individual_contact", type_="foreignkey")
    op.drop_column("individual_contact", "project_id")
    op.drop_constraint(None, "incident_type", type_="foreignkey")
    op.drop_column("incident_type", "project_id")
    op.drop_constraint(None, "incident_priority", type_="foreignkey")
    op.drop_column("incident_priority", "project_id")
    op.drop_constraint(None, "incident_cost_type", type_="foreignkey")
    op.drop_column("incident_cost_type", "project_id")
    op.drop_constraint(None, "incident_cost", type_="foreignkey")
    op.drop_column("incident_cost", "project_id")
    op.drop_constraint(None, "incident", type_="foreignkey")
    op.drop_column("incident", "project_id")
    op.drop_constraint(None, "document", type_="foreignkey")
    op.drop_column("document", "project_id")
    op.add_column(
        "dispatch_user",
        sa.Column("role", sa.VARCHAR(), autoincrement=False, nullable=False))
    op.drop_constraint(None, "definition", type_="foreignkey")
    op.drop_column("definition", "project_id")
    op.drop_table("dispatch_user_projects")
    op.drop_index("ix_project_search_vector", table_name="project")
    op.drop_table("project")
    op.drop_table("dispatch_user_organizations")
    op.drop_index("ix_organization_search_vector", table_name="organization")
    op.drop_table("organization")
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    op.drop_constraint(None, 'comments', type_='unique')
    op.drop_column('comments', 'report')
コード例 #47
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'submission', type_='foreignkey')
    op.drop_column('submission', 'submittedVersionId')
コード例 #48
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'users', type_='foreignkey')
    op.drop_column('users', 'default_random_alias_domain_id')
コード例 #49
0
def downgrade():
    op.drop_constraint('games_ibfk_4', 'games', type_='foreignkey')
    op.drop_column('games', 'tournament_id')
    op.add_column('games', Column('tournament_game', Boolean, nullable=False))
コード例 #50
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, "doc_tag", type_="foreignkey")
    op.drop_constraint(None, "doc_tag", type_="foreignkey")
    op.create_foreign_key(None, "doc_tag", "doc", ["doc_id"], ["id"])
    op.create_foreign_key(None, "doc_tag", "tag", ["tag_id"], ["id"])
コード例 #51
0
def downgrade():
    op.drop_constraint(None, 'dashboard_status_report', type_='foreignkey')
    op.drop_column('dashboard_status_report', 'electionId')
コード例 #52
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'games', type_='foreignkey')
    op.drop_column('games', 'user_id')
    op.drop_table('users')
コード例 #53
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'tx_county_aggregate',
        sa.Column('county_name',
                  sa.VARCHAR(length=255),
                  autoincrement=False,
                  nullable=True))
    op.drop_constraint(None, 'tx_county_aggregate', type_='unique')
    op.create_unique_constraint(
        'tx_county_aggregate_fips_report_date_report_granularity_key',
        'tx_county_aggregate', ['fips', 'report_date', 'report_granularity'])
    op.alter_column('tx_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('tx_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('tx_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.drop_column('tx_county_aggregate', 'facility_name')
    op.drop_index(op.f('ix_person_history_region'),
                  table_name='person_history')
    op.drop_index(op.f('ix_person_history_external_id'),
                  table_name='person_history')
    op.drop_constraint(None, 'ny_facility_aggregate', type_='unique')
    op.create_unique_constraint(
        'ny_facility_aggregate_fips_report_date_report_granularity_key',
        'ny_facility_aggregate', ['fips', 'report_date', 'report_granularity'])
    op.alter_column('ny_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('ny_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('ny_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('ny_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.drop_constraint(None, 'ky_county_aggregate', type_='unique')
    op.create_unique_constraint(
        'ky_county_aggregate_fips_report_date_report_granularity_key',
        'ky_county_aggregate', ['fips', 'report_date', 'report_granularity'])
    op.alter_column('ky_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('ky_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('ky_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('ky_county_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.drop_constraint(None, 'hi_facility_aggregate', type_='unique')
    op.create_unique_constraint(
        'hi_facility_aggregate_fips_report_date_report_granularity_key',
        'hi_facility_aggregate', ['fips', 'report_date', 'report_granularity'])
    op.alter_column('hi_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('hi_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('hi_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('hi_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('ga_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('ga_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('ga_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('ga_county_aggregate',
                    'county_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.drop_constraint(None, 'fl_facility_aggregate', type_='unique')
    op.create_unique_constraint(
        'fl_facility_aggregate_fips_report_date_report_granularity_key',
        'fl_facility_aggregate', ['fips', 'report_date', 'report_granularity'])
    op.alter_column('fl_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('fl_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('fl_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('fl_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('fl_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('fl_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('fl_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('fl_county_aggregate',
                    'county_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('dc_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=True)
    op.alter_column('dc_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=True)
    op.alter_column('dc_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.alter_column('dc_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=True)
    op.drop_table('ca_facility_aggregate')
def downgrade():
    op.drop_constraint("asset_market_id_fkey", "asset", type_="foreignkey")
    op.drop_column("asset", "market_id")
コード例 #55
0
def downgrade():
    op.drop_constraint(u'unq_task_number', 'task', type_='unique')
    op.drop_column('task', 'number')
コード例 #56
0
def upgrade():
    op.drop_constraint('ft_billing_pkey', 'ft_billing', type_='primary')
    op.create_primary_key('ft_billing_pkey', 'ft_billing', [
        'bst_date', 'template_id', 'service_id', 'notification_type',
        'provider', 'rate_multiplier', 'international', 'rate', 'postage'
    ])
def schema_downgrades():
    """schema downgrade migrations go here."""
    op.drop_constraint(None, 'devices', type_='foreignkey')
    op.drop_column('devices', 'dep_profile_id')
コード例 #58
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'ca_facility_aggregate',
        sa.Column('record_id', sa.Integer(), nullable=False),
        sa.Column('fips', sa.String(length=255), nullable=False),
        sa.Column('report_date', sa.Date(), nullable=False),
        # Set as string to force alembic to stop trying to re-create the enum
        # Will migrate to enum separately
        sa.Column('report_granularity', sa.String(length=255), nullable=False),
        sa.Column('jurisdiction_name', sa.String(length=255), nullable=True),
        sa.Column('facility_name', sa.String(length=255), nullable=True),
        sa.Column('average_daily_population',
                  sa.String(length=255),
                  nullable=True),
        sa.Column('unsentenced_male_adp', sa.String(length=255),
                  nullable=True),
        sa.Column('unsentenced_female_adp',
                  sa.String(length=255),
                  nullable=True),
        sa.Column('sentenced_male_adp', sa.String(length=255), nullable=True),
        sa.Column('sentenced_female_adp', sa.String(length=255),
                  nullable=True),
        sa.PrimaryKeyConstraint('record_id'),
        sa.UniqueConstraint('fips', 'facility_name', 'report_date',
                            'report_granularity'))
    op.alter_column('dc_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('dc_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('dc_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('dc_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.alter_column('fl_county_aggregate',
                    'county_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('fl_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('fl_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('fl_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.alter_column('fl_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('fl_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('fl_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('fl_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.drop_constraint(
        'fl_facility_aggregate_fips_report_date_report_granularity_key',
        'fl_facility_aggregate',
        type_='unique')
    op.create_unique_constraint(
        None, 'fl_facility_aggregate',
        ['fips', 'facility_name', 'report_date', 'report_granularity'])
    op.alter_column('ga_county_aggregate',
                    'county_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ga_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ga_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('ga_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.alter_column('hi_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('hi_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('hi_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('hi_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.drop_constraint(
        'hi_facility_aggregate_fips_report_date_report_granularity_key',
        'hi_facility_aggregate',
        type_='unique')
    op.create_unique_constraint(
        None, 'hi_facility_aggregate',
        ['fips', 'facility_name', 'report_date', 'report_granularity'])
    op.alter_column('ky_county_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ky_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ky_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('ky_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.drop_constraint(
        'ky_county_aggregate_fips_report_date_report_granularity_key',
        'ky_county_aggregate',
        type_='unique')
    op.create_unique_constraint(
        None, 'ky_county_aggregate',
        ['fips', 'facility_name', 'report_date', 'report_granularity'])
    op.alter_column('ny_facility_aggregate',
                    'facility_name',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ny_facility_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('ny_facility_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('ny_facility_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.drop_constraint(
        'ny_facility_aggregate_fips_report_date_report_granularity_key',
        'ny_facility_aggregate',
        type_='unique')
    op.create_unique_constraint(
        None, 'ny_facility_aggregate',
        ['fips', 'facility_name', 'report_date', 'report_granularity'])
    op.create_index(op.f('ix_person_history_external_id'),
                    'person_history', ['external_id'],
                    unique=False)
    op.create_index(op.f('ix_person_history_region'),
                    'person_history', ['region'],
                    unique=False)
    op.add_column(
        'tx_county_aggregate',
        sa.Column('facility_name', sa.String(length=255), nullable=False))
    op.alter_column('tx_county_aggregate',
                    'fips',
                    existing_type=sa.VARCHAR(length=255),
                    nullable=False)
    op.alter_column('tx_county_aggregate',
                    'report_date',
                    existing_type=sa.DATE(),
                    nullable=False)
    op.alter_column('tx_county_aggregate',
                    'report_granularity',
                    existing_type=postgresql.ENUM('DAILY',
                                                  'WEEKLY',
                                                  'MONTHLY',
                                                  name='report_granularity'),
                    nullable=False)
    op.drop_constraint(
        'tx_county_aggregate_fips_report_date_report_granularity_key',
        'tx_county_aggregate',
        type_='unique')
    op.create_unique_constraint(
        None, 'tx_county_aggregate',
        ['fips', 'facility_name', 'report_date', 'report_granularity'])
    op.drop_column('tx_county_aggregate', 'county_name')
コード例 #59
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'fix_detail', type_='foreignkey')
    op.drop_constraint(None, 'fix', type_='foreignkey')
    op.drop_constraint(None, 'fix', type_='foreignkey')
    op.drop_constraint(None, 'employee', type_='foreignkey')
    op.drop_constraint(None, 'client', type_='foreignkey')
    op.drop_constraint(None, 'FixEmployee', type_='foreignkey')
    op.create_foreign_key(None, 'FixEmployee', 'user', ['fixid'], ['id'])
    op.drop_constraint(None, 'FixEmployee', type_='foreignkey')
コード例 #60
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'conta', type_='foreignkey')
    op.drop_column('conta', 'usuario_id')