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"
    )
    op.add_column("users", sa.Column("active", sa.Boolean(), nullable=True))
    op.add_column("users", sa.Column("has_nyc_account", sa.Boolean(), nullable=True))
    op.add_column(
        "users", sa.Column("is_anonymous_requester", sa.Boolean(), nullable=True)
    )
    op.add_column("users", sa.Column("is_nyc_employee", sa.Boolean(), nullable=True))
Exemple #2
0
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 upgrade():
    # constraint name is autogenerated differently between pg versions
    try:
        op.drop_constraint("reportunknownpackages_report_id_key", t)
    except:
        op.execute('ROLLBACK')
        op.drop_constraint(
            "reportunknownpackages_report_id_type_name_installed_epoch_i_key",
            t)

    op.drop_constraint("reportunknownpackages_installed_arch_id_fkey", t)

    op.drop_column(t, "running_epoch")
    op.drop_column(t, "running_version")
    op.drop_column(t, "running_release")
    op.drop_column(t, "running_arch_id")

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

    op.create_foreign_key("reportunknownpackages_arch_id_fkey", t,
                          "archs", ["arch_id"], ["id"])

    fields = ["report_id", "type", "name", "epoch",
              "version", "release", "arch_id"]

    op.create_unique_constraint("reportunknownpackages_report_id_key", t,
                                fields)
Exemple #4
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('hero', sa.Column('image_name', sa.String(), nullable=True))
    op.add_column('hero', sa.Column('url_name', sa.String(), nullable=True))
    op.create_unique_constraint(None, 'hero', ['image_name'])
    op.create_unique_constraint(None, 'hero', ['url_name'])
    op.drop_column('hero', 'image_id')
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"])
Exemple #6
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('users', 'game_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.create_unique_constraint(u'games_api_key_key', 'games', ['api_key'])
    op.drop_index(op.f('ix_games_api_key'), table_name='games')
Exemple #7
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('privilege')
    op.add_column('engagement_order', sa.Column('uuid', sa.String(length=2), nullable=False))
    op.drop_column('engagement_order', 'id')
    op.create_unique_constraint(None, 'job_label', ['name'])
    op.create_unique_constraint(None, 'personal_label', ['name'])
Exemple #8
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('relationships', sa.Column('followed_by_id', sa.Integer(), nullable=True))
    op.add_column('relationships', sa.Column('user_id', sa.Integer(), nullable=True))
    op.create_unique_constraint('unique_idx_user_id_followed_by_id', 'relationships', ['user_id', 'followed_by_id'])
    op.create_foreign_key(None, 'relationships', 'users', ['followed_by_id'], ['id'])
    op.create_foreign_key(None, 'relationships', 'users', ['user_id'], ['id'])
def upgrade():
    op.add_column(ROUTER_L3_AGENT_BINDING,
                  sa.Column('binding_index', sa.Integer(), nullable=False,
                            server_default='1'))

    bindings_table = sa.Table(
        ROUTER_L3_AGENT_BINDING,
        sa.MetaData(),
        sa.Column('router_id', sa.String(36)),
        sa.Column('l3_agent_id', sa.String(36)),
        sa.Column('binding_index', sa.Integer,
                  nullable=False, server_default='1'),
    )

    routers_to_bindings = defaultdict(list)
    session = sa.orm.Session(bind=op.get_bind())
    with session.begin(subtransactions=True):
        for result in session.query(bindings_table):
            routers_to_bindings[result.router_id].append(result)

        for bindings in routers_to_bindings.values():
            for index, result in enumerate(bindings):
                session.execute(bindings_table.update().values(
                    binding_index=index + 1).where(
                    bindings_table.c.router_id == result.router_id).where(
                    bindings_table.c.l3_agent_id == result.l3_agent_id))
    session.commit()

    op.create_unique_constraint(
        'uniq_router_l3_agent_binding0router_id0binding_index0',
        ROUTER_L3_AGENT_BINDING, ['router_id', 'binding_index'])
def upgrade():
    op.create_table(
        'nodes',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=256), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('up', sa.Boolean(), nullable=True),
        sa.Column('machine_type', sa.String(length=32), nullable=True),
        sa.Column('arch', sa.String(length=16), nullable=True),
        sa.Column('is_vm', sa.Boolean(), nullable=False),
        sa.Column('distro', sa.String(length=32), nullable=True),
        sa.Column('vm_host_id', sa.Integer(), nullable=True),
        sa.Column('locked', sa.Boolean(), nullable=False),
        sa.Column('locked_by', sa.String(length=64), nullable=True),
        sa.Column('locked_since', sa.DateTime(), nullable=True),
        sa.Column('mac_address', sa.String(length=17), nullable=True),
        sa.Column('ssh_pub_key', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['vm_host_id'], ['nodes.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_unique_constraint("uq_node_name", "nodes", ["name"])
    op.create_table(
        'job_nodes',
        sa.Column('node_id', sa.Integer(), nullable=False),
        sa.Column('job_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['job_id'], ['jobs.id'], ),
        sa.ForeignKeyConstraint(['node_id'], ['nodes.id'], ),
        sa.PrimaryKeyConstraint()
    )
def upgrade():
    op.add_column("umbrella_organisation_oraganisation_associations", sa.Column('id', sa.Integer(), primary_key = True))
    op.create_unique_constraint(
        "umbrella_organisation_oraganisation_associations_unique_key",
        "umbrella_organisation_oraganisation_associations",
        ["organisation_id", "umbrella_organisation_id"]
    )
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'])
def upgrade():
    if migration.schema_has_table(TABLE_NAME):
        op.create_unique_constraint(
            name=CONSTRAINT_NAME,
            source=TABLE_NAME,
            local_cols=['pool_id', 'address', 'protocol_port']
        )
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')
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()
def upgrade():
    if not is_sqlite:
        connection = op.get_bind()
        attendees = connection.execute(select([
            attendee_table.c.hotel_pin,
            func.count(attendee_table.c.id),
            func.array_agg(attendee_table.c.id),
        ]).where(and_(
            attendee_table.c.hotel_pin != None,
            attendee_table.c.hotel_pin != '',
        )).group_by(
            attendee_table.c.hotel_pin,
        ).having(
            func.count(attendee_table.c.id) > 1,
        ))
        for hotel_pin, count, ids in attendees:
            hotel_pin_template = '{{:0{}d}}{{}}'.format(len(str(count))) if count > 9 else '{}{}'

            for i, id in enumerate(ids):
                new_hotel_pin = hotel_pin_template.format(i, hotel_pin)
                connection.execute(
                    attendee_table.update().where(attendee_table.c.id == id).values({
                        'hotel_pin': new_hotel_pin,
                    })
                )

    op.create_unique_constraint(op.f('uq_attendee_hotel_pin'), 'attendee', ['hotel_pin'])
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')
Exemple #18
0
def configurable_hostnames_upgrade():
    op.add_column(
        'nodes',
        sa.Column('hostname',
                  sa.String(length=255),
                  nullable=False,
                  server_default='')
    )
    op.drop_column('nodes', 'fqdn')

    connection = op.get_bind()
    update = sa.text(
        """UPDATE nodes SET hostname = 'node-' || id::text""")
    connection.execute(update)

    # the unique constrant should be created only when hostname is
    # filled properly for all nodes, otherwise the migration will fail
    # if there're few nodes in one cluster
    op.create_unique_constraint(
        '_hostname_cluster_uc',
        'nodes',
        [
            'cluster_id',
            'hostname'
        ]
    )
Exemple #19
0
def upgrade():
    op.create_foreign_key(
        'network_groups_nodegroups_fk', 'network_groups', 'nodegroups',
        ['group_id'], ['id'])
    op.create_foreign_key(
        'nodes_nodegroups_fk', 'nodes', 'nodegroups', ['group_id'], ['id'])
    op.alter_column(
        'oswl_stats', 'resource_checksum', existing_type=sa.TEXT(),
        nullable=False)
    op.create_unique_constraint(
        'oswl_stats_cluster_id_created_date_resource_type_unique_key',
        'oswl_stats', ['cluster_id', 'created_date', 'resource_type'])
    op.alter_column('clusters', 'name', type_=sa.TEXT())

    extend_ip_addrs_model_upgrade()
    extend_node_model_upgrade()
    configurable_hostnames_upgrade()
    extend_plugin_model_upgrade()
    upgrade_node_roles_metadata()
    node_roles_as_plugin_upgrade()
    migrate_volumes_into_extension_upgrade()
    networking_templates_upgrade()
    extend_releases_model_upgrade()
    upgrade_task_names()
    vms_conf_upgrade()
    extend_nic_model_upgrade()
    upgrade_cluster_ui_settings()
    upgrade_cluster_bond_settings()
    extensions_field_upgrade()
    set_deployable_false_for_old_releases()
    upgrade_node_labels()
    extend_segmentation_type()
    network_groups_name_upgrade()
def upgrade():
    op.drop_constraint('organizations_ibfk_1', 'organizations', type_='foreignkey')
    op.drop_constraint('idx_organizations_name', 'organizations', type_='unique')
    op.drop_constraint('idx_organizations_user_id', 'organizations', type_='unique')
    op.drop_constraint('org_name', 'organizations', type_='unique')
    op.create_unique_constraint('uk_organizations', 'organizations', ['org_name', 'user_id'])
    op.create_foreign_key('fk_organizations_user', 'organizations', 'users', ['user_id'], ['id'])
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('activity_reporting_org_ref_fkey', 'activity', type="foreignkey")
    op.drop_constraint('participation_organisation_ref_fkey', 'participation', type="foreignkey")
    op.drop_constraint('transaction_provider_org_ref_fkey', 'transaction', type="foreignkey")
    op.drop_constraint('transaction_receiver_org_ref_fkey', 'transaction', type="foreignkey")

    op.drop_constraint('organisation_pkey', 'organisation', type="primary")
    op.add_column('organisation', sa.Column('id', sa.Integer(), nullable=False, primary_key=True))
    op.create_primary_key('organisation_pkey', 'organisation', ['id'])

    op.add_column('activity', sa.Column('reporting_org_id', sa.Integer(), nullable=True))
    op.drop_column('activity', u'reporting_org_ref')
    op.add_column('participation', sa.Column('organisation_id', sa.Integer(), nullable=False))
    op.drop_column('participation', u'organisation_ref')
    op.add_column('transaction', sa.Column('provider_org_id', sa.Integer(), nullable=True))
    op.add_column('transaction', sa.Column('receiver_org_id', sa.Integer(), nullable=True))
    op.drop_column('transaction', u'provider_org_ref')
    op.drop_column('transaction', u'receiver_org_ref')

    op.create_foreign_key('activity_reporting_org_id_fkey', 'activity', 'organisation',
        ["reporting_org_id"], ["id"])
    op.create_foreign_key('participation_organisation_id_fkey', 'participation', 'organisation',
        ["organisation_id"], ["id"])

    op.create_foreign_key('transaction_provider_org_id_fkey', 'transaction', 'organisation',
        ["provider_org_id"], ["id"])

    op.create_foreign_key('transaction_receiver_org_id_fkey', 'transaction', 'organisation',
        ["receiver_org_id"], ["id"])
    op.create_unique_constraint("organisation_ref_name_type_key", "organisation", 
        ["ref", "name", "type"])
Exemple #22
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('record', sa.Column('chart_config_json', sa.Text(), nullable=True))
    op.add_column('record', sa.Column('parent_id', sa.Integer(), nullable=True))
    op.add_column('record', sa.Column('url_id', sa.String(), nullable=True))
    op.create_unique_constraint(None, 'record', ['url_id'])
    op.create_foreign_key(None, 'record', 'record', ['parent_id'], ['id'])
def upgrade():
    op.drop_constraint(u"sync_ticket_proposal_space_id_ticket_no_key", "sync_ticket", type_="unique")
    op.create_unique_constraint(
        u"sync_ticket_proposal_space_id_order_no_ticket_no",
        "sync_ticket",
        ["proposal_space_id", "order_no", "ticket_no"],
    )
Exemple #24
0
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('ratings', sa.Column('rating', postgresql.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.add_column('ratings', sa.Column('series_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'ratings', type_='foreignkey')
    op.drop_constraint(None, 'ratings', type_='foreignkey')
    op.create_foreign_key('ratings_series_id_fkey', 'ratings', 'story', ['series_id'], ['id'])
    op.drop_constraint(None, 'ratings', type_='unique')
    op.create_unique_constraint('ratings_user_id_source_ip_series_id_key', 'ratings', ['user_id', 'source_ip', 'series_id'])
    op.create_index('ix_ratings_series_id', 'ratings', ['series_id'], unique=False)
    op.drop_index(op.f('ix_ratings_story'), table_name='ratings')
    op.drop_index(op.f('ix_ratings_changeuser'), table_name='ratings')
    op.drop_index(op.f('ix_ratings_changetime'), table_name='ratings')
    op.alter_column('ratings', 'source_ip',
               existing_type=sa.TEXT(),
               nullable=True)
    op.drop_column('ratings', 'technical')
    op.drop_column('ratings', 'story')
    op.drop_column('ratings', 'overall')
    op.drop_column('ratings', 'nickname')
    op.drop_column('ratings', 'comments')
    op.drop_column('ratings', 'chars_ctnt')
    op.drop_column('ratings', 'changeuser')
    op.drop_column('ratings', 'changetime')
    op.drop_column('ratings', 'be_ctnt')
    op.drop_index(op.f('ix_ratingschanges_user_id'), table_name='ratingschanges')
    op.drop_index(op.f('ix_ratingschanges_story'), table_name='ratingschanges')
    op.drop_index(op.f('ix_ratingschanges_srccol'), table_name='ratingschanges')
    op.drop_index(op.f('ix_ratingschanges_source_ip'), table_name='ratingschanges')
    op.drop_index(op.f('ix_ratingschanges_changeuser'), table_name='ratingschanges')
    op.drop_index(op.f('ix_ratingschanges_changetime'), table_name='ratingschanges')
    op.drop_table('ratingschanges')
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    gender_types.create(op.get_bind(), checkfirst=False)
    op.add_column('users', sa.Column('gender', gender_types, nullable=True))
    op.add_column('users', sa.Column(
        'phone', sa.String(length=40), nullable=True))
    op.create_unique_constraint(None, 'users', ['phone'])
Exemple #26
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('received_unnoticed_glance', u'hour')
    op.drop_constraint(u'twitter_friends_cache_twitter_id_friend_twitter_id_key', 'twitter_friends_cache')
    op.create_unique_constraint(None, 'twitter_friends_cache', ['twitter_id', 'friend_twitter_id'])
    op.drop_constraint(u'whoyoulookinat_user_id_looking_at_twitter_display_name_key', 'whoyoulookinat')
    op.create_unique_constraint(None, 'whoyoulookinat', ['user_id', 'looking_at_twitter_display_name'])
Exemple #27
0
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.add_column('received_unnoticed_glance', sa.Column(u'hour', sa.INTEGER(), nullable=False))
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    roles = op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=80), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ondelete='SET NULL'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_unique_constraint('company_company_name_key', 'company', ['company_name'])
    op.bulk_insert(roles, [
        { 'id': 1, 'name': 'superadmin' },
        { 'id': 2, 'name': 'admin' },
        { 'id': 3, 'name': 'staff' }
    ])
def upgrade():
  """Upgrade database schema and/or data, creating a new revision."""

  # Remove duplicate lines and include only the newest ones.
  # This relies on the newest lines having the biggest id.
  connection = op.get_bind()
  good_rows = connection.execute("""
      SELECT MAX(id) AS id
      FROM custom_attribute_values
      GROUP BY custom_attribute_id, attributable_id
  """).fetchall()
  all_rows = connection.execute(
      "SELECT id FROM custom_attribute_values"
  ).fetchall()
  good_ids = set(row[0] for row in good_rows)
  all_ids = set(row[0] for row in all_rows)

  bad_ids = [str(i) for i in all_ids.difference(good_ids)]

  if bad_ids:
    op.execute(
        """
        DELETE FROM custom_attribute_values
        WHERE id IN ({bad_ids})
        """.format(bad_ids=",".join(bad_ids))
    )

  # The unique constraint does not include the attributable_type since that is
  # already specified in the custom attribute definition (custom_attribute_id)
  # and we should avoid adding string values to indexes.
  op.create_unique_constraint(
      "uq_custom_attribute_value",
      "custom_attribute_values",
      ["custom_attribute_id", "attributable_id"]
  )
def downgrade():
    op.drop_table('recipe_reservation')
    op.drop_table('job_activity')
    op.drop_table('openstack_region')
    op.drop_column('virt_resource', 'kernel_options')
    op.drop_column('virt_resource', 'instance_id')
    op.drop_column('tg_user', 'openstack_tenant_name')
    op.drop_column('tg_user', 'openstack_password')
    op.drop_column('tg_user', 'openstack_username')
    op.drop_index('email_address', 'tg_user')
    op.create_unique_constraint('email_address', 'tg_user', ['email_address'])
    # We want to replace the unique constraint on lab_controller.user_id with 
    # an ordinary index. The constraint will be called 'uc_user_id' if it was 
    # created by following the original 0.17 upgrade notes, otherise it will be 
    # called 'user_id'.
    unique_name = find_unique('lab_controller', ['user_id'])
    op.execute("ALTER TABLE lab_controller "
               "DROP KEY %s, ADD KEY user_id (user_id)" % unique_name)
    op.execute("ALTER TABLE job "
               "DROP ntasks,"
               "MODIFY status ENUM('New', 'Processed', 'Queued', 'Scheduled',"
               "'Waiting', 'Running', 'Completed', 'Cancelled', 'Aborted') NOT NULL")
    op.execute("ALTER TABLE recipe_set "
               "DROP ntasks,"
               "MODIFY status ENUM('New', 'Processed', 'Queued', 'Scheduled',"
               "'Waiting', 'Running', 'Completed', 'Cancelled', 'Aborted') NOT NULL")
    op.execute("ALTER TABLE recipe "
               "DROP ntasks,"
               "MODIFY status ENUM('New', 'Processed', 'Queued', 'Scheduled',"
               "'Waiting', 'Running', 'Completed', 'Cancelled', 'Aborted') NOT NULL")
    op.alter_column('recipe_task', u'status',
               existing_type=sa.Enum(u'New', u'Processed', u'Queued', u'Scheduled', u'Waiting', u'Running', u'Completed', u'Cancelled', u'Aborted'),
               nullable=False)
Exemple #31
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('posts',
                  sa.Column('created_date', sa.DateTime(), nullable=False))
    op.create_unique_constraint(None, 'users', ['username'])
Exemple #32
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(None, 'artists', ['name'])
    op.create_unique_constraint(None, 'venues', ['name'])
def downgrade():
    op.create_unique_constraint("users_email_key", "users", ["email"])
    op.drop_constraint("uq_users_email", "users", type_="unique")
Exemple #34
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('alert_types',
    sa.Column('alert_type_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('utility_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.Enum('YELLOW_ALARM_LOAD', 'RED_ALARM_LOAD', 'YELLOW_ALARM_PRICE', 'RED_ALARM_PRICE', 'PRICE_ALERT', 'IMPORT_CAPACITY', 'EXPORT_CAPACITY', 'RESOURCE_DEPLETION', 'TELECOMM_ALERT', 'PEAK_EVENT', name='alertname'), nullable=False),
    sa.Column('limit', sa.Float(), nullable=False),
    sa.Column('updated_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.func.now(), nullable=True),
    sa.ForeignKeyConstraint(['utility_id'], ['utilities.utility_id'], ),
    sa.PrimaryKeyConstraint('alert_type_id'),
    sa.UniqueConstraint('utility_id', 'name', name='_utility_name_uc')
    )
    op.create_table('alerts',
    sa.Column('alert_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('alert_type_id', sa.Integer(), nullable=False),
    sa.Column('assigned_to', sa.String(length=255), nullable=False),
    sa.Column('description', sa.Text(), nullable=False),
    sa.Column('status', sa.Enum('OPEN', 'PENDING', 'RESOLVED', name='status'), nullable=False),
    sa.Column('context', sa.Enum('TRANSFORMER', 'FEEDER', 'RETAIL_MARKET', 'NONE', name='contexttype'), nullable=False),
    sa.Column('context_id', sa.String(length=64), nullable=False),
    sa.Column('resolution', sa.Text(), nullable=False),
    sa.Column('updated_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.func.now(), nullable=True),
    sa.ForeignKeyConstraint(['alert_type_id'], ['alert_types.alert_type_id'], ),
    sa.ForeignKeyConstraint(['assigned_to'], ['users.email'], ),
    sa.PrimaryKeyConstraint('alert_id')
    )
    op.create_table('notifications',
    sa.Column('notification_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('alert_type_id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('is_active', sa.Boolean(), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=False),
    sa.Column('updated_at', sa.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.func.now(), nullable=True),
    sa.ForeignKeyConstraint(['alert_type_id'], ['alert_types.alert_type_id'], ),
    sa.ForeignKeyConstraint(['created_by'], ['users.id'], ),
    sa.PrimaryKeyConstraint('notification_id'),
    sa.UniqueConstraint('alert_type_id', 'email', name='_alert_type_id_email_uc')
    )
    op.create_unique_constraint('uniq_name_utility', 'utilities', ['name'])
    op.drop_column('addresses', 'created_at')
    op.drop_column('addresses', 'updated_at')
    op.add_column('addresses',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('addresses',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('groups', 'created_at')
    op.drop_column('groups', 'updated_at')
    op.add_column('groups',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('groups',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('home_hubs', 'created_at')
    op.drop_column('home_hubs', 'updated_at')
    op.add_column('home_hubs',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('home_hubs',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('logins', 'created_at')
    op.drop_column('logins', 'updated_at')
    op.add_column('logins',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('logins',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('markets', 'created_at')
    op.drop_column('markets', 'updated_at')
    op.add_column('markets',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('markets',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('meters', 'created_at')
    op.drop_column('meters', 'updated_at')
    op.add_column('meters',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('meters',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('pvs', 'created_at')
    op.drop_column('pvs', 'updated_at')
    op.add_column('pvs',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('pvs',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('service_locations', 'created_at')
    op.drop_column('service_locations', 'updated_at')
    op.add_column('service_locations',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('service_locations',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
    op.drop_column('users', 'created_at')
    op.drop_column('users', 'updated_at')
    op.add_column('users',
        sa.Column('updated_at', sa.TIMESTAMP, nullable=False, server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')))
    op.add_column('users',
        sa.Column('created_at', sa.TIMESTAMP, nullable=True, server_default=sa.func.now()))
Exemple #35
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('tokens', sa.Column('token', sa.String(), nullable=True))
    op.drop_constraint('tokens_tokenn_key', 'tokens', type_='unique')
    op.create_unique_constraint(None, 'tokens', ['token'])
    op.drop_column('tokens', 'tokenn')
Exemple #36
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('files_name_key', 'files', ['name'])
def upgrade():
    op.create_unique_constraint('unique_frame_number', 'file',
                                ['video_parent_file_id', 'frame_number'])
Exemple #38
0
def upgrade():
    op.create_table(
        "forj_user",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('password', sa.String(128)),
        sa.Column('last_login', sa.DateTime(timezone=True), nullable=True),
        sa.Column('is_superuser', sa.Boolean),
        sa.Column('first_name', sa.String(30)),
        sa.Column('last_name', sa.String(150)),
        sa.Column('stripe_customer_id', sa.String(100), nullable=True),
        sa.Column('email', sa.String(254), unique=True),
        sa.Column('is_staff', sa.Boolean),
        sa.Column('is_active', sa.Boolean),
        sa.Column('date_joined', sa.DateTime(timezone=True)),
    )

    op.create_index('forj_user__email__idx', 'forj_user', ['email'])

    op.create_table(
        "forj_address",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('type', sa.SmallInteger, nullable=False),
        sa.Column('first_name', sa.String(250), nullable=True),
        sa.Column('last_name', sa.String(250), nullable=True),
        sa.Column('business_name', sa.String(250), nullable=True),
        sa.Column('line1', sa.Text, nullable=True),
        sa.Column('line2', sa.Text, nullable=True),
        sa.Column('postal_code', sa.String(140), nullable=True),
        sa.Column('city', sa.String(140), nullable=True),
        sa.Column('country', sa.String(2), nullable=True),
        sa.Column('phone_number', sa.String(20), nullable=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_address__user_id__idx', 'forj_address', ['user_id'])

    op.create_table(
        "forj_product",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(100)),
        sa.Column('reference', sa.String(100)),
        sa.Column('description', sa.Text, nullable=True),
        sa.Column('price', sa.Integer, nullable=True),
        sa.Column('condition', sa.String(100), nullable=True),
        sa.Column('formula', sa.String(100), nullable=True),
        sa.Column('currency', sa.String(3)),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_product__reference__idx', 'forj_product',
                    ['reference'])

    op.create_table(
        "forj_order",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('amount', sa.Integer),
        sa.Column('currency', sa.String(3)),
        sa.Column('reference', sa.String(30)),
        sa.Column('status', sa.SmallInteger, nullable=False),
        sa.Column('shipping_status', sa.SmallInteger, nullable=False),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('shipping_address_id',
                  sa.Integer,
                  sa.ForeignKey('forj_address.id'),
                  nullable=True),
        sa.Column('billing_address_id',
                  sa.Integer,
                  sa.ForeignKey('forj_address.id'),
                  nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
        sa.Column('stripe_card_id', sa.String(100), nullable=True),
        sa.Column('stripe_source_id', sa.String(100), nullable=True),
        sa.Column('stripe_charge_id', sa.String(100), nullable=True),
    )

    op.create_index('forj_order__user_id__idx', 'forj_order', ['user_id'])

    op.create_table(
        "forj_orderitem",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('quantity', sa.Integer, server_default="0"),
        sa.Column('amount', sa.Integer),
        sa.Column('shipping_cost', sa.Integer, server_default="0"),
        sa.Column('tax_cost', sa.Integer, server_default="0"),
        sa.Column('order_id', sa.Integer, sa.ForeignKey('forj_order.id')),
        sa.Column('product_id', sa.Integer, sa.ForeignKey('forj_product.id')),
        sa.Column('product_reference', sa.String(100)),
        sa.Column('created_at', sa.DateTime(timezone=True)),
        sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
    )

    op.create_index('forj_orderitem__product_id__idx', 'forj_orderitem',
                    ['product_id'])

    op.create_table(
        "auth_group",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(80)),
    )

    op.create_index('auth_group__name__idx', 'auth_group', ['name'])

    op.create_table(
        "forj_user_groups",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('group_id', sa.Integer, sa.ForeignKey('auth_group.id')),
    )

    op.create_unique_constraint('forj_user_groups__user_id__group_id__uniq',
                                'forj_user_groups', ['user_id', 'group_id'])

    op.create_table(
        "django_session",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('session_key', sa.String(40)),
        sa.Column('session_data', sa.Text),
        sa.Column('expire_date', sa.DateTime(timezone=True)),
    )

    op.create_unique_constraint('django_session__expire_date__idx',
                                'django_session', ['expire_date'])

    op.create_table(
        "django_content_type",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('app_label', sa.String(100)),
        sa.Column('model', sa.String(100)),
    )

    op.create_unique_constraint('django_content_type__app_label__model__uniq',
                                'django_content_type', ['app_label', 'model'])

    op.create_table(
        "auth_permission",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(255)),
        sa.Column('content_type_id', sa.Integer,
                  sa.ForeignKey('django_content_type.id')),
        sa.Column('codename', sa.String(100)),
    )

    op.create_unique_constraint(
        'auth_permission__content_type_id__codename__uniq', 'auth_permission',
        ['content_type_id', 'codename'])
    op.create_index('auth_permission__content_type_id__idx', 'auth_permission',
                    ['content_type_id'])

    op.create_table(
        "forj_user_user_permissions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
        sa.Column('permission_id', sa.Integer,
                  sa.ForeignKey('auth_permission.id')),
    )

    op.create_unique_constraint(
        'forj_user_user_permissions__user_id__permission_id__uniq',
        'forj_user_user_permissions', ['user_id', 'permission_id'])

    op.create_table(
        "auth_group_permissions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('group_id', sa.Integer, sa.ForeignKey('auth_group.id')),
        sa.Column('permission_id', sa.Integer,
                  sa.ForeignKey('auth_permission.id')),
    )

    op.create_unique_constraint(
        'auth_group_permissions__group_id__permission_id__uniq',
        'auth_group_permissions', ['group_id', 'permission_id'])
    op.create_index('auth_group_permissions__group_id__idx',
                    'auth_group_permissions', ['group_id'])
    op.create_index('auth_group_permissions__permission_id__idx',
                    'auth_group_permissions', ['permission_id'])

    op.create_table(
        "django_admin_log",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('action_time', sa.DateTime(timezone=True)),
        sa.Column('object_id', sa.Text, nullable=True),
        sa.Column('object_repr', sa.String(200)),
        sa.Column('action_flag', sa.SmallInteger),
        sa.Column('change_message', sa.Text),
        sa.Column('content_type_id',
                  sa.Integer,
                  sa.ForeignKey('django_content_type.id'),
                  nullable=True),
        sa.Column('user_id', sa.Integer, sa.ForeignKey('forj_user.id')),
    )

    op.create_index('django_admin_log__content_type_id__idx',
                    'django_admin_log', ['content_type_id'])
    op.create_index('django_admin_log__user_id__idx', 'django_admin_log',
                    ['user_id'])

    op.create_check_constraint("django_admin_log_action_flag_check",
                               "django_admin_log",
                               column('action_flag') >= 0)

    op.create_table(
        "easy_thumbnails_source",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('storage_hash', sa.String(40)),
        sa.Column('name', sa.String(255)),
        sa.Column('modified', sa.DateTime(timezone=True)),
    )

    op.create_unique_constraint(
        'easy_thumbnails_source__storage_hash__name__uniq',
        'easy_thumbnails_source', ['storage_hash', 'name'])
    op.create_index('easy_thumbnails_source__name__idx',
                    'easy_thumbnails_source', ['name'])
    op.create_index('easy_thumbnails_source__storage_hash__idx',
                    'easy_thumbnails_source', ['storage_hash'])

    op.create_table(
        "easy_thumbnails_thumbnail",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('name', sa.String(255)),
        sa.Column('storage_hash', sa.String(40)),
        sa.Column('modified', sa.DateTime(timezone=True)),
        sa.Column('source_id', sa.Integer,
                  sa.ForeignKey('easy_thumbnails_source.id')),
    )

    op.create_unique_constraint(
        'easy_thumbnails_thumbnail__storage_hash__name__source_id__uniq',
        'easy_thumbnails_thumbnail', ['storage_hash', 'name', 'source_id'])
    op.create_index('easy_thumbnails_thumbnail__name__idx',
                    'easy_thumbnails_thumbnail', ['name'])
    op.create_index('easy_thumbnails_thumbnail__storage_hash__idx',
                    'easy_thumbnails_thumbnail', ['storage_hash'])
    op.create_index('easy_thumbnails_thumbnail__source_id__idx',
                    'easy_thumbnails_thumbnail', ['source_id'])

    op.create_table(
        "easy_thumbnails_thumbnaildimensions",
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('thumbnail_id', sa.Integer,
                  sa.ForeignKey('easy_thumbnails_thumbnail.id')),
        sa.Column('width', sa.Integer),
        sa.Column('height', sa.Integer),
    )

    op.create_check_constraint(
        "easy_thumbnails_thumbnaildimensions__width_check",
        "easy_thumbnails_thumbnaildimensions",
        column('width') >= 0)

    op.create_check_constraint(
        "easy_thumbnails_thumbnaildimensions__height_check",
        "easy_thumbnails_thumbnaildimensions",
        column('height') >= 0)
Exemple #39
0
 def test_add_unique_constraint_col_event(self):
     context = op_fixture()
     op.create_unique_constraint("ik_test", "tbl_with_auto_appended_column",
                                 ["foo", "bar"])
     context.assert_("ALTER TABLE tbl_with_auto_appended_column "
                     "ADD CONSTRAINT ik_test UNIQUE (foo, bar)")
Exemple #40
0
def upgrade():
    """
    update schema&data
    """
    bind = op.get_bind()
    session = Session(bind=bind)

    # create table harbor_label
    HarborLabel.__table__.create(bind)

    # create table harbor_resource_label
    HarborResourceLabel.__table__.create(bind)

    # create user_group
    UserGroup.__table__.create(bind)

    # project member
    op.drop_constraint('project_member_ibfk_1',
                       'project_member',
                       type_='foreignkey')
    op.drop_constraint('project_member_ibfk_2',
                       'project_member',
                       type_='foreignkey')
    op.drop_constraint('project_member_ibfk_3',
                       'project_member',
                       type_='foreignkey')
    op.drop_constraint('PRIMARY', 'project_member', type_='primary')
    op.drop_index('user_id', 'project_member')
    op.drop_index('role', 'project_member')
    op.execute(
        'ALTER TABLE project_member ADD id INT PRIMARY KEY AUTO_INCREMENT;')
    op.alter_column('project_member',
                    'user_id',
                    existing_type=sa.Integer,
                    existing_nullable=False,
                    new_column_name='entity_id')
    op.alter_column('project_member',
                    'creation_time',
                    existing_type=mysql.TIMESTAMP,
                    server_default=sa.text("CURRENT_TIMESTAMP"))
    op.alter_column('project_member',
                    'update_time',
                    existing_type=mysql.TIMESTAMP,
                    server_default=sa.text("CURRENT_TIMESTAMP"),
                    onupdate=sa.text("CURRENT_TIMESTAMP"))
    op.add_column('project_member', sa.Column('entity_type', sa.String(1)))

    session.query(ProjectMember).update({ProjectMember.entity_type: 'u'})
    op.alter_column('project_member',
                    'entity_type',
                    existing_type=sa.String(1),
                    existing_nullable=True,
                    nullable=False)

    op.create_unique_constraint('unique_project_entity_type', 'project_member',
                                ['project_id', 'entity_id', 'entity_type'])

    # add job_uuid to replicationjob and img_scan_job
    op.add_column('replication_job', sa.Column('job_uuid', sa.String(64)))
    op.add_column('img_scan_job', sa.Column('job_uuid', sa.String(64)))

    # add index to replication job
    op.create_index('poid_status', 'replication_job', ['policy_id', 'status'])

    # add index to img_scan_job
    op.create_index('idx_status', 'img_scan_job', ['status'])
    op.create_index('idx_digest', 'img_scan_job', ['digest'])
    op.create_index('idx_uuid', 'img_scan_job', ['job_uuid'])
    op.create_index('idx_repository_tag', 'img_scan_job',
                    ['repository', 'tag'])

    session.commit()
Exemple #41
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(None, 'users', ['email'])
    op.create_unique_constraint(None, 'users', ['username'])
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('posts',
                  sa.Column('title', sa.Unicode(length=128), nullable=True))
    op.create_unique_constraint(None, 'posts', ['title'])
Exemple #43
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('shelters', sa.Column('login_id', sa.String(length=16), nullable=True))
    op.drop_constraint('shelters_loginID_key', 'shelters', type_='unique')
    op.create_unique_constraint(None, 'shelters', ['login_id'])
    op.drop_column('shelters', 'loginID')
Exemple #44
0
 def test_add_unique_constraint(self):
     context = op_fixture()
     op.create_unique_constraint("uk_test", "t1", ["foo", "bar"])
     context.assert_(
         "ALTER TABLE t1 ADD CONSTRAINT uk_test UNIQUE (foo, bar)")
Exemple #45
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(None, "users", ["email"])
    op.create_unique_constraint(None, "users", ["username"])
Exemple #46
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('shelters', sa.Column('loginID', sa.VARCHAR(length=16), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'shelters', type_='unique')
    op.create_unique_constraint('shelters_loginID_key', 'shelters', ['loginID'])
    op.drop_column('shelters', 'login_id')
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("users",
                  sa.Column("email", sa.String(length=80), nullable=False))
    op.create_unique_constraint(op.f("uq_users_email"), "users", ["email"])
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('follows_follower_id_key', 'follows',
                                ['follower_id'])
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(None, 'ecosystems', ['name'])
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('Artist',
                    'city',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Artist',
                    'facebook_link',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Artist',
                    'genres',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Artist',
                    'image_link',
                    existing_type=sa.VARCHAR(length=500),
                    nullable=False)
    op.alter_column('Artist',
                    'name',
                    existing_type=sa.VARCHAR(),
                    nullable=False)
    op.alter_column('Artist',
                    'phone',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Artist',
                    'seeking_venue',
                    existing_type=sa.BOOLEAN(),
                    nullable=False)
    op.alter_column('Artist',
                    'state',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.create_unique_constraint(None, 'Artist', ['name'])
    op.alter_column('Venue',
                    'address',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Venue',
                    'city',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Venue',
                    'facebook_link',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Venue',
                    'genres',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Venue',
                    'image_link',
                    existing_type=sa.VARCHAR(length=500),
                    nullable=False)
    op.alter_column('Venue',
                    'phone',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.alter_column('Venue',
                    'seeking_talent',
                    existing_type=sa.BOOLEAN(),
                    nullable=False)
    op.alter_column('Venue',
                    'state',
                    existing_type=sa.VARCHAR(length=120),
                    nullable=False)
    op.create_unique_constraint(None, 'Venue', ['name'])
def upgrade():
    op.create_unique_constraint(UNIQUE_NAME, TABLE_NAME,
                                ['router_id', 'l3_agent_id'])
def upgrade():
    op.create_unique_constraint('sec_base_cluster_id_username_sec_type_key',
                                model.SecurityBase.__tablename__,
                                ['cluster_id', 'username', 'sec_type'])

    op.create_table(
        model.NTLM.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id'),
                  primary_key=True))

    op.create_table(
        model.APIKeySecurity.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id'),
                  primary_key=True))

    op.create_table(
        model.XPathSecurity.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id'),
                  primary_key=True),
        sa.Column('username_expr', sa.String(200), nullable=False),
        sa.Column('password_expr', sa.String(200), nullable=True),
    )

    add_col(model.HTTPSOAP.__tablename__,
            sa.Column('serialization_type', sa.String(200), nullable=True))
    alter_column_nullable_false(model.HTTPSOAP.__tablename__,
                                'serialization_type',
                                HTTP_SOAP_SERIALIZATION_TYPE.SUDS.id,
                                sa.String(200))

    add_col(model.HTTPSOAP.__tablename__,
            sa.Column('timeout', sa.Integer(), nullable=True))
    alter_column_nullable_false(model.HTTPSOAP.__tablename__, 'timeout',
                                MISC.DEFAULT_HTTP_TIMEOUT, sa.Integer())

    op.create_table(
        model.AWSSecurity.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id'),
                  primary_key=True))

    op.execute(CreateSequence(sa.Sequence('deliv_def_seq')))

    op.execute(CreateSequence(sa.Sequence('deliv_seq')))

    op.execute(CreateSequence(sa.Sequence('deliv_payl_seq')))

    op.execute(CreateSequence(sa.Sequence('msg_ns_seq')))

    op.execute(CreateSequence(sa.Sequence('http_soap_audit_seq')))
    op.create_table(
        model.HTTSOAPAudit.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('http_soap_audit_seq'),
                  primary_key=True),
        sa.Column('name', sa.String(200), nullable=False, index=True),
        sa.Column('cid', sa.String(200), nullable=False, index=True),
        sa.Column('transport', sa.String(200), nullable=False, index=True),
        sa.Column('connection', sa.String(200), nullable=False, index=True),
        sa.Column('req_time', sa.DateTime(), nullable=False),
        sa.Column('resp_time', sa.DateTime(), nullable=True),
        sa.Column('user_token', sa.String(200), nullable=True, index=True),
        sa.Column('invoke_ok', sa.Boolean, nullable=True),
        sa.Column('auth_ok', sa.Boolean, nullable=True),
        sa.Column('remote_addr', sa.String(200), nullable=False, index=True),
        sa.Column('req_headers', sa.LargeBinary(), nullable=True),
        sa.Column('req_payload', sa.LargeBinary(), nullable=True),
        sa.Column('resp_headers', sa.LargeBinary(), nullable=True),
        sa.Column('resp_payload', sa.LargeBinary(), nullable=True),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('conn_id',
                  sa.Integer(),
                  sa.ForeignKey('http_soap.id', ondelete='CASCADE'),
                  nullable=False),
    )

    op.execute(CreateSequence(sa.Sequence('htp_sp_ad_rpl_p_jp_seq')))
    op.create_table(
        model.HTTSOAPAuditReplacePatternsJSONPointer.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('htp_sp_ad_rpl_p_jp_seq'),
                  primary_key=True),
        sa.Column('conn_id',
                  sa.Integer,
                  sa.ForeignKey('http_soap.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('pattern_id',
                  sa.Integer,
                  sa.ForeignKey('msg_json_pointer.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('cluster_id',
                  sa.Integer,
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False), sa.UniqueConstraint('conn_id',
                                                       'pattern_id'))

    op.execute(CreateSequence(sa.Sequence('htp_sp_ad_rpl_p_xp_seq')))
    op.create_table(
        model.HTTSOAPAuditReplacePatternsXPath.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('htp_sp_ad_rpl_p_xp_seq'),
                  primary_key=True),
        sa.Column('conn_id',
                  sa.Integer(),
                  sa.ForeignKey('http_soap.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('pattern_id',
                  sa.Integer(),
                  sa.ForeignKey('msg_xpath.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False), sa.UniqueConstraint('conn_id',
                                                       'pattern_id'))

    op.execute(CreateSequence(sa.Sequence('pub_sub_topic_seq')))
    op.create_table(
        model.PubSubTopic.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('pub_sub_topic_seq'),
                  primary_key=True),
        sa.Column('name', sa.String(200), nullable=False),
        sa.Column('is_active', sa.Boolean, nullable=False),
        sa.Column('max_depth', sa.Integer(), nullable=False),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False), sa.UniqueConstraint('name', 'cluster_id'))

    op.execute(CreateSequence(sa.Sequence('pub_sub_cons_seq')))
    op.create_table(
        model.PubSubConsumer.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('pub_sub_cons_seq'),
                  primary_key=True),
        sa.Column('is_active', sa.Boolean, nullable=False),
        sa.Column('sub_key', sa.String(200), nullable=False),
        sa.Column('max_backlog', sa.Integer(), nullable=False),
        sa.Column('delivery_mode', sa.String(200), nullable=False),
        sa.Column('callback_id',
                  sa.Integer(),
                  sa.ForeignKey('http_soap.id', ondelete='CASCADE'),
                  nullable=True),
        sa.Column('callback_type',
                  sa.String(20),
                  nullable=True,
                  default=PUB_SUB.CALLBACK_TYPE.OUTCONN_PLAIN_HTTP),
        sa.Column('topic_id',
                  sa.Integer(),
                  sa.ForeignKey('pub_sub_topic.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('sec_def_id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False),
        sa.UniqueConstraint('sec_def_id', 'topic_id', 'cluster_id'))

    op.create_table(
        model.PubSubProducer.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('pub_sub_cons_seq'),
                  primary_key=True),
        sa.Column('is_active', sa.Boolean, nullable=False),
        sa.Column('topic_id',
                  sa.Integer(),
                  sa.ForeignKey('pub_sub_topic.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('sec_def_id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False),
        sa.UniqueConstraint('sec_def_id', 'topic_id', 'cluster_id'))

    op.execute(CreateSequence(sa.Sequence('os_swift_seq')))
    op.create_table(
        model.OpenStackSwift.__tablename__,
        sa.Column('id',
                  sa.Integer(),
                  sa.Sequence('os_swift_seq'),
                  primary_key=True),
        sa.Column('name', sa.String(200), nullable=False),
        sa.Column('is_active', sa.Boolean, nullable=False),
        sa.Column('auth_url', sa.String(200), nullable=False),
        sa.Column('auth_version',
                  sa.String(200),
                  nullable=False,
                  default=CLOUD.OPENSTACK.SWIFT.DEFAULTS.AUTH_VERSION),
        sa.Column('user', sa.String(200), nullable=True),
        sa.Column('key', sa.String(200), nullable=True),
        sa.Column('retries',
                  sa.Integer,
                  nullable=False,
                  default=CLOUD.OPENSTACK.SWIFT.DEFAULTS.RETRIES),
        sa.Column('is_snet', sa.Boolean, nullable=False),
        sa.Column('starting_backoff',
                  sa.Integer(),
                  nullable=False,
                  default=CLOUD.OPENSTACK.SWIFT.DEFAULTS.BACKOFF_STARTING),
        sa.Column('max_backoff',
                  sa.Integer(),
                  nullable=False,
                  default=CLOUD.OPENSTACK.SWIFT.DEFAULTS.BACKOFF_MAX),
        sa.Column('tenant_name', sa.String(200), nullable=True),
        sa.Column('should_validate_cert', sa.Boolean, nullable=False),
        sa.Column('cacert', sa.String(200), nullable=True),
        sa.Column('should_retr_ratelimit', sa.Boolean, nullable=False),
        sa.Column('needs_tls_compr', sa.Boolean, nullable=False),
        sa.Column('custom_options', sa.String(2000), nullable=True),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False), sa.UniqueConstraint('name', 'cluster_id'))

    op.execute(CreateSequence(sa.Sequence('aws_s3_seq')))
    op.create_table(
        model.AWSS3.__tablename__,
        sa.Column('id',
                  sa.Integer,
                  sa.Sequence('aws_s3_seq'),
                  primary_key=True),
        sa.Column('name', sa.String(200), nullable=False),
        sa.Column('is_active', sa.Boolean, nullable=False),
        sa.Column('pool_size',
                  sa.Integer(),
                  nullable=False,
                  default=CLOUD.AWS.S3.DEFAULTS.POOL_SIZE),
        sa.Column('address',
                  sa.String(200),
                  nullable=False,
                  default=CLOUD.AWS.S3.DEFAULTS.ADDRESS),
        sa.Column('debug_level',
                  sa.Integer,
                  nullable=False,
                  default=CLOUD.AWS.S3.DEFAULTS.DEBUG_LEVEL),
        sa.Column('suppr_cons_slashes',
                  sa.Boolean,
                  nullable=False,
                  default=True),
        sa.Column('content_type',
                  sa.String(200),
                  nullable=False,
                  default=CLOUD.AWS.S3.DEFAULTS.CONTENT_TYPE),
        sa.Column('metadata_', sa.String(2000), nullable=True),
        sa.Column('bucket', sa.String(2000), nullable=True),
        sa.Column('encrypt_at_rest', sa.Boolean, nullable=False,
                  default=False),
        sa.Column('storage_class',
                  sa.String(200),
                  nullable=False,
                  default=CLOUD.AWS.S3.STORAGE_CLASS.DEFAULT),
        sa.Column('security_id',
                  sa.Integer(),
                  sa.ForeignKey('sec_base.id', ondelete='CASCADE'),
                  nullable=False),
        sa.Column('cluster_id',
                  sa.Integer(),
                  sa.ForeignKey('cluster.id', ondelete='CASCADE'),
                  nullable=False), sa.UniqueConstraint('name', 'cluster_id'))

    op.alter_column(model.Cluster.__tablename__, 'odb_host', nullable=True)
    op.alter_column(model.Cluster.__tablename__, 'odb_port', nullable=True)
    op.alter_column(model.Cluster.__tablename__, 'odb_user', nullable=True)
    op.alter_column(model.Cluster.__tablename__, 'odb_db_name', nullable=True)
Exemple #53
0
def downgrade():
    op.drop_column('device', 'fw_version')
    op.drop_constraint('device_uix_1', 'device', type_='unique')
    op.create_unique_constraint('device_uix_1', 'device', ['vendor_id',
            'device_id', 'subsys_device_id', 'subsys_vendor_id', 'bus',
            'driver', 'description', 'device_class_id'])
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(None, 'Login', ['username'])
    op.create_unique_constraint(None, 'Role', ['role_name'])
Exemple #55
0
def downgrade():
    op.create_unique_constraint("uq_registration_ref", "register", ["registration_no", "date"])
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint(op.f("uq_user_nickname"), "user", ["nickname"])
Exemple #57
0
def upgrade():
    # Role
    __tablename__ = '%s_%s' % (__app_label__, 'role')
    op.create_table(__tablename__,
        Column('uuid', UUID, server_default=func.uuid_generate_v4()),
        Column('title', String(96), nullable=False),
        PrimaryKeyConstraint('uuid',
            name = '__'.join(['pk', __tablename__])),)
    op.create_unique_constraint(
        '__'.join(['uq', __tablename__, 'title']),
                         __tablename__,('title',))

    # User
    __tablename__ = '%s_%s' % (__app_label__, 'user')
    op.create_table(__tablename__,
        Column('uuid', UUID, server_default=func.uuid_generate_v4()),
        Column('login', String(48), nullable=False),
        Column('password', String(255), server_default=u'', nullable=False),
        Column('name', String(255), server_default=u'', nullable=False),
        Column('active', Boolean, server_default=expression.false(), nullable=False),
        Column('confirmed_at', DateTime, nullable=True),
        PrimaryKeyConstraint('uuid',
            name = '__'.join(['pk', __tablename__])),)
    op.create_unique_constraint(
        '__'.join(['uq', __tablename__, 'login']),
                         __tablename__,('login',))

    # Email
    __tablename__ = '%s_%s' % (__app_label__, 'email')
    op.create_table(__tablename__,
        Column('address', String(255), nullable=False),
        Column('user_uuid', UUID, nullable=False),
        Column('notification', Boolean,
            server_default = expression.true(),
            nullable       = False),
        Column('secure_reset', Boolean,
            server_default = expression.true(),
            nullable       = False),
        PrimaryKeyConstraint('address',
            name = '__'.join(['pk', __tablename__])),)
    op.create_foreign_key(
        '__'.join(['fk', __tablename__, 'user']),
                         __tablename__,
        '%s_%s' % (__app_label__, 'user'),
        ('user_uuid',),
        (     'uuid',))
    op.create_index(
        '__'.join(['ix', __tablename__, 'user_uuid']),
                         __tablename__,
        ('user_uuid',))
    op.create_index(
        '__'.join(['ix', __tablename__, 'notification']),
                         __tablename__,
        ('notification',))

    # UserRole
    __tablename__ = '%s_%s' % (__app_label__, 'user_role')
    op.create_table(__tablename__,
        Column('user_uuid', UUID, nullable=False),
        Column('role_uuid', UUID, nullable=False),
        PrimaryKeyConstraint('user_uuid', 'role_uuid',
            name = '__'.join(['pk', __tablename__])),)
    op.create_foreign_key(
        '__'.join(['fk', __tablename__, 'role']),
                         __tablename__,
        '%s_%s' % (__app_label__, 'role'),
        ('role_uuid',),
        (     'uuid',))
    op.create_foreign_key(
        '__'.join(['fk', __tablename__, 'user']),
                         __tablename__,
        '%s_%s' % (__app_label__, 'user'),
        ('user_uuid',),
        (     'uuid',))
Exemple #58
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'project',
        sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True))
    op.create_unique_constraint(u'project_name_key', 'project', ['name'])
def upgrade_data_broker():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('tas_lookup_sanity_check', 'tas_lookup', ['account_num', 'allocation_transfer_agency', 'agency_identifier', 'beginning_period_of_availability', 'ending_period_of_availability', 'availability_type_code', 'main_account_code', 'sub_account_code'])
Exemple #60
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('recipes_recipe_url_key', 'recipes', ['recipe_url'])
    op.create_unique_constraint('recipes_image_url_key', 'recipes', ['image_url'])