Ejemplo n.º 1
0
def upgrade():
    attribute_value_type = postgresql.ENUM('percent',
                                           'count',
                                           name='attribute_value_type')
    attribute_value_type.create(op.get_bind())

    op.create_table(
        'email_authentication_codes',
        sa.Column('email_authentication_id',
                  sa.Integer(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('authentication_code', sa.Integer(), nullable=False),
        sa.Column('expiration_timestamp', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.user_id'],
        ), sa.PrimaryKeyConstraint('email_authentication_id'))
    op.create_table(
        'geographic_dataset_views',
        sa.Column('geographic_dataset_view_id', sa.Integer(), nullable=False),
        sa.Column('geographic_dataset_id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('ip_address', sa.Text(), nullable=False),
        sa.Column('created_at',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=True),
        sa.Column('updated_at',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['geographic_dataset_id'],
            ['maps.map_id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.user_id'],
        ), sa.PrimaryKeyConstraint('geographic_dataset_view_id'))
    op.create_table(
        'map_views', sa.Column('map_view_id', sa.Integer(), nullable=False),
        sa.Column('map_id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('ip_address', sa.Text(), nullable=False),
        sa.Column('created_at',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=True),
        sa.Column('updated_at',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['map_id'],
            ['maps.map_id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.user_id'],
        ), sa.PrimaryKeyConstraint('map_view_id'))
    op.add_column('geo_codes', sa.Column('fips_code', sa.Text(),
                                         nullable=True))
    op.add_column(
        'geographic_attributes',
        sa.Column('attribute_value_type',
                  sa.Enum('percent', 'count', name='attribute_value_type'),
                  nullable=False))
    op.add_column(
        'geographic_attributes',
        sa.Column('attribute_year', sa.SmallInteger(), nullable=True))
    op.add_column(
        'geographic_datasets',
        sa.Column('display_by_default',
                  sa.Boolean(),
                  server_default=sa.text('false'),
                  nullable=True))
    op.add_column('geographic_datasets',
                  sa.Column('organization', sa.Text(), nullable=True))
    op.add_column('geographic_datasets',
                  sa.Column('url', sa.Text(), nullable=True))
    op.add_column('maps',
                  sa.Column('map_thumbnail_link', sa.Text(), nullable=True))
    op.add_column(
        'maps',
        sa.Column('updated_at',
                  sa.DateTime(),
                  server_default=sa.text('now()'),
                  nullable=True))
Ejemplo n.º 2
0
def upgrade():
    relationship = postgresql.ENUM('self_participant', 'self_guardian', 'dependent', name='relationship')
    relationship.create(op.get_bind())
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user_participant', sa.Column('relationship', sa.Enum('self_participant', 'self_guardian', 'dependent', name='relationship'), nullable=True))
Ejemplo n.º 3
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    scrape_targets_tbl = op.create_table(
        'scrape_targets', sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('site_name', sa.Text(), nullable=False),
        sa.Column('artist_name', sa.Text(), nullable=False),
        sa.Column('uploadeh', sa.Boolean(), nullable=True),
        sa.Column('last_fetched', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('site_name', 'artist_name'))
    op.create_index(op.f('ix_scrape_targets_uploadeh'),
                    'scrape_targets', ['uploadeh'],
                    unique=False)

    art_item_tbl = op.create_table(
        'art_item', sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('state',
                  postgresql.ENUM('new',
                                  'fetching',
                                  'processing',
                                  'complete',
                                  'error',
                                  'removed',
                                  'disabled',
                                  'specialty_deferred',
                                  'specialty_ready',
                                  'not_set',
                                  name='dlstate_enum'),
                  nullable=False),
        sa.Column('errno', sa.Integer(), nullable=True),
        sa.Column('artist_id', sa.BigInteger(), nullable=True),
        sa.Column('release_meta', sa.Text(), nullable=False),
        sa.Column('fetchtime', sa.DateTime(), nullable=True),
        sa.Column('addtime', sa.DateTime(), nullable=True),
        sa.Column('title', sa.Text(), nullable=True),
        sa.Column('content', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(
            ['artist_id'],
            ['scrape_targets.id'],
        ), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('artist_id', 'release_meta'))
    op.create_index(op.f('ix_art_item_id'), 'art_item', ['id'], unique=False)
    op.create_index(op.f('ix_art_item_state'),
                    'art_item', ['state'],
                    unique=False)

    art_file_tbl = op.create_table(
        'art_file', sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('item_id', sa.BigInteger(), nullable=False),
        sa.Column('seqnum', sa.Integer(), nullable=False),
        sa.Column('filename', sa.Text(), nullable=True),
        sa.Column('fspath', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(
            ['item_id'],
            ['art_item.id'],
        ), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('item_id', 'seqnum'))
    op.create_index(op.f('ix_art_file_id'), 'art_file', ['id'], unique=False)

    art_tag_tbl = op.create_table(
        'art_tag', sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('item_id', sa.BigInteger(), nullable=False),
        sa.Column('tag', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(
            ['item_id'],
            ['art_item.id'],
        ), sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('item_id', 'tag'))
    op.create_index(op.f('ix_art_tag_id'), 'art_tag', ['id'], unique=False)

    ##########################################################################################
    ##########################################################################################

    conn = op.get_bind()
    res = conn.execute('''
            SELECT
             tablename
            FROM
             pg_catalog.pg_tables
            WHERE
             schemaname != 'pg_catalog'
            AND schemaname != 'information_schema';''')
    have = res.fetchall()
    have = [tmp for tmp, in have]
    print("Current tables:")
    print(have)
    print("Have old-data tables:", 'retrieved_pages' in have
          or 'siteartistnames' in have)
    print("sys.argv:", sys.argv)
    if 'siteartistnames' in have:
        print("Have:", have)
        migrate_data(scrape_targets_tbl, art_item_tbl, art_file_tbl,
                     art_tag_tbl)
    elif 'retrieved_pages' in have:
        print("Have:", have)
        migrate_data(scrape_targets_tbl, art_item_tbl, art_file_tbl,
                     art_tag_tbl)
    elif ('retrieved_pages', ) in have:
        print("Have:", have)
        migrate_data(scrape_targets_tbl, art_item_tbl, art_file_tbl,
                     art_tag_tbl)
    elif "force-migrate" in sys.argv:
        print("Forcing a values-present migrations")
        migrate_data(scrape_targets_tbl, art_item_tbl, art_file_tbl,
                     art_tag_tbl)

    ##########################################################################################
    ##########################################################################################

    print("Migration complete!")
Ejemplo n.º 4
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('event_partner_associations',
                    sa.Column('event_id', sa.Integer(), nullable=False),
                    sa.Column('partner_id', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['event_id'],
                        ['events.id'],
                    ),
                    sa.ForeignKeyConstraint(
                        ['partner_id'],
                        ['partners.id'],
                    ), sa.PrimaryKeyConstraint('event_id', 'partner_id'))
    op.add_column('partners',
                  sa.Column('phone_number', sa.String(), nullable=True))
    op.drop_column('partners', 'phone')
    op.alter_column('volunteers',
                    'additional_skills',
                    existing_type=sa.VARCHAR(),
                    nullable=True)
    op.alter_column('volunteers',
                    'children_work_experience',
                    existing_type=sa.TEXT(),
                    nullable=True)
    op.alter_column('volunteers',
                    'cloth_size',
                    existing_type=postgresql.ENUM('XS',
                                                  'S',
                                                  'M',
                                                  'L',
                                                  'XL',
                                                  'XXL',
                                                  name='clothsize'),
                    nullable=True)
    op.alter_column('volunteers',
                    'email',
                    existing_type=sa.VARCHAR(),
                    nullable=True)
    op.alter_column('volunteers',
                    'interested_in_projects',
                    existing_type=sa.TEXT(),
                    nullable=True)
    op.alter_column('volunteers',
                    'known_by_id',
                    existing_type=sa.INTEGER(),
                    nullable=True)
    op.alter_column('volunteers',
                    'phone_number',
                    existing_type=sa.VARCHAR(length=20),
                    nullable=True)
    op.alter_column('volunteers',
                    'reasons_to_work',
                    existing_type=sa.VARCHAR(),
                    nullable=True)
    op.alter_column('volunteers',
                    'volunteer_id',
                    existing_type=sa.VARCHAR(),
                    nullable=True)
    op.alter_column('volunteers',
                    'work',
                    existing_type=sa.VARCHAR(),
                    nullable=True)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "state_supervision_violation_response_decision_entry",
        sa.Column("state_code", sa.String(length=255), nullable=False),
        sa.Column(
            "decision",
            postgresql.ENUM(
                "CONTINUANCE",
                "DELAYED_ACTION",
                "EXTENSION",
                "REVOCATION",
                "SERVICE_TERMINATION",
                "SUSPENSION",
                name="state_supervision_violation_response_decision",
                create_type=False,
            ),
            nullable=True,
        ),
        sa.Column("decision_raw_text", sa.String(length=255), nullable=True),
        sa.Column(
            "revocation_type",
            postgresql.ENUM(
                "REINCARCERATION",
                "RETURN_TO_SUPERVISION",
                "SHOCK_INCARCERATION",
                "TREATMENT_IN_PRISON",
                name="state_supervision_violation_response_revocation_type",
                create_type=False,
            ),
            nullable=True,
        ),
        sa.Column("revocation_type_raw_text",
                  sa.String(length=255),
                  nullable=True),
        sa.Column(
            "supervision_violation_response_decision_entry_id",
            sa.Integer(),
            nullable=False,
        ),
        sa.Column("supervision_violation_response_id",
                  sa.Integer(),
                  nullable=True),
        sa.Column("person_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["person_id"],
            ["state_person.person_id"],
            initially="DEFERRED",
            deferrable=True,
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_id"],
            [
                "state_supervision_violation_response.supervision_violation_response_id"
            ],
        ),
        sa.PrimaryKeyConstraint(
            "supervision_violation_response_decision_entry_id"),
    )
    op.create_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_state_code"),
        "state_supervision_violation_response_decision_entry",
        ["state_code"],
        unique=False,
    )
    op.create_table(
        "state_supervision_violation_response_decision_entry_history",
        sa.Column("valid_from", sa.DateTime(), nullable=False),
        sa.Column("valid_to", sa.DateTime(), nullable=True),
        sa.Column("state_code", sa.String(length=255), nullable=False),
        sa.Column(
            "decision",
            postgresql.ENUM(
                "CONTINUANCE",
                "DELAYED_ACTION",
                "EXTENSION",
                "REVOCATION",
                "SERVICE_TERMINATION",
                "SUSPENSION",
                name="state_supervision_violation_response_decision",
                create_type=False,
            ),
            nullable=True,
        ),
        sa.Column("decision_raw_text", sa.String(length=255), nullable=True),
        sa.Column(
            "revocation_type",
            postgresql.ENUM(
                "REINCARCERATION",
                "RETURN_TO_SUPERVISION",
                "SHOCK_INCARCERATION",
                "TREATMENT_IN_PRISON",
                name="state_supervision_violation_response_revocation_type",
                create_type=False,
            ),
            nullable=True,
        ),
        sa.Column("revocation_type_raw_text",
                  sa.String(length=255),
                  nullable=True),
        sa.Column(
            "supervision_violation_response_decision_entry_history_id",
            sa.Integer(),
            nullable=False,
        ),
        sa.Column(
            "supervision_violation_response_decision_entry_id",
            sa.Integer(),
            nullable=False,
        ),
        sa.Column("supervision_violation_response_id",
                  sa.Integer(),
                  nullable=True),
        sa.Column("person_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ["person_id"],
            ["state_person.person_id"],
            initially="DEFERRED",
            deferrable=True,
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_decision_entry_id"],
            [
                "state_supervision_violation_response_decision_entry.supervision_violation_response_decision_entry_id"
            ],
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_id"],
            [
                "state_supervision_violation_response.supervision_violation_response_id"
            ],
        ),
        sa.PrimaryKeyConstraint(
            "supervision_violation_response_decision_entry_history_id"),
    )
    op.create_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_history_state_code"
          ),
        "state_supervision_violation_response_decision_entry_history",
        ["state_code"],
        unique=False,
    )
    op.create_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_history_supervision_violation_response_decision_entry_id"
          ),
        "state_supervision_violation_response_decision_entry_history",
        ["supervision_violation_response_decision_entry_id"],
        unique=False,
    )
    op.drop_index(
        "ix_state_supervision_violation_response_decision_type_e_2fc7",
        table_name=
        "state_supervision_violation_response_decision_type_entry_histor",
    )
    op.drop_index(
        "ix_state_supervision_violation_response_decision_type_e_ba56",
        table_name=
        "state_supervision_violation_response_decision_type_entry_histor",
    )
    op.drop_table(
        "state_supervision_violation_response_decision_type_entry_histor")
    op.drop_index(
        "ix_state_supervision_violation_response_decision_type_e_a335",
        table_name="state_supervision_violation_response_decision_type_entry",
    )
    op.drop_table("state_supervision_violation_response_decision_type_entry")
Ejemplo n.º 6
0
def test_should_postgresql_enum_convert():
    assert_column_conversion(postgresql.ENUM(), graphene.String)
Ejemplo n.º 7
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "alternative_name",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column(
            "type",
            postgresql.ENUM(
                "country",
                "region",
                "area",
                "locality",
                "district",
                "street",
                "house",
                name="address_type_enum",
            ),
            nullable=False,
        ),
        sa.Column("related_id", sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__alternative_name")),
    )
    op.create_index(
        op.f("ix__alternative_name__related_id"),
        "alternative_name",
        ["related_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix__alternative_name__type"),
        "alternative_name",
        ["type"],
        unique=False,
    )
    op.create_table(
        "country",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=64), nullable=False),
        sa.Column("code", sa.String(length=2), nullable=False),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__country")),
        sa.UniqueConstraint("code", name=op.f("uq__country__code")),
    )
    op.create_table(
        "region",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("country_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=False),
        sa.Column("geoip_name", sa.String(length=128), nullable=False),
        sa.ForeignKeyConstraint(
            ["country_id"],
            ["country.id"],
            name=op.f("fk__region__country_id__country"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__region")),
    )
    op.create_index(op.f("ix__region__country_id"),
                    "region", ["country_id"],
                    unique=False)
    op.create_table(
        "area",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("region_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=False),
        sa.ForeignKeyConstraint(
            ["region_id"],
            ["region.id"],
            name=op.f("fk__area__region_id__region"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__area")),
    )
    op.create_index(op.f("ix__area__region_id"),
                    "area", ["region_id"],
                    unique=False)
    op.create_table(
        "locality",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("area_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=False),
        sa.ForeignKeyConstraint(["area_id"], ["area.id"],
                                name=op.f("fk__locality__area_id__area")),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__locality")),
    )
    op.create_index(op.f("ix__locality__area_id"),
                    "locality", ["area_id"],
                    unique=False)
    op.create_table(
        "district",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("locality_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=False),
        sa.ForeignKeyConstraint(
            ["locality_id"],
            ["locality.id"],
            name=op.f("fk__district__locality_id__locality"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__district")),
    )
    op.create_index(
        op.f("ix__district__locality_id"),
        "district",
        ["locality_id"],
        unique=False,
    )
    op.create_table(
        "street",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("district_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=False),
        sa.ForeignKeyConstraint(
            ["district_id"],
            ["district.id"],
            name=op.f("fk__street__district_id__district"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__street")),
    )
    op.create_index(
        op.f("ix__street__district_id"),
        "street",
        ["district_id"],
        unique=False,
    )
    op.create_table(
        "house",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("street_id", sa.Integer(), nullable=False),
        sa.Column("index", sa.String(length=8), nullable=False),
        sa.Column("number", sa.String(length=32), nullable=False),
        sa.ForeignKeyConstraint(
            ["street_id"],
            ["street.id"],
            name=op.f("fk__house__street_id__street"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk__house")),
    )
    op.create_index(op.f("ix__house__index"), "house", ["index"], unique=False)
    op.create_index(op.f("ix__house__street_id"),
                    "house", ["street_id"],
                    unique=False)
def create_deployment_groups_table():
    op.create_table(
        'deployment_groups',
        sa.Column('_storage_id',
                  sa.Integer(),
                  autoincrement=True,
                  nullable=False), sa.Column('id', sa.Text(), nullable=True),
        sa.Column('visibility',
                  postgresql.ENUM('private',
                                  'tenant',
                                  'global',
                                  name='visibility_states',
                                  create_type=False),
                  nullable=True),
        sa.Column('created_at', UTCDateTime(), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('_default_blueprint_fk', sa.Integer(), nullable=True),
        sa.Column('default_inputs', JSONString(), nullable=True),
        sa.Column('_tenant_id', sa.Integer(), nullable=False),
        sa.Column('_creator_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['_default_blueprint_fk'], ['blueprints._storage_id'],
            name=op.f('deployment_groups__default_blueprint_fk_fkey'),
            ondelete='SET NULL'),
        sa.ForeignKeyConstraint(
            ['_creator_id'], ['users.id'],
            name=op.f('deployment_groups__creator_id_fkey'),
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_tenant_id'], ['tenants.id'],
                                name=op.f('deployment_groups__tenant_id_fkey'),
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('_storage_id',
                                name=op.f('deployment_groups_pkey')))
    op.create_index(op.f('deployment_groups__default_blueprint_fk_idx'),
                    'deployment_groups', ['_default_blueprint_fk'],
                    unique=False)
    op.create_index(op.f('deployment_groups__creator_id_idx'),
                    'deployment_groups', ['_creator_id'],
                    unique=False)
    op.create_index(op.f('deployment_groups__tenant_id_idx'),
                    'deployment_groups', ['_tenant_id'],
                    unique=False)
    op.create_index(op.f('deployment_groups_created_at_idx'),
                    'deployment_groups', ['created_at'],
                    unique=False)
    op.create_index(op.f('deployment_groups_id_idx'),
                    'deployment_groups', ['id'],
                    unique=False)
    op.create_index(op.f('deployment_groups_visibility_idx'),
                    'deployment_groups', ['visibility'],
                    unique=False)
    op.create_table(
        'deployment_groups_deployments',
        sa.Column('deployment_group_id', sa.Integer(), nullable=True),
        sa.Column('deployment_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['deployment_group_id'], ['deployment_groups._storage_id'],
            name=op.f(
                'deployment_groups_deployments_deployment_grou_id_fkey')),
        sa.ForeignKeyConstraint(
            ['deployment_id'], ['deployments._storage_id'],
            name=op.f('deployment_groups_deployments_deployment_id_fkey')))
Ejemplo n.º 9
0
def upgrade():
    status = postgresql.ENUM('OTHER', 'PACKAGE_EDIT', 'PACKAGE_APPROVAL', 'NEW_THREAD', 'NEW_REVIEW', 'THREAD_REPLY', 'MAINTAINER', 'EDITOR_ALERT', 'EDITOR_MISC', name='notificationtype')
    status.create(op.get_bind())

    op.add_column('notification', sa.Column('emailed', sa.Boolean(), nullable=False, server_default="true"))
    op.add_column('notification', sa.Column('type', sa.Enum('OTHER', 'PACKAGE_EDIT', 'PACKAGE_APPROVAL', 'NEW_THREAD', 'NEW_REVIEW', 'THREAD_REPLY', 'MAINTAINER', 'EDITOR_ALERT', 'EDITOR_MISC', name='notificationtype'), nullable=False, server_default="OTHER"))
def upgrade():
    # Add new supervision period termination values
    op.execute(
        'ALTER TYPE state_supervision_period_termination_reason RENAME TO state_supervision_period_termination_reason_old;'
    )
    sa.Enum(*new_supervision_termination_values,
            name='state_supervision_period_termination_reason').create(
                bind=op.get_bind())
    op.alter_column(
        'state_supervision_period',
        column_name='termination_reason',
        type_=sa.Enum(*new_supervision_termination_values,
                      name='state_supervision_period_termination_reason'),
        postgresql_using=
        'termination_reason::text::state_supervision_period_termination_reason'
    )
    op.alter_column(
        'state_supervision_period_history',
        column_name='termination_reason',
        type_=sa.Enum(*new_supervision_termination_values,
                      name='state_supervision_period_termination_reason'),
        postgresql_using=
        'termination_reason::text::state_supervision_period_termination_reason'
    )
    op.execute('DROP TYPE state_supervision_period_termination_reason_old;')

    # Add new incarceration period admission values
    op.execute(
        'ALTER TYPE state_incarceration_period_admission_reason RENAME TO state_incarceration_period_admission_reason_old;'
    )
    sa.Enum(*new_incarceration_admission_values,
            name='state_incarceration_period_admission_reason').create(
                bind=op.get_bind())
    op.alter_column(
        'state_incarceration_period',
        column_name='admission_reason',
        type_=sa.Enum(*new_incarceration_admission_values,
                      name='state_incarceration_period_admission_reason'),
        postgresql_using=
        'admission_reason::text::state_incarceration_period_admission_reason')
    op.alter_column(
        'state_incarceration_period_history',
        column_name='admission_reason',
        type_=sa.Enum(*new_incarceration_admission_values,
                      name='state_incarceration_period_admission_reason'),
        postgresql_using=
        'admission_reason::text::state_incarceration_period_admission_reason')
    op.execute('DROP TYPE state_incarceration_period_admission_reason_old;')

    # Add new incarceration period specialized purpose for incarceration
    op.execute(
        'ALTER TYPE state_specialized_purpose_for_incarceration RENAME TO state_specialized_purpose_for_incarceration_old;'
    )
    sa.Enum(*new_specialized_purpose_for_incarceration_values,
            name='state_specialized_purpose_for_incarceration').create(
                bind=op.get_bind())
    op.alter_column(
        'state_incarceration_period',
        column_name='specialized_purpose_for_incarceration',
        type_=sa.Enum(*new_specialized_purpose_for_incarceration_values,
                      name='state_specialized_purpose_for_incarceration'),
        postgresql_using=
        'specialized_purpose_for_incarceration::text::state_specialized_purpose_for_incarceration'
    )
    op.alter_column(
        'state_incarceration_period_history',
        column_name='specialized_purpose_for_incarceration',
        type_=sa.Enum(*new_specialized_purpose_for_incarceration_values,
                      name='state_specialized_purpose_for_incarceration'),
        postgresql_using=
        'specialized_purpose_for_incarceration::text::state_specialized_purpose_for_incarceration'
    )
    op.execute('DROP TYPE state_specialized_purpose_for_incarceration_old;')

    # Add StateSupervisionPeriod.supervision_period_supervision_type and enum
    state_supervision_period_supervision_type = postgresql.ENUM(
        'EXTERNAL_UNKNOWN',
        'INTERNAL_UNKNOWN',
        'INVESTIGATION',
        'PAROLE',
        'PROBATION',
        'DUAL',
        name='state_supervision_period_supervision_type')
    state_supervision_period_supervision_type.create(op.get_bind())
    op.add_column(
        'state_supervision_period',
        sa.Column('supervision_period_supervision_type',
                  sa.Enum('EXTERNAL_UNKNOWN',
                          'INTERNAL_UNKNOWN',
                          'INVESTIGATION',
                          'PAROLE',
                          'PROBATION',
                          'DUAL',
                          name='state_supervision_period_supervision_type'),
                  nullable=True))
    op.add_column(
        'state_supervision_period',
        sa.Column('supervision_period_supervision_type_raw_text',
                  sa.String(length=255),
                  nullable=True))
    op.add_column(
        'state_supervision_period_history',
        sa.Column('supervision_period_supervision_type',
                  sa.Enum('EXTERNAL_UNKNOWN',
                          'INTERNAL_UNKNOWN',
                          'INVESTIGATION',
                          'PAROLE',
                          'PROBATION',
                          'DUAL',
                          name='state_supervision_period_supervision_type'),
                  nullable=True))
    op.add_column(
        'state_supervision_period_history',
        sa.Column('supervision_period_supervision_type_raw_text',
                  sa.String(length=255),
                  nullable=True))
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from sqlalchemy.sql import table, column

from cloudify.models_states import VisibilityState, BlueprintUploadState
from manager_rest.storage.models_base import JSONString, UTCDateTime

# revision identifiers, used by Alembic.
revision = '9d261e90b1f3'
down_revision = '5ce2b0cbb6f3'
branch_labels = None
depends_on = None

VISIBILITY_ENUM = postgresql.ENUM(*VisibilityState.STATES,
                                  name='visibility_states',
                                  create_type=False)

config_table = table(
    'config',
    column('name', sa.Text),
    column('value', JSONString()),
    column('schema', JSONString()),
    column('is_editable', sa.Boolean),
    column('updated_at', UTCDateTime()),
    column('scope', sa.Text),
)

NEW_LDAP_CONFIG_ENTRIES = [
    'ldap_group_members_filter',
    'ldap_attribute_group_membership',
def downgrade():
    # Remove new supervision period termination values
    op.execute(
        'ALTER TYPE state_supervision_period_termination_reason RENAME TO state_supervision_period_termination_reason_old;'
    )
    sa.Enum(*old_supervision_termination_values,
            name='state_supervision_period_termination_reason').create(
                bind=op.get_bind())
    op.alter_column(
        'state_supervision_period',
        column_name='termination_reason',
        type_=sa.Enum(*old_supervision_termination_values,
                      name='state_supervision_period_termination_reason'),
        postgresql_using=
        'termination_reason::text::state_supervision_period_termination_reason'
    )
    op.alter_column(
        'state_supervision_period_history',
        column_name='termination_reason',
        type_=sa.Enum(*old_supervision_termination_values,
                      name='state_supervision_period_termination_reason'),
        postgresql_using=
        'termination_reason::text::state_supervision_period_termination_reason'
    )
    op.execute('DROP TYPE state_supervision_period_termination_reason_old;')

    # Remove new incarceration period admission values
    op.execute(
        'ALTER TYPE state_incarceration_period_admission_reason RENAME TO state_incarceration_period_admission_reason_old;'
    )
    sa.Enum(*old_incarceration_admission_values,
            name='state_incarceration_period_admission_reason').create(
                bind=op.get_bind())
    op.alter_column(
        'state_incarceration_period',
        column_name='admission_reason',
        type_=sa.Enum(*old_incarceration_admission_values,
                      name='state_incarceration_period_admission_reason'),
        postgresql_using=
        'admission_reason::text::state_incarceration_period_admission_reason')
    op.alter_column(
        'state_incarceration_period_history',
        column_name='admission_reason',
        type_=sa.Enum(*old_incarceration_admission_values,
                      name='state_incarceration_period_admission_reason'),
        postgresql_using=
        'admission_reason::text::state_incarceration_period_admission_reason')
    op.execute('DROP TYPE state_incarceration_period_admission_reason_old;')

    # Remove new specialized purpose for incarceration values
    op.execute(
        'ALTER TYPE state_specialized_purpose_for_incarceration RENAME TO state_specialized_purpose_for_incarceration_old;'
    )
    sa.Enum(*old_specialized_purpose_for_incarceration_values,
            name='state_specialized_purpose_for_incarceration').create(
                bind=op.get_bind())
    op.alter_column(
        'state_incarceration_period',
        column_name='specialized_purpose_for_incarceration',
        type_=sa.Enum(*old_specialized_purpose_for_incarceration_values,
                      name='state_specialized_purpose_for_incarceration'),
        postgresql_using=
        'specialized_purpose_for_incarceration::text::state_specialized_purpose_for_incarceration'
    )
    op.alter_column(
        'state_incarceration_period_history',
        column_name='specialized_purpose_for_incarceration',
        type_=sa.Enum(*old_specialized_purpose_for_incarceration_values,
                      name='state_specialized_purpose_for_incarceration'),
        postgresql_using=
        'specialized_purpose_for_incarceration::text::state_specialized_purpose_for_incarceration'
    )
    op.execute('DROP TYPE state_specialized_purpose_for_incarceration_old;')

    # Remove StateSupervisionPeriod.supervision_period_supervision_type and enum
    op.drop_column('state_supervision_period_history',
                   'supervision_period_supervision_type_raw_text')
    op.drop_column('state_supervision_period_history',
                   'supervision_period_supervision_type')
    op.drop_column('state_supervision_period',
                   'supervision_period_supervision_type_raw_text')
    op.drop_column('state_supervision_period',
                   'supervision_period_supervision_type')
    state_supervision_period_supervision_type = postgresql.ENUM(
        'EXTERNAL_UNKNOWN',
        'INTERNAL_UNKNOWN',
        'INVESTIGATION',
        'PAROLE',
        'PROBATION',
        'DUAL',
        name='state_supervision_period_supervision_type')
    state_supervision_period_supervision_type.drop(op.get_bind())
Ejemplo n.º 13
0
def downgrade():
    op.drop_column('token', 'token_type')

    tokentype = postgresql.ENUM('LIQUID', 'RESERVE', name='tokentype')
    tokentype.drop(op.get_bind())
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('trailhead', 'capacity_type')
    capacitytype = postgresql.ENUM('Trail', 'Vehicle', name='capacitytype')
    capacitytype.drop(op.get_bind())
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    statetype = postgresql.ENUM('active',
                                'archived',
                                'deleted',
                                name='statetype')
    statetype.create(op.get_bind())
    op.add_column(
        'blocks',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'floors',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'locations',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'offices',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'questions',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'resources',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'rooms',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'users',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
    op.add_column(
        'wings',
        sa.Column('state',
                  sa.Enum('active', 'archived', 'deleted', name='statetype'),
                  nullable=False,
                  server_default='active'))
def downgrade():
    """Downgrade the database to an older revision."""
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    conn.execute("DELETE FROM ecosystems WHERE name = 'nuget'")

    # There's no 'ALTER TYPE enum REMOVE VALUE'
    op.alter_column('package_gh_usage',
                    'ecosystem_backend',
                    existing_type=postgresql.ENUM(
                        'none',
                        'npm',
                        'maven',
                        'pypi',
                        'rubygems',
                        'scm',
                        'crates',
                        'nuget',
                        name='ecosystem_backend_enum'),
                    type_=postgresql.ENUM('none',
                                          'npm',
                                          'maven',
                                          'pypi',
                                          'rubygems',
                                          'scm',
                                          'crates',
                                          name='ecosystem_backend_enum'),
                    existing_nullable=True)
    op.alter_column('ecosystems',
                    '_backend',
                    existing_type=sa.Enum('none',
                                          'npm',
                                          'maven',
                                          'pypi',
                                          'rubygems',
                                          'scm',
                                          'crates',
                                          'nuget',
                                          name='ecosystem_backend_enum'),
                    type_=sa.Enum('none',
                                  'npm',
                                  'maven',
                                  'pypi',
                                  'rubygems',
                                  'scm',
                                  'crates',
                                  name='ecosystem_backend_enum'),
                    existing_nullable=True)
    op.alter_column('component_gh_usage',
                    'ecosystem_backend',
                    existing_type=postgresql.ENUM(
                        'none',
                        'npm',
                        'maven',
                        'pypi',
                        'rubygems',
                        'scm',
                        'crates',
                        'nuget',
                        name='ecosystem_backend_enum'),
                    type_=postgresql.ENUM('none',
                                          'npm',
                                          'maven',
                                          'pypi',
                                          'rubygems',
                                          'scm',
                                          'crates',
                                          name='ecosystem_backend_enum'),
                    existing_nullable=True)
def downgrade():
    op.drop_column("user_balances", "associated_sol_wallets_balance")
    op.drop_column("associated_wallets", "chain")
    wallet_chain = postgresql.ENUM("eth", "sol", name="wallet_chain")
    wallet_chain.drop(op.get_bind())
Ejemplo n.º 18
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'pi_matmul',
        sa.Column('origin',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('version',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('overall_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('exit_code',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_utime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_stime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_maxrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_ixrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_idrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_isrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_minflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_majflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nswap',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_inblock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_oublock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgsnd',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgrcv',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nsignals',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nvcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nivcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('inspection_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('device',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('matrix_size',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dtype',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('reps', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('elapsed',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('rate',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('component',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['inspection_run_id'], ['inspection_run.id'],
                                name='pi_matmul_inspection_run_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='pi_matmul_pkey'))
    op.create_table(
        'pi_conv2d',
        sa.Column('origin',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('version',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('overall_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('exit_code',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_utime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_stime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_maxrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_ixrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_idrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_isrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_minflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_majflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nswap',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_inblock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_oublock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgsnd',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgrcv',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nsignals',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nvcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nivcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('inspection_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('device',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dtype',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('reps', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('data_format',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('batch', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('input_height',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('input_width',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('input_channels',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('filter_height',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('filter_width',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('output_channels',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('strides', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('padding', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('elapsed',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('rate',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('component',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['inspection_run_id'], ['inspection_run.id'],
                                name='pi_conv2d_inspection_run_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='pi_conv2d_pkey'))
    op.create_table(
        'provenance_checker_run',
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('provenance_checker_document_id',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('datetime',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('provenance_checker_version',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('provenance_checker_name',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('origin', sa.TEXT(), autoincrement=False, nullable=True),
        sa.Column('debug', sa.BOOLEAN(), autoincrement=False, nullable=False),
        sa.Column('provenance_checker_error',
                  sa.BOOLEAN(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('duration', sa.INTEGER(), autoincrement=False,
                  nullable=True),
        sa.Column('user_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ['user_software_stack_id'], ['python_software_stack.id'],
            name='provenance_checker_run_user_software_stack_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id',
                                'user_software_stack_id',
                                name='provenance_checker_run_pkey'))
    op.create_table(
        'pi_pybench',
        sa.Column('component',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('origin',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('version',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('overall_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('exit_code',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_utime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_stime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_maxrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_ixrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_idrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_isrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_minflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_majflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nswap',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_inblock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_oublock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgsnd',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgrcv',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nsignals',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nvcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nivcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('inspection_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('rounds', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('built_in_function_calls_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('built_in_method_lookup_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_floats_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_floats_integers_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_integers_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_interned_strings_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_longs_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_strings_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('compare_unicode_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('concat_strings_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('concat_unicode_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('create_instances_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('create_new_instances_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('create_strings_with_concat_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('create_unicode_with_concat_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dict_creation_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dict_with_float_keys_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dict_with_integer_keys_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dict_with_string_keys_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('for_loops_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('if_then_else_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('list_slicing_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('nested_for_loops_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('normal_class_attribute_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('normal_instance_attribute_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_function_calls_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_method_calls_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('recursion_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('second_import_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('second_package_import_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('second_submodule_import_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_complex_arithmetic_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_dict_manipulation_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_float_arithmetic_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_int_float_arithmetic_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_integer_arithmetic_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_list_manipulation_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('simple_long_arithmetic_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('small_lists_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('small_tuples_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('special_class_attribute_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('special_instance_attribute_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('string_mappings_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('string_predicates_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('string_slicing_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('try_except_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('try_raise_except_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('tuple_slicing_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('unicode_mappings_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('unicode_predicates_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('unicode_properties_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('unicode_slicing_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('totals_average',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['inspection_run_id'], ['inspection_run.id'],
                                name='pi_pybench_inspection_run_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='pi_pybench_pkey'))
    op.create_table(
        'pi_conv1d',
        sa.Column('origin',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('version',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('overall_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('exit_code',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_utime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_stime',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_maxrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_ixrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_idrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_isrss',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_minflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_majflt',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nswap',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_inblock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_oublock',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgsnd',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_msgrcv',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nsignals',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nvcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('ru_nivcsw',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('inspection_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('device',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('dtype',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('reps', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('data_format',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.Column('batch', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('input_width',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('input_channels',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('filter_width',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('output_channels',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('strides', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('padding', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('elapsed',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('rate',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=False),
        sa.Column('component',
                  sa.VARCHAR(length=256),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['inspection_run_id'], ['inspection_run.id'],
                                name='pi_conv1d_inspection_run_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='pi_conv1d_pkey'))
    op.create_table(
        'python_requirements',
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('python_package_requirement_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ['python_package_requirement_id'],
            ['python_package_requirement.id'],
            name='python_requirements_python_package_requirement_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['python_software_stack_id'], ['python_software_stack.id'],
            name='python_requirements_python_software_stack_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id',
                                'python_package_requirement_id',
                                'python_software_stack_id',
                                name='python_requirements_pkey'))
    op.create_table(
        'adviser_run',
        sa.Column(
            'id',
            sa.INTEGER(),
            server_default=sa.text("nextval('adviser_run_id_seq'::regclass)"),
            autoincrement=True,
            nullable=False),
        sa.Column('adviser_document_id',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('datetime',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('adviser_version',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('adviser_name',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column('limit', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column('origin', sa.TEXT(), autoincrement=False, nullable=True),
        sa.Column('debug', sa.BOOLEAN(), autoincrement=False, nullable=False),
        sa.Column('limit_latest_versions',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('adviser_error',
                  sa.BOOLEAN(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('recommendation_type',
                  postgresql.ENUM('LATEST',
                                  'PERFORMANCE',
                                  'SECURITY',
                                  'STABLE',
                                  'TESTING',
                                  name='recommendation_type'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('requirements_format',
                  postgresql.ENUM('PIPENV', name='requirements_format'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('duration', sa.INTEGER(), autoincrement=False,
                  nullable=True),
        sa.Column('advised_configuration_changes',
                  sa.BOOLEAN(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('additional_stack_info',
                  sa.BOOLEAN(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('user_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('external_build_software_environment_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('external_hardware_information_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('external_run_software_environment_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('is_s2i', sa.BOOLEAN(), autoincrement=False, nullable=True),
        sa.Column('need_re_run',
                  sa.BOOLEAN(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('re_run_adviser_id',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('source_type',
                  postgresql.ENUM('CLI',
                                  'KEBECHET',
                                  'S2I',
                                  'GITHUB_APP',
                                  'JUPYTER_NOTEBOOK',
                                  name='source_type'),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['external_build_software_environment_id'],
            ['external_software_environment.id'],
            name='adviser_run_external_build_software_environment_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['external_hardware_information_id'],
            ['external_hardware_information.id'],
            name='adviser_run_external_hardware_information_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['external_run_software_environment_id'],
            ['external_software_environment.id'],
            name='adviser_run_external_run_software_environment_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['user_software_stack_id'],
                                ['python_software_stack.id'],
                                name='adviser_run_user_software_stack_id_fkey',
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name='adviser_run_pkey'),
        postgresql_ignore_search_path=False)
    op.create_table(
        'python_requirements_lock',
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('python_package_version_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ['python_package_version_id'], ['python_package_version.id'],
            name='python_requirements_lock_python_package_version_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['python_software_stack_id'], ['python_software_stack.id'],
            name='python_requirements_lock_python_software_stack_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id',
                                'python_package_version_id',
                                'python_software_stack_id',
                                name='python_requirements_lock_pkey'))
    op.create_table(
        'python_software_stack',
        sa.Column('id',
                  sa.INTEGER(),
                  server_default=sa.text(
                      "nextval('python_software_stack_id_seq'::regclass)"),
                  autoincrement=True,
                  nullable=False),
        sa.Column('software_stack_type',
                  postgresql.ENUM('USER',
                                  'INSPECTION',
                                  'ADVISED',
                                  name='software_stack_type',
                                  create_type=True),
                  autoincrement=False,
                  nullable=True),
        sa.Column('performance_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('overall_score',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.PrimaryKeyConstraint('id', name='python_software_stack_pkey'),
        postgresql_ignore_search_path=False)
    op.create_table(
        'inspection_run',
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('inspection_document_id',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('datetime',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('amun_version',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('build_requests_cpu',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('build_requests_memory',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('run_requests_cpu',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('run_requests_memory',
                  postgresql.DOUBLE_PRECISION(precision=53),
                  autoincrement=False,
                  nullable=True),
        sa.Column('inspection_sync_state',
                  postgresql.ENUM('PENDING',
                                  'SYNCED',
                                  name='inspection_sync_state'),
                  autoincrement=False,
                  nullable=False),
        sa.Column('build_hardware_information_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('run_hardware_information_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('build_software_environment_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('run_software_environment_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('dependency_monkey_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('inspection_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('inspection_result_number',
                  sa.INTEGER(),
                  server_default=sa.text('0'),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ['build_hardware_information_id'], ['hardware_information.id'],
            name='inspection_run_build_hardware_information_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['build_software_environment_id'], ['software_environment.id'],
            name='inspection_run_build_software_environment_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['dependency_monkey_run_id'], ['dependency_monkey_run.id'],
            name='inspection_run_dependency_monkey_run_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['inspection_software_stack_id'], ['python_software_stack.id'],
            name='inspection_run_inspection_software_stack_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['run_hardware_information_id'], ['hardware_information.id'],
            name='inspection_run_run_hardware_information_id_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['run_software_environment_id'], ['software_environment.id'],
            name='inspection_run_run_software_environment_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name='inspection_run_pkey'))
    op.create_table(
        'advised',
        sa.Column('adviser_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('python_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['adviser_run_id'], ['adviser_run.id'],
                                name='advised_adviser_run_id_fkey',
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['python_software_stack_id'],
                                ['python_software_stack.id'],
                                name='advised_python_software_stack_id_fkey',
                                ondelete='CASCADE'))
    op.create_table(
        'has_unresolved',
        sa.Column('adviser_run_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_package_version_entity_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['adviser_run_id'], ['adviser_run.id'],
                                name='has_unresolved_adviser_run_id_fkey',
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['python_package_version_entity_id'],
            ['python_package_version_entity.id'],
            name='has_unresolved_python_package_version_entity_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('adviser_run_id',
                                'python_package_version_entity_id',
                                name='has_unresolved_pkey'))
    op.create_table(
        'external_python_requirements_lock',
        sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column('python_package_version_entity_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('python_software_stack_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ['python_package_version_entity_id'],
            ['python_package_version_entity.id'],
            name=
            'external_python_requirements__python_package_version_entit_fkey',
            ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['python_software_stack_id'], ['python_software_stack.id'],
            name=
            'external_python_requirements_lock_python_software_stack_id_fkey',
            ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id',
                                'python_package_version_entity_id',
                                'python_software_stack_id',
                                name='external_python_requirements_lock_pkey'))
Ejemplo n.º 19
0
Revision ID: c092dabf3ee5
Revises: c1409ad0e8da
Create Date: 2019-08-01 15:18:20.306290

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'c092dabf3ee5'
down_revision = '48ab2dfefba9'
branch_labels = None
depends_on = None

sessiontypes = postgresql.ENUM('INTERACTIVE', 'BATCH', name='sessiontypes')


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('kernels',
                  sa.Column('startup_command', sa.Text(), nullable=True))
    op.drop_column('kernels', 'type')
    op.add_column(
        'kernels',
        sa.Column('sess_type',
                  sa.Enum('INTERACTIVE', 'BATCH', name='sessiontypes'),
                  nullable=False,
                  server_default='INTERACTIVE'))
    op.create_index(op.f('ix_kernels_sess_type'),
                    'kernels', ['sess_type'],
Ejemplo n.º 20
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('persons',
                    sa.Column('id',
                              postgresql.UUID(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('name',
                              sa.VARCHAR(length=255),
                              autoincrement=False,
                              nullable=False),
                    sa.PrimaryKeyConstraint('id', name='persons_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table('genres',
                    sa.Column('id',
                              postgresql.UUID(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('name',
                              sa.VARCHAR(length=255),
                              autoincrement=False,
                              nullable=False),
                    sa.PrimaryKeyConstraint('id', name='genres_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table('movies',
                    sa.Column('id',
                              postgresql.UUID(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('title',
                              sa.VARCHAR(length=255),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('plot',
                              sa.TEXT(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('imdb_rating',
                              sa.NUMERIC(),
                              server_default=sa.text('0'),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('id', name='movies_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table(
        'movies_person',
        sa.Column('id', postgresql.UUID(), autoincrement=False,
                  nullable=False),
        sa.Column('movie_id',
                  postgresql.UUID(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('person_id',
                  postgresql.UUID(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('position',
                  postgresql.ENUM('director',
                                  'writer',
                                  'actor',
                                  name='person_position'),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id'], ['movies.id'],
                                name='movies_person_movie'),
        sa.ForeignKeyConstraint(['id'], ['persons.id'],
                                name='movies_person_person'),
        sa.PrimaryKeyConstraint('id', name='movies_person_pkey'))
    op.create_table(
        'movies_genres',
        sa.Column('id', postgresql.UUID(), autoincrement=False,
                  nullable=False),
        sa.Column('movie_id',
                  postgresql.UUID(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('genre_id',
                  postgresql.UUID(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['id'], ['genres.id'],
                                name='movies_genres_genre'),
        sa.ForeignKeyConstraint(['id'], ['movies.id'],
                                name='movies_genres_movie'),
        sa.PrimaryKeyConstraint('id', name='movies_genres_pkey'))
Ejemplo n.º 21
0
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from answer.migrations import metadata
from answer.users.enums import UserGender


__all__ = ['users', 'gender_enum', ]


gender_enum = postgresql.ENUM(UserGender)


users = sa.Table(
    'users', metadata,
    sa.Column('id', sa.Integer, primary_key=True, index=True),
    sa.Column('username', sa.String(200), unique=True, nullable=False),
    sa.Column('email', sa.String(200), unique=True, nullable=False),
    sa.Column('password', sa.String(10), nullable=False),
    sa.Column('avatar_url', sa.Text),
    sa.Column(
        'gender',
        gender_enum,
        server_default=UserGender.none.value,
    ),
)
Ejemplo n.º 22
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'apilog', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('request_url', sa.String(length=512), nullable=False),
        sa.Column('request_method', sa.String(length=512), nullable=False),
        sa.Column('request_data', sa.String(length=512), nullable=False),
        sa.Column('error', sa.String(length=512), nullable=False),
        sa.Column('result', sa.String(length=512), nullable=False),
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('finished', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'errorlog', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('request_url', sa.String(length=512), nullable=False),
        sa.Column('request_method', sa.String(length=512), nullable=False),
        sa.Column('request_data', sa.String(length=512), nullable=False),
        sa.Column('error', sa.String(length=512), nullable=False),
        sa.Column('traceback', sa.String(length=1024), nullable=False),
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'wallet', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=100), nullable=True),
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('is_active',
                  sa.Boolean(),
                  server_default=sa.text('true'),
                  nullable=False), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'journal', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('from_wallet_id', sa.Integer(), nullable=True),
        sa.Column('to_wallet_id', sa.Integer(), nullable=True),
        sa.Column('type_operation',
                  postgresql.ENUM('Пополнение',
                                  'Вывод',
                                  'Перевод',
                                  name='EVENT_TYPES'),
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['from_wallet_id'],
            ['wallet.id'],
        ), sa.ForeignKeyConstraint(
            ['to_wallet_id'],
            ['wallet.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'users', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=512), nullable=False),
        sa.Column('last_name', sa.String(length=512), nullable=False),
        sa.Column('fathers_name', sa.String(length=512), nullable=False),
        sa.Column('birthday', sa.String(length=512), nullable=False),
        sa.Column('email', sa.String(length=512), nullable=False),
        sa.Column('phone', sa.String(length=512), nullable=True),
        sa.Column('type_account',
                  postgresql.ENUM('Юридическое лицо',
                                  'Физическое лицо',
                                  name='USER_TYPES'),
                  nullable=True),
        sa.Column('wallet_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['wallet_id'],
            ['wallet.id'],
        ), sa.PrimaryKeyConstraint('id'))
Ejemplo n.º 23
0
def upgrade():
    # server_default accepts string or SQL element only
    op.add_column(
        'executions',
        sa.Column('is_dry_run',
                  sa.Boolean(),
                  nullable=False,
                  server_default='f'))
    op.add_column('executions',
                  sa.Column('scheduled_for', UTCDateTime(), nullable=True))

    op.execute('COMMIT')
    # Add new execution status
    op.execute("alter type execution_status add value 'scheduled'")
    op.add_column(
        'deployments',
        sa.Column('capabilities', sa.PickleType(comparator=lambda *a: False)))
    op.add_column('events', sa.Column('source_id', sa.Text(), nullable=True))
    op.add_column('events', sa.Column('target_id', sa.Text(), nullable=True))
    op.add_column('logs', sa.Column('source_id', sa.Text(), nullable=True))
    op.add_column('logs', sa.Column('target_id', sa.Text(), nullable=True))

    # Create the agents table
    visibility_enum = postgresql.ENUM(*VisibilityState.STATES,
                                      name='visibility_states',
                                      create_type=False)
    agent_states_enum = postgresql.ENUM(*AgentState.STATES,
                                        name='agent_states')
    op.create_table(
        'agents', sa.Column('_storage_id', sa.Integer(), nullable=False),
        sa.Column('id', sa.Text(), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('ip', sa.Text(), nullable=True),
        sa.Column('install_method', sa.Text(), nullable=False),
        sa.Column('system', sa.Text(), nullable=True),
        sa.Column('version', sa.Text(), nullable=False),
        sa.Column('state', agent_states_enum, nullable=False),
        sa.Column('visibility', visibility_enum, nullable=True),
        sa.Column('rabbitmq_username', sa.Text(), nullable=True),
        sa.Column('rabbitmq_password', sa.Text(), nullable=True),
        sa.Column('rabbitmq_exchange', sa.Text(), nullable=False),
        sa.Column('created_at', UTCDateTime(), nullable=False),
        sa.Column('updated_at', UTCDateTime(), nullable=True),
        sa.Column('_node_instance_fk', sa.Integer(), nullable=False),
        sa.Column('_tenant_id', sa.Integer(), nullable=False),
        sa.Column('_creator_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['_creator_id'], [u'users.id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_node_instance_fk'],
                                [u'node_instances._storage_id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_tenant_id'], [u'tenants.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('_storage_id'))
    op.create_index(op.f('agents__tenant_id_idx'),
                    'agents', ['_tenant_id'],
                    unique=False)
    op.create_index(op.f('agents_created_at_idx'),
                    'agents', ['created_at'],
                    unique=False)
    op.create_index(op.f('agents_id_idx'), 'agents', ['id'], unique=False)

    # Remove the deprecated column private_resource from all the
    # resources tables
    for table_name in resource_tables:
        op.drop_column(table_name, 'private_resource')

    op.create_table(
        'tasks_graphs',
        sa.Column('_storage_id',
                  sa.Integer(),
                  autoincrement=True,
                  nullable=False), sa.Column('id', sa.Text(), nullable=True),
        sa.Column('visibility', visibility_enum, nullable=True),
        sa.Column('name', sa.Text(), nullable=True),
        sa.Column('created_at', UTCDateTime(), nullable=False),
        sa.Column('_execution_fk', sa.Integer(), nullable=False),
        sa.Column('_tenant_id', sa.Integer(), nullable=False),
        sa.Column('_creator_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['_creator_id'], [u'users.id'],
                                name=op.f('tasks_graphs__creator_id_fkey'),
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_execution_fk'], [u'executions._storage_id'],
                                name=op.f('tasks_graphs__execution_fk_fkey'),
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_tenant_id'], [u'tenants.id'],
                                name=op.f('tasks_graphs__tenant_id_fkey'),
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('_storage_id', name=op.f('tasks_graphs_pkey')))
    op.create_index(op.f('tasks_graphs__tenant_id_idx'),
                    'tasks_graphs', ['_tenant_id'],
                    unique=False)
    op.create_index(op.f('tasks_graphs_created_at_idx'),
                    'tasks_graphs', ['created_at'],
                    unique=False)
    op.create_index(op.f('tasks_graphs_id_idx'),
                    'tasks_graphs', ['id'],
                    unique=False)
    op.create_table(
        'operations',
        sa.Column('_storage_id',
                  sa.Integer(),
                  autoincrement=True,
                  nullable=False), sa.Column('id', sa.Text(), nullable=True),
        sa.Column('visibility', visibility_enum, nullable=True),
        sa.Column('name', sa.Text(), nullable=True),
        sa.Column('state', sa.Text(), nullable=False),
        sa.Column('created_at', UTCDateTime(), nullable=False),
        sa.Column('dependencies', postgresql.ARRAY(sa.Text()), nullable=True),
        sa.Column('type', sa.Text(), nullable=True),
        sa.Column('parameters', JSONString(), nullable=True),
        sa.Column('_tasks_graph_fk', sa.Integer(), nullable=False),
        sa.Column('_tenant_id', sa.Integer(), nullable=False),
        sa.Column('_creator_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['_creator_id'], [u'users.id'],
                                name=op.f('operations__creator_id_fkey'),
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_tasks_graph_fk'],
                                [u'tasks_graphs._storage_id'],
                                name=op.f('operations__tasks_graph_fk_fkey'),
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['_tenant_id'], [u'tenants.id'],
                                name=op.f('operations__tenant_id_fkey'),
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('_storage_id', name=op.f('operations_pkey')))
    op.create_index(op.f('operations__tenant_id_idx'),
                    'operations', ['_tenant_id'],
                    unique=False)
    op.create_index(op.f('operations_created_at_idx'),
                    'operations', ['created_at'],
                    unique=False)
    op.create_index(op.f('operations_id_idx'),
                    'operations', ['id'],
                    unique=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('state_supervision_violated_condition_entry',
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('condition', sa.String(length=255), nullable=False),
    sa.Column('supervision_violated_condition_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violation_id'], ['state_supervision_violation.supervision_violation_id'], ),
    sa.PrimaryKeyConstraint('supervision_violated_condition_entry_id')
    )
    op.create_index(op.f('ix_state_supervision_violated_condition_entry_state_code'), 'state_supervision_violated_condition_entry', ['state_code'], unique=False)
    op.create_table('state_supervision_violation_type_entry',
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('violation_type', postgresql.ENUM('ABSCONDED', 'ESCAPED', 'FELONY', 'MISDEMEANOR', 'MUNICIPAL', 'TECHNICAL', name='state_supervision_violation_type', create_type=False), nullable=True),
    sa.Column('violation_type_raw_text', sa.String(length=255), nullable=True),
    sa.Column('supervision_violation_type_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violation_id'], ['state_supervision_violation.supervision_violation_id'], ),
    sa.PrimaryKeyConstraint('supervision_violation_type_entry_id')
    )
    op.create_index(op.f('ix_state_supervision_violation_type_entry_state_code'), 'state_supervision_violation_type_entry', ['state_code'], unique=False)
    op.create_table('state_supervision_violated_condition_entry_history',
    sa.Column('valid_from', sa.DateTime(), nullable=False),
    sa.Column('valid_to', sa.DateTime(), nullable=True),
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('condition', sa.String(length=255), nullable=False),
    sa.Column('supervision_violated_condition_entry_history_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violated_condition_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violated_condition_entry_id'], ['state_supervision_violated_condition_entry.supervision_violated_condition_entry_id'], ),
    sa.ForeignKeyConstraint(['supervision_violation_id'], ['state_supervision_violation.supervision_violation_id'], ),
    sa.PrimaryKeyConstraint('supervision_violated_condition_entry_history_id')
    )
    op.create_index(op.f('ix_state_supervision_violated_condition_entry_history_supervision_violated_condition_entry_id'), 'state_supervision_violated_condition_entry_history', ['supervision_violated_condition_entry_id'], unique=False)
    op.create_index(op.f('ix_state_supervision_violated_condition_entry_history_state_code'), 'state_supervision_violated_condition_entry_history', ['state_code'], unique=False)
    op.create_table('state_supervision_violation_response_decision_type_entry',
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('decision', postgresql.ENUM('CONTINUANCE', 'EXTENSION', 'REVOCATION', 'SUSPENSION', name='state_supervision_violation_response_decision', create_type=False), nullable=True),
    sa.Column('decision_raw_text', sa.String(length=255), nullable=True),
    sa.Column('revocation_type', postgresql.ENUM('REINCARCERATION', 'RETURN_TO_SUPERVISION', 'SHOCK_INCARCERATION', 'TREATMENT_IN_PRISON', name='state_supervision_violation_response_revocation_type', create_type=False), nullable=True),
    sa.Column('revocation_type_raw_text', sa.String(length=255), nullable=True),
    sa.Column('supervision_violation_response_decision_type_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_response_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violation_response_id'], ['state_supervision_violation_response.supervision_violation_response_id'], ),
    sa.PrimaryKeyConstraint('supervision_violation_response_decision_type_entry_id')
    )
    op.create_index(op.f('ix_state_supervision_violation_response_decision_type_entry_state_code'), 'state_supervision_violation_response_decision_type_entry', ['state_code'], unique=False)
    op.create_table('state_supervision_violation_type_entry_history',
    sa.Column('valid_from', sa.DateTime(), nullable=False),
    sa.Column('valid_to', sa.DateTime(), nullable=True),
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('violation_type', postgresql.ENUM('ABSCONDED', 'ESCAPED', 'FELONY', 'MISDEMEANOR', 'MUNICIPAL', 'TECHNICAL', name='state_supervision_violation_type', create_type=False), nullable=True),
    sa.Column('violation_type_raw_text', sa.String(length=255), nullable=True),
    sa.Column('supervision_violation_type_history_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_type_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violation_id'], ['state_supervision_violation.supervision_violation_id'], ),
    sa.ForeignKeyConstraint(['supervision_violation_type_entry_id'], ['state_supervision_violation_type_entry.supervision_violation_type_entry_id'], ),
    sa.PrimaryKeyConstraint('supervision_violation_type_history_id')
    )
    op.create_index(op.f('ix_state_supervision_violation_type_entry_history_state_code'), 'state_supervision_violation_type_entry_history', ['state_code'], unique=False)
    op.create_index(op.f('ix_state_supervision_violation_type_entry_history_supervision_violation_type_entry_id'), 'state_supervision_violation_type_entry_history', ['supervision_violation_type_entry_id'], unique=False)
    op.create_table('state_supervision_violation_response_decision_type_entry_history',
    sa.Column('valid_from', sa.DateTime(), nullable=False),
    sa.Column('valid_to', sa.DateTime(), nullable=True),
    sa.Column('state_code', sa.String(length=255), nullable=False),
    sa.Column('decision', postgresql.ENUM('CONTINUANCE', 'EXTENSION', 'REVOCATION', 'SUSPENSION', name='state_supervision_violation_response_decision', create_type=False), nullable=True),
    sa.Column('decision_raw_text', sa.String(length=255), nullable=True),
    sa.Column('revocation_type', postgresql.ENUM('REINCARCERATION', 'RETURN_TO_SUPERVISION', 'SHOCK_INCARCERATION', 'TREATMENT_IN_PRISON', name='state_supervision_violation_response_revocation_type', create_type=False), nullable=True),
    sa.Column('revocation_type_raw_text', sa.String(length=255), nullable=True),
    sa.Column('supervision_violation_response_decision_type_entry_history_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_response_decision_type_entry_id', sa.Integer(), nullable=False),
    sa.Column('supervision_violation_response_id', sa.Integer(), nullable=True),
    sa.Column('person_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['person_id'], ['state_person.person_id'], initially='DEFERRED', deferrable=True),
    sa.ForeignKeyConstraint(['supervision_violation_response_decision_type_entry_id'], ['state_supervision_violation_response_decision_type_entry.supervision_violation_response_decision_type_entry_id'], ),
    sa.ForeignKeyConstraint(['supervision_violation_response_id'], ['state_supervision_violation_response.supervision_violation_response_id'], ),
    sa.PrimaryKeyConstraint('supervision_violation_response_decision_type_entry_history_id')
    )
    op.create_index(op.f('ix_state_supervision_violation_response_decision_type_entry_history_supervision_violation_response_decision_type_entry_id'), 'state_supervision_violation_response_decision_type_entry_history', ['supervision_violation_response_decision_type_entry_id'], unique=False)
    op.create_index(op.f('ix_state_supervision_violation_response_decision_type_entry_history_state_code'), 'state_supervision_violation_response_decision_type_entry_history', ['state_code'], unique=False)
    op.add_column('state_incarceration_sentence', sa.Column('is_capital_punishment', sa.Boolean(), nullable=True))
    op.add_column('state_incarceration_sentence_history', sa.Column('is_capital_punishment', sa.Boolean(), nullable=True))
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "state_supervision_violation_response_decision_type_entry",
        sa.Column("state_code",
                  sa.VARCHAR(length=255),
                  autoincrement=False,
                  nullable=False),
        sa.Column(
            "decision",
            postgresql.ENUM(
                "CONTINUANCE",
                "DELAYED_ACTION",
                "EXTENSION",
                "REVOCATION",
                "SERVICE_TERMINATION",
                "SUSPENSION",
                name="state_supervision_violation_response_decision",
                create_type=False,
            ),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "decision_raw_text",
            sa.VARCHAR(length=255),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "revocation_type",
            postgresql.ENUM(
                "REINCARCERATION",
                "RETURN_TO_SUPERVISION",
                "SHOCK_INCARCERATION",
                "TREATMENT_IN_PRISON",
                name="state_supervision_violation_response_revocation_type",
                create_type=False,
            ),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "revocation_type_raw_text",
            sa.VARCHAR(length=255),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "supervision_violation_response_decision_type_entry_id",
            sa.INTEGER(),
            server_default=sa.text(
                "nextval('state_supervision_violation_r_supervision_violation_respon_seq2'::regclass)"
            ),
            autoincrement=True,
            nullable=False,
        ),
        sa.Column(
            "supervision_violation_response_id",
            sa.INTEGER(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column("person_id",
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ["person_id"],
            ["state_person.person_id"],
            name=
            "state_supervision_violation_response_decision_ty_person_id_fkey",
            initially="DEFERRED",
            deferrable=True,
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_id"],
            [
                "state_supervision_violation_response.supervision_violation_response_id"
            ],
            name=
            "state_supervision_violation__supervision_violation_respon_fkey2",
        ),
        sa.PrimaryKeyConstraint(
            "supervision_violation_response_decision_type_entry_id",
            name=
            "state_supervision_violation_response_decision_type_entry_pkey",
        ),
        postgresql_ignore_search_path=False,
    )
    op.create_index(
        "ix_state_supervision_violation_response_decision_type_e_a335",
        "state_supervision_violation_response_decision_type_entry",
        ["state_code"],
        unique=False,
    )
    op.create_table(
        "state_supervision_violation_response_decision_type_entry_histor",
        sa.Column("valid_from",
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column("valid_to",
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=True),
        sa.Column("state_code",
                  sa.VARCHAR(length=255),
                  autoincrement=False,
                  nullable=False),
        sa.Column(
            "decision",
            postgresql.ENUM(
                "CONTINUANCE",
                "DELAYED_ACTION",
                "EXTENSION",
                "REVOCATION",
                "SERVICE_TERMINATION",
                "SUSPENSION",
                name="state_supervision_violation_response_decision",
                create_type=False,
            ),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "decision_raw_text",
            sa.VARCHAR(length=255),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "revocation_type",
            postgresql.ENUM(
                "REINCARCERATION",
                "RETURN_TO_SUPERVISION",
                "SHOCK_INCARCERATION",
                "TREATMENT_IN_PRISON",
                name="state_supervision_violation_response_revocation_type",
                create_type=False,
            ),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "revocation_type_raw_text",
            sa.VARCHAR(length=255),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column(
            "supervision_violation_response_decision_type_entry_history_id",
            sa.INTEGER(),
            autoincrement=True,
            nullable=False,
        ),
        sa.Column(
            "supervision_violation_response_decision_type_entry_id",
            sa.INTEGER(),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column(
            "supervision_violation_response_id",
            sa.INTEGER(),
            autoincrement=False,
            nullable=True,
        ),
        sa.Column("person_id",
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(
            ["person_id"],
            ["state_person.person_id"],
            name=
            "state_supervision_violation_response_decision_t_person_id_fkey1",
            initially="DEFERRED",
            deferrable=True,
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_decision_type_entry_id"],
            [
                "state_supervision_violation_response_decision_type_entry.supervision_violation_response_decision_type_entry_id"
            ],
            name=
            "state_supervision_violation__supervision_violation_respon_fkey3",
        ),
        sa.ForeignKeyConstraint(
            ["supervision_violation_response_id"],
            [
                "state_supervision_violation_response.supervision_violation_response_id"
            ],
            name=
            "state_supervision_violation__supervision_violation_respon_fkey4",
        ),
        sa.PrimaryKeyConstraint(
            "supervision_violation_response_decision_type_entry_history_id",
            name=
            "state_supervision_violation_response_decision_type_entry_h_pkey",
        ),
    )
    op.create_index(
        "ix_state_supervision_violation_response_decision_type_e_ba56",
        "state_supervision_violation_response_decision_type_entry_histor",
        ["state_code"],
        unique=False,
    )
    op.create_index(
        "ix_state_supervision_violation_response_decision_type_e_2fc7",
        "state_supervision_violation_response_decision_type_entry_histor",
        ["supervision_violation_response_decision_type_entry_id"],
        unique=False,
    )
    op.drop_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_history_supervision_violation_response_decision_entry_id"
          ),
        table_name=
        "state_supervision_violation_response_decision_entry_history",
    )
    op.drop_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_history_state_code"
          ),
        table_name=
        "state_supervision_violation_response_decision_entry_history",
    )
    op.drop_table(
        "state_supervision_violation_response_decision_entry_history")
    op.drop_index(
        op.
        f("ix_state_supervision_violation_response_decision_entry_state_code"),
        table_name="state_supervision_violation_response_decision_entry",
    )
    op.drop_table("state_supervision_violation_response_decision_entry")
Ejemplo n.º 26
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('dataset',
                    'os',
                    existing_type=postgresql.ENUM('android', 'ios', name='os'),
                    nullable=False)
Ejemplo n.º 27
0
def upgrade():
    billing_cycles = op.create_table(
        'billing_cycles', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('start_date', sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column('end_date', sa.TIMESTAMP(timezone=True), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    populate_billing_cycles(billing_cycles)

    plans = op.create_table(
        'plans', sa.Column('id', sa.String(length=30), nullable=False),
        sa.Column('description', sa.String(length=200), nullable=True),
        sa.Column('mb_available', sa.BigInteger(), nullable=True),
        sa.Column('is_unlimited', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    populate_plans(plans)

    service_codes = op.create_table(
        'service_codes', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(length=200), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'))
    populate_service_codes(service_codes)

    subscriptions = op.create_table(
        'subscriptions', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('phone_number', sa.String(length=10), nullable=True),
        sa.Column('status',
                  postgresql.ENUM('new',
                                  'active',
                                  'suspended',
                                  'expired',
                                  name='subscriptionstatus'),
                  nullable=True),
        sa.Column('plan_id', sa.String(length=30), nullable=False),
        sa.ForeignKeyConstraint(
            ['plan_id'],
            ['plans.id'],
        ), sa.PrimaryKeyConstraint('id'))
    populate_subscriptions(subscriptions)

    data_usages = op.create_table(
        'data_usages', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('mb_used', sa.Float(), nullable=True),
        sa.Column('from_date', sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column('to_date', sa.TIMESTAMP(timezone=True), nullable=True),
        sa.Column('subscription_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['subscription_id'],
            ['subscriptions.id'],
        ), sa.PrimaryKeyConstraint('id'))
    populate_data_usages(data_usages)

    subscriptions_service_codes = op.create_table(
        'subscriptions_service_codes',
        sa.Column('subscription_id', sa.Integer(), nullable=False),
        sa.Column('service_code_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['service_code_id'],
            ['service_codes.id'],
        ), sa.ForeignKeyConstraint(
            ['subscription_id'],
            ['subscriptions.id'],
        ), sa.PrimaryKeyConstraint('subscription_id', 'service_code_id'))
    populate_subscriptions_service_codes(subscriptions_service_codes)
from sqlalchemy.schema import Sequence, CreateSequence

# revision identifiers, used by Alembic.
revision = 'e2bdb3a5b1b4'
down_revision = '528cb85d6ad3'
branch_labels = None
depends_on = None

meta = sa.MetaData()

#
# Define the types we need
#

# image_state is an enumeration type used in the *images tables
image_state = postgresql.ENUM('deleted', 'deprecated', 'inactive', 'active', name='image_state')

# image_region is a string type used in many of the alibaba and amazon images tables
image_region = sa.VARCHAR(length=100)

# image_project is a string type used in the googleimages table
image_project = sa.VARCHAR(length=50)

# server_ip is a Postgres INET type used in the *servers tables
server_ip = postgresql.INET()

# server_name is a string type used in the *servers table
server_name = sa.VARCHAR(length=100)

# server_type is an enumeration type used in the *servers table
server_type = postgresql.ENUM('region', 'update', name='server_type',
Ejemplo n.º 29
0
 def test_enum(self):
     result = format_partition_value(postgresql.ENUM(), '1.1')
     assert result == '\'1.1\''
Ejemplo n.º 30
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "set_translation",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("set_id", postgresql.UUID(as_uuid=True), nullable=False),
        sa.Column("locale", sa.String(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(["set_id"], ["set.uuid"],
                                name=op.f("fk_set_translation_set_id_set")),
        sa.PrimaryKeyConstraint("uuid", name=op.f("pk_set_translation")),
    )
    op.create_table(
        "item_translation",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("item_id", postgresql.UUID(as_uuid=True), nullable=False),
        sa.Column("locale", sa.String(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(["item_id"], ["item.uuid"],
                                name=op.f("fk_item_translation_item_id_item")),
        sa.PrimaryKeyConstraint("uuid", name=op.f("pk_item_translation")),
    )
    op.drop_index("ix_item_condition_item_id", table_name="item_condition")
    op.drop_table("item_condition")
    op.add_column("item", sa.Column("condtions", sa.JSON(), nullable=True))
    op.add_column("item", sa.Column("dofus_db_id", sa.String(),
                                    nullable=False))
    op.drop_column("item", "name")
    op.add_column("item_stat", sa.Column("alt_stat",
                                         sa.String(),
                                         nullable=True))
    op.add_column("set", sa.Column("dofus_db_id", sa.String(), nullable=False))
    op.drop_column("set", "name")
    op.add_column("set_bonus", sa.Column("alt_stat",
                                         sa.String(),
                                         nullable=True))
    op.add_column("set_bonus", sa.Column("value", sa.Integer(), nullable=True))
    op.alter_column(
        "set_bonus",
        "stat",
        existing_type=postgresql.ENUM(
            "VITALITY",
            "AP",
            "MP",
            "INITIATIVE",
            "PROSPECTING",
            "RANGE",
            "SUMMON",
            "WISDOM",
            "STRENGTH",
            "INTELLIGENCE",
            "CHANCE",
            "AGILITY",
            "AP_PARRY",
            "AP_REDUCTION",
            "MP_PARRY",
            "MP_REDUCTION",
            "CRITICAL",
            "HEALS",
            "LOCK",
            "DODGE",
            "PCT_FINAL_DAMAGE",
            "POWER",
            "DAMAGE",
            "CRITICAL_DAMAGE",
            "NEUTRAL_DAMAGE",
            "EARTH_DAMAGE",
            "FIRE_DAMAGE",
            "WATER_DAMAGE",
            "AIR_DAMAGE",
            "REFLECT",
            "TRAP_DAMAGE",
            "TRAP_POWER",
            "PUSHBACK_DAMAGE",
            "PCT_SPELL_DAMAGE",
            "PCT_WEAPON_DAMAGE",
            "PCT_RANGED_DAMAGE",
            "PCT_MELEE_DAMAGE",
            "NEUTRAL_RES",
            "PCT_NEUTRAL_RES",
            "EARTH_RES",
            "PCT_EARTH_RES",
            "FIRE_RES",
            "PCT_FIRE_RES",
            "WATER_RES",
            "PCT_WATER_RES",
            "AIR_RES",
            "PCT_AIR_RES",
            "CRITICAL_RES",
            "PUSHBACK_RES",
            "PCT_RANGED_RES",
            "PCT_MELEE_RES",
            "PODS",
            name="stat",
        ),
        nullable=True,
    )
    op.drop_column("set_bonus", "max_value")