class Data(db.Model):
    """
    Attribute metadata.
    Gives some informations about the data columns
    """
    __tablename__ = 'tjs_data'
    pkid = db.Column(db.Integer, primary_key=True)
    dataset = db.relationship(
        'Dataset',
        backref=db.backref('datas', lazy='dynamic')
    )
    dataset_id = db.Column(db.Integer, db.ForeignKey('tjs_datasets.pkid'))
    isframeworkkey = db.Column(db.Boolean)

    name = db.Column(db.String, nullable=False)
    type = db.Column(xmldtypes, default="string")
    length = db.Column(db.Integer, default=0)
    purpose = db.Column(db.String, default="Attribute")
    title = db.Column(db.String)
    abstract = db.Column(db.Text)
    values = db.Column(
        ENUM('count', 'measure', 'nominal', 'ordinal', name='tjs_valuetype'),
        default='ordinal')

    # extensions
    curves = db.Column(emp_chart_rules)
    jointoframeworkkey = db.Column(db.Integer, db.ForeignKey('tjs_frameworkkey.pkid'))
    bars = db.Column(emp_chart_rules)
    tabular = db.Column(emp_chart_rules)
    brush = db.Column(emp_chart_rules)
    map = db.Column(emp_chart_rules)
    map_mode = db.Column(ENUM('flow-source', 'flow-dest', 'standard', name='emp_mapmodes'))

    def __repr__(self):
        return '{} : {}'.format(self.dataset.dataseturi, self.name)
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('manga_tags_link')
    op.drop_index('manga_releases_source_site_id_idx',
                  table_name='manga_releases')
    op.drop_index(op.f('ix_manga_releases_state'), table_name='manga_releases')
    op.drop_index(op.f('ix_manga_releases_source_site'),
                  table_name='manga_releases')
    op.drop_index(op.f('ix_manga_releases_source_id'),
                  table_name='manga_releases')
    op.drop_table('manga_releases')
    op.drop_table('hentai_tags_link')
    op.drop_index(op.f('ix_hentai_releases_state'),
                  table_name='hentai_releases')
    op.drop_index(op.f('ix_hentai_releases_source_site'),
                  table_name='hentai_releases')
    op.drop_index(op.f('ix_hentai_releases_source_id'),
                  table_name='hentai_releases')
    op.drop_index('hentai_releases_source_site_id_idx',
                  table_name='hentai_releases')
    op.drop_table('hentai_releases')
    op.drop_table('release_files')
    op.drop_index(op.f('ix_manga_tags_tag'), table_name='manga_tags')
    op.drop_table('manga_tags')
    op.drop_index(op.f('ix_hentai_tags_tag'), table_name='hentai_tags')
    op.drop_table('hentai_tags')

    ENUM(name='filetype_enum').drop(op.get_bind(), checkfirst=False)
    ENUM(name='dlstate_enum').drop(op.get_bind(), checkfirst=False)
    ENUM(name='dirtype_enum').drop(op.get_bind(), checkfirst=False)
def upgrade():
    context = op.get_context()

    # Upgrading to this revision WILL clear your directmedia values.
    if context.bind.dialect.name == 'sqlite':
        with op.batch_alter_table('sippeers') as batch_op:
            batch_op.alter_column('directmedia', type_=new_type)
    elif context.bind.dialect.name != 'postgresql':
        op.alter_column('sippeers',
                        'directmedia',
                        type_=new_type,
                        existing_type=old_type)
    else:
        enum = ENUM("yes",
                    "no",
                    "nonat",
                    "update",
                    "outgoing",
                    name="sip_directmedia_values_v2")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
                   ' sip_directmedia_values_v2 USING'
                   ' directmedia::text::sip_directmedia_values_v2')

        ENUM(name="sip_directmedia_values").drop(op.get_bind(),
                                                 checkfirst=False)
def upgrade():
    enum = ENUM(u'289',
                u'619',
                u'679',
                u'889',
                u'789',
                u'998',
                u'589',
                u'380',
                u'798',
                u'689',
                u'89',
                u'498',
                u'489',
                u'389',
                u'189',
                u'298',
                name="ck_region",
                create_type=False)
    enum.create(op.get_bind(), checkfirst=False)
    op.create_table(
        'region_percentage', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('percentage', sa.Integer(), nullable=True),
        sa.Column('region', enum, nullable=False),
        sa.Column('activity_id', sa.Unicode(), nullable=False),
        sa.ForeignKeyConstraint(['activity_id'], ['activity.iati_identifier'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
Example #5
0
class Candidacy(Base):
    __tablename__ = 'candidacies'
    id = sa.Column(sa.Integer, primary_key=True)

    candidate_id = sa.Column(sa.Integer)
    candidate = sa.orm.relationship(
        'Candidate',
        primaryjoin='Candidacy.candidate_id==Candidate.id',
        foreign_keys='Candidacy.candidate_id',
        remote_side='Candidate.id',
        backref='candidacies')

    election_type = sa.Column(sa.String)
    election_year = sa.Column(sa.Integer)

    # Incumbent, challenger, open seat
    race_type = sa.Column(
        ENUM('incumbent',
             'challenger',
             'open seat',
             'retired',
             name='candidacy_race_type'))
    outcome = sa.Column(ENUM('won', 'lost', name='candidacy_outcome'))
    fair_campaign = sa.Column(sa.Boolean)
    limits_off = sa.Column(sa.Boolean)
    limits_off_reason = sa.Column(sa.String)

    def __repr__(self):
        return '<Candidacy %r %r, (%r %r)>' % (
            self.candidate.first_name, self.candidate.last_name,
            self.election_year, self.election_type)

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
Example #6
0
def upgrade():
    ENUM(u'gcc', u'g++', u'java', name=u'user_program_language_enum').create(op.get_bind(), checkfirst=False)
    op.alter_column('user', 'program_language', existing_type=sa.Enum(u'gcc', u'g++', u'java', name=u'user_program_language_enum'), nullable=True)
    op.alter_column('user_deleted', 'program_language', existing_type=sa.Enum(u'male', u'female', name='user_gender'), nullable=True)

    ENUM(u'gcc', u'g++', u'java', name=u'solution_program_language_enum').create(op.get_bind(), checkfirst=False)
    op.alter_column('solution', 'program_language', existing_type=sa.Enum(u'gcc', u'g++', u'java', name=u'solution_program_language_enum'), nullable=False)
Example #7
0
def upgrade():
    # If we don't do this, Alembic won't create the type automatically
    enum_type = ENUM('yahoo', 'google', 'kofia', name='asset_value_source')
    enum_type.create(op.get_bind())

    op.add_column('asset_value', sa.Column('source', enum_type,
                                           nullable=False))
Example #8
0
class SubOrder(Model):
    __tablename__ = 'sub_order'

    title = Column(String, nullable=True)
    order_id = Column(UUIDType(binary=False),
                      ForeignKey('order.id'),
                      nullable=False)
    total_price = Column(Float)
    receiver_id = Column(UUIDType(binary=False), ForeignKey('receivers.id'))
    address_id = Column(UUIDType(binary=False), ForeignKey('addresses.id'))
    delivery_type = Column(ENUM('fast', 'scheduled', name='delivery_typess'))
    delivery_date = Column(DateTime)
    delivery_time = Column(String)
    message = Column(String)
    order_status = Column(
        ENUM('pending', 'ongoing', 'done', name='sub_order_status'))
    is_cart = Column(Boolean, unique=False, default=True)

    @hybrid_property
    def product(self):
        return Product.query.filter_by(id=str(self.product_id)).first()

    @hybrid_property
    def address(self):
        return Address.query.filter_by(id=str(self.address_id)).first()

    @hybrid_property
    def receiver(self):
        return Receiver.query.filter_by(id=str(self.receiver_id)).first()

    @hybrid_property
    def extra_orders(self):
        return ExtraOrder.query.filter_by(suborder_id=str(self.id)).all()
def upgrade():
    # If we don't do this, Alembic won't create the type automatically
    enum_type = ENUM("yahoo", "google", "kofia", name="asset_value_source")
    enum_type.create(op.get_bind())

    op.add_column("asset_value", sa.Column("source", enum_type,
                                           nullable=False))
Example #10
0
class Pickup(Base):
    __tablename__ = "pickups"
    id = sa.Column("id", sa.Integer, primary_key=True)
    firebase_id = sa.Column("firebase_id", sa.String, nullable=False)
    firebase_run_id = sa.Column("firebase_run_id", sa.String, nullable=False)
    centerline_id =\
        sa.Column("centerline_id", sa.Integer, sa.ForeignKey("centerlines.id"), nullable=False)
    type = sa.Column("type",
                     ENUM(*RUBBISH_TYPES, name="rubbish_type"),
                     nullable=False)
    timestamp = sa.Column("timestamp", sa.DateTime, nullable=False)
    geometry = sa.Column("geometry", Geometry("POINT"), nullable=False)
    snapped_geometry = sa.Column("snapped_geometry",
                                 Geometry("POINT"),
                                 nullable=False)
    linear_reference = sa.Column("linear_reference",
                                 sa.Float(precision=3),
                                 nullable=False)
    curb = sa.Column("curb",
                     ENUM('left', 'right', 'middle', name='curb'),
                     nullable=False)
    centerline = relationship("Centerline", back_populates="pickups")

    def __repr__(self):
        return (
            f"""<Pickup id={self.id} """
            f"""geometry={self.geometry} snapped_geometry={self.snapped_geometry} """
            f"""centerline_id={self.centerline_id} firebase_id={self.firebase_id} """
            f"""firebase_run_id={self.firebase_run_id} """
            f"""type={self.type} timestamp={self.timestamp} """
            f"""linear_reference={self.linear_reference} curb={self.curb}>""")
def downgrade():
    context = op.get_context()

    op.execute(tcr.update().where(tcr.c.directmedia == u'outgoing').values(
        directmedia=None))

    if context.bind.dialect.name != 'postgresql':
        op.alter_column('sippeers',
                        'directmedia',
                        type_=old_type,
                        existing_type=new_type)
    else:
        enum = ENUM("yes",
                    "no",
                    "nonat",
                    "update",
                    name="sip_directmedia_values")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
                   ' sip_directmedia_values USING'
                   ' directmedia::text::sip_directmedia_values')

        ENUM(name="sip_directmedia_values_v2").drop(op.get_bind(),
                                                    checkfirst=False)
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('alert_affected_services_alert_id_fkey',
                       'alert_affected_services',
                       type_='foreignkey')
    op.drop_constraint('alert_affected_services_route_id_fkey',
                       'alert_affected_services',
                       type_='foreignkey')
    op.drop_constraint('alert_effect_period_alert_id_fkey',
                       'alert_effect_period',
                       type_='foreignkey')
    op.drop_constraint('alert_events_routes_fkey',
                       'alert_events',
                       type_='foreignkey')
    op.drop_constraint('alert_events_day_check', 'alert_events', type_='check')

    op.drop_table('alert_events')
    op.drop_table('alert_affected_services')
    op.drop_table('alert_effect_period')
    op.drop_table('alerts')
    op.drop_table('stops')
    op.drop_table('routes')

    ENUM(name="delayaccuracy").drop(op.get_bind(), checkfirst=False)
    ENUM(name="direction").drop(op.get_bind(), checkfirst=False)
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    enum = ENUM('unverified',
                'valid',
                'rejected',
                name='nu_item_enum',
                create_type=False)
    enum.create(op.get_bind(), checkfirst=True)

    op.execute(
        "ALTER TABLE nu_release_item ALTER COLUMN reviewed DROP DEFAULT")

    op.alter_column(
        'nu_release_item',
        'reviewed',
        existing_type=sa.BOOLEAN(),
        type_=enum,
        existing_nullable=False,
        nullable=False,
        server_default=sa.text("'unverified'"),
        existing_server_default=sa.text('false'),
        postgresql_using=
        "CASE WHEN reviewed = false THEN 'unverified'::nu_item_enum ELSE 'valid'::nu_item_enum END"
    )

    op.execute(
        "ALTER TABLE nu_release_item ALTER COLUMN reviewed SET DEFAULT 'unverified'"
    )
def downgrade():
    context = op.get_context()

    op.drop_column('ps_endpoints', 'dtls_fingerprint')

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
        enum.drop(op.get_bind(), checkfirst=False)
def upgrade():
    # If we don't do this, Alembic won't create the type automatically
    enum_type = ENUM('yahoo', 'google', 'kofia', name='asset_value_source')
    enum_type.create(op.get_bind())

    op.add_column(
        'asset_value',
        sa.Column('source', enum_type, nullable=False))
def upgrade():
    enum = ENUM(
        u'10', u'15', u'21', u'22', u'23', u'30', u'40', u'60', u'70', u'80',
        name="ck_organisation_type",
        create_type=False
    )
    enum.create(op.get_bind(), checkfirst=False)
    op.add_column('organisation', sa.Column('type', enum, nullable=True))
Example #17
0
def downgrade():
    context = op.get_context()

    op.drop_column('ps_endpoints', 'dtls_fingerprint')

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
        enum.drop(op.get_bind(), checkfirst=False)
def downgrade():
    if op.get_context().bind.dialect.name == 'mssql':
        op.drop_constraint('ck_ps_globals_taskprocessor_overload_trigger_pjsip_taskprocessor_overload_trigger_values', 'ps_globals')
    op.drop_column('ps_globals', 'taskprocessor_overload_trigger')

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
                    name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
        enum.drop(op.get_bind(), checkfirst=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    trialoutcome = ENUM(
        "BOTH_SAME", "FIRST_SAME", "SECOND_SAME", "NONE_SAME", name="trialoutcome"
    )
    trialoutcome.create(op.get_bind())
    op.add_column(
        "drug_categorizations", sa.Column("categorization", trialoutcome, nullable=True)
    )
Example #20
0
class Committee(Base):
    __tablename__ = 'committees'
    id = sa.Column(sa.Integer, primary_key=True)
    type = sa.Column(sa.String)
    state_committee = sa.Column(sa.Boolean)
    state_id = sa.Column(sa.Integer)
    local_committee = sa.Column(sa.Boolean)
    local_id = sa.Column(sa.Integer)
    refer_name = sa.Column(sa.String)
    name = sa.Column(sa.String)
    address1 = sa.Column(sa.String)
    address2 = sa.Column(sa.String)
    address3 = sa.Column(sa.String)
    city = sa.Column(sa.String)
    state = sa.Column(sa.String)
    zipcode = sa.Column(sa.String)
    active = sa.Column(sa.Boolean)
    status_date = sa.Column(sa.DateTime)
    creation_date = sa.Column(sa.DateTime)
    creation_amount = sa.Column(DOUBLE_PRECISION)
    disp_funds_return = sa.Column(sa.Boolean)
    disp_funds_political_committee = sa.Column(sa.Boolean)
    disp_funds_charity = sa.Column(sa.Boolean)
    disp_funds_95 = sa.Column(sa.Boolean)
    disp_funds_description = sa.Column(sa.Text)

    # These use the same ENUM. Need to create it separately
    candidate_position = sa.Column(
        ENUM('support', 'oppose', name='committee_position',
             create_type=False))
    policy_position = sa.Column(
        ENUM('support', 'oppose', name='committee_position',
             create_type=False))
    party = sa.Column(sa.String)
    purpose = sa.Column(sa.Text)

    candidates = sa.orm.relationship(
        'Candidate',
        primaryjoin='Committee.id==candidate_committees.c.committee_id',
        secondaryjoin='candidate_committees.c.candidate_id==Candidate.id',
        secondary=candidate_committees,
        backref='committees')

    officers = sa.orm.relationship(
        'Officer',
        primaryjoin='Committee.id==officer_committees.c.committee_id',
        secondaryjoin='officer_committees.c.officer_id==Officer.id',
        secondary=officer_committees,
        backref='committees')

    def __repr__(self):
        return '<Committee %r>' % self.name

    def as_dict(self):
        d = {c.name: getattr(self, c.name) for c in self.__table__.columns}
        d['officers'] = [o.as_dict() for o in self.officers]
Example #21
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    enum = ENUM('plain_text', 'markdown', name='commentreplytype')
    enum.create(op.get_bind(), checkfirst=True)
    op.add_column(
        'comment_reply',
        sa.Column('reply_type',
                  enum,
                  server_default='plain_text',
                  nullable=False))
def downgrade():
    yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
    if op.get_context().bind.dialect.name != 'mssql':
        op.alter_column('ps_transports', 'verify_server', type_=yesno_values,
                        new_column_name='verifiy_server')
    else:
        op.alter_column('ps_transports', 'verify_server', existing_type=yesno_values, type_=sa.String(3),
                        new_column_name='verifiy_server')
        yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=True)
        op.alter_column('ps_transports', 'verifiy_server', existing_type=sa.String(3), type_=yesno_values)
def upgrade():
    ''' Add the column merge_status to the table pull_requests.
    '''
    enum = ENUM('NO_CHANGE', 'FFORWARD', 'CONFLICTS', 'MERGE',
                name='merge_status_enum', create_type=False)
    enum.create(op.get_bind(), checkfirst=False)
    op.add_column(
        'pull_requests',
        sa.Column('merge_status', enum, nullable=True)
    )
def upgrade():
    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
        enum.create(op.get_bind(), checkfirst=False)

    op.add_column('ps_endpoints',
             sa.Column('dtls_fingerprint', ENUM(*SHA_HASH_VALUES,
                 name=SHA_HASH_NAME, create_type=False)))
def upgrade():
    op.create_table(
        'activity_log',
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('box_code', sa.Integer(), nullable=False),
        sa.Column('worker_id', sa.Integer, sa.ForeignKey('worker.id')),
        sa.Column('payload', sa.Integer()),
        sa.Column('type', ENUM(ActivityType, name="type")),
        sa.Column('status', ENUM(ActivityStatus, name="status")),
        sa.Column('local_time', sa.DateTime()),
        sa.Column('server_time', sa.DateTime(), default=dt.now))
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    gender_column = sa.Column(
        'gender', sa.Enum('male', 'female', 'unspecified'))
    if DATABASE_URL[:8] == 'postgres':
        gender_enum = ENUM(
            'male', 'female', 'unspecified', name='alert_gender')
        gender_enum.create(op.get_bind(), checkfirst=False)
        gender_column = sa.Column('gender', gender_enum)
    op.add_column('alerts', sa.Column('age', sa.Integer()))
    op.add_column('alerts', gender_column)
Example #27
0
def downgrade():
    if op.get_context().bind.dialect.name == 'mssql':
        op.drop_constraint(
            'ck_ps_globals_taskprocessor_overload_trigger_pjsip_taskprocessor_overload_trigger_values',
            'ps_globals')
    op.drop_column('ps_globals', 'taskprocessor_overload_trigger')

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
                    name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
        enum.drop(op.get_bind(), checkfirst=False)
def downgrade():
    context = op.get_context()

    if op.get_context().bind.dialect.name == 'mssql':
        op.drop_constraint('ck_ps_endpoints_dtls_fingerprint_sha_hash_values',
                           'ps_endpoints')
    op.drop_column('ps_endpoints', 'dtls_fingerprint')

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
        enum.drop(op.get_bind(), checkfirst=False)
Example #29
0
def upgrade():
    ''' Add the column merge_status to the table pull_requests.
    '''
    enum = ENUM('NO_CHANGE',
                'FFORWARD',
                'CONFLICTS',
                'MERGE',
                name='merge_status_enum',
                create_type=False)
    enum.create(op.get_bind(), checkfirst=False)
    op.add_column('pull_requests',
                  sa.Column('merge_status', enum, nullable=True))
def upgrade():
    # Create the new enum
    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
    if op.get_context().bind.dialect.name == 'postgresql':
        ast_bool_values.create(op.get_bind(), checkfirst=False)

    # There is no direct way to convert from Integer to ENUM that is
    # not database specific so we transition through a string type.
    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
                    type_=sa.String(5))
    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
                    type_=ast_bool_values)
def upgrade():
    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
                    name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
        enum.create(op.get_bind(), checkfirst=False)

    op.add_column('ps_globals',
        sa.Column('taskprocessor_overload_trigger',
            sa.Enum(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
            name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)))
def upgrade():
    # Create the new enum
    ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
    if op.get_context().bind.dialect.name == 'postgresql':
        ast_bool_values.create(op.get_bind(), checkfirst=False)

    # There is no direct way to convert from Integer to ENUM that is
    # not database specific so we transition through a string type.
    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
                    type_=sa.String(5))
    op.alter_column('ps_endpoints', 'mwi_subscribe_replaces_unsolicited',
            type_=ast_bool_values, postgresql_using='mwi_subscribe_replaces_unsolicited::{0}'.format(AST_BOOL_NAME))
Example #33
0
def upgrade():
    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME)
        enum.create(op.get_bind(), checkfirst=False)

    op.add_column(
        'ps_endpoints',
        sa.Column(
            'dtls_fingerprint',
            ENUM(*SHA_HASH_VALUES, name=SHA_HASH_NAME, create_type=False)))
Example #34
0
def downgrade():
    op.alter_column('user', 'program_language',
               existing_type=sa.VARCHAR(length=64),
               nullable=True)
    op.alter_column('user_deleted', 'program_language',
               existing_type=sa.VARCHAR(length=64),
               nullable=True)
    op.alter_column('solution', 'program_language',
               existing_type=sa.VARCHAR(length=64),
               nullable=False)
    ENUM(name=u'user_program_language_enum').drop(op.get_bind(), checkfirst=False)
    ENUM(name=u'solution_program_language_enum').drop(op.get_bind(), checkfirst=False)
Example #35
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    enum = ENUM("unknown",
                "incoming_text",
                "incoming_call",
                "outgoing_call",
                name='contact_types')
    enum.create(op.get_bind(), checkfirst=False)
    op.add_column(
        'calls',
        sa.Column('contact_type', sa.Enum(name='contact_types'),
                  nullable=True))
Example #36
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    gender_column = sa.Column('gender', sa.Enum('male', 'female',
                                                'unspecified'))
    if DATABASE_URL[:8] == 'postgres':
        gender_enum = ENUM('male',
                           'female',
                           'unspecified',
                           name='alert_gender')
        gender_enum.create(op.get_bind(), checkfirst=False)
        gender_column = sa.Column('gender', gender_enum)
    op.add_column('alerts', sa.Column('age', sa.Integer()))
    op.add_column('alerts', gender_column)
class Candidate(BaseModelWithTimestamps):
    fec_id = db.Column(db.String(9), unique=True, nullable=False)
    name = db.Column(db.String)
    party_affiliation = db.Column(db.String(3))
    election_year = db.Column(db.SmallInteger, nullable=False)
    office = db.Column(ENUM("H", "S", name="office"), nullable=False)
    office_state = db.Column(db.String(2), nullable=False)
    office_district = db.Column(db.String(2))
    incumbent_challenger_status = db.Column(
        ENUM("C", "I", "O", name="incumbent_challenger_status")
    )
    principal_campaign_committee_fec_id = db.Column(db.String(9))
    pledge_date = db.Column(db.Date)
Example #38
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    enum = ENUM('visible', 'archived', 'deleted', name='coursestate')
    enum.create(op.get_bind(), checkfirst=True)
    op.add_column(
        'Course',
        sa.Column('state', enum, server_default='visible', nullable=False))
    op.add_column(
        'Course',
        sa.Column('updated_at',
                  sa.TIMESTAMP(timezone=True),
                  nullable=False,
                  server_default='NOW()'))
Example #39
0
def upgrade():
    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':
        enum = ENUM(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
                    name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)
        enum.create(op.get_bind(), checkfirst=False)

    op.add_column(
        'ps_globals',
        sa.Column(
            'taskprocessor_overload_trigger',
            sa.Enum(*PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_VALUES,
                    name=PJSIP_TASKPROCESSOR_OVERLOAD_TRIGGER_NAME)))
Example #40
0
def destroy_db():
    metadata = MetaData()
    metadata.bind = db.engine
    metadata.reflect()
    tables = list(metadata.sorted_tables)
    while len(tables):
        for table in tables:
            try:
                table.drop(checkfirst=True)
                tables.remove(table)
            except InternalError:
                pass
    for enum in inspect(db.engine).get_enums():
        enum = ENUM(name=enum['name'])
        enum.drop(bind=db.engine, checkfirst=True)
Example #41
0
def evilshit():
    """EVIL: Delete all data and recreate the database."""
    delete_index()
    db.drop_all()
    from sqlalchemy import MetaData, inspect
    from sqlalchemy.dialects.postgresql import ENUM
    metadata = MetaData()
    metadata.bind = db.engine
    metadata.reflect()
    for table in metadata.sorted_tables:
        table.drop(checkfirst=True)
    for enum in inspect(db.engine).get_enums():
        enum = ENUM(name=enum['name'])
        enum.drop(bind=db.engine, checkfirst=True)
    init()
def upgrade():
    enum = ENUM(
        u'289', u'619', u'679', u'889', u'789', u'998', u'589', u'380', u'798', u'689', u'89', u'498', u'489', u'389', u'189', u'298',
        name="ck_region",
        create_type=False
    )
    enum.create(op.get_bind(), checkfirst=False)
    op.create_table(
        'region_percentage',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('percentage', sa.Integer(), nullable=True),
        sa.Column('region', enum, nullable=False),
        sa.Column('activity_id', sa.Unicode(), nullable=False),
        sa.ForeignKeyConstraint(['activity_id'], ['activity.iati_identifier'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )
def upgrade():
    package_type = ENUM(
        "bdist_dmg", "bdist_dumb", "bdist_egg", "bdist_msi", "bdist_rpm",
        "bdist_wheel", "bdist_wininst", "sdist",
        name="package_type",
        create_type=False,
    )
    package_type.create(op.get_bind(), checkfirst=False)

    op.execute(
        """ ALTER TABLE release_files
                ALTER COLUMN packagetype
                TYPE package_type
                USING packagetype::package_type
        """
    )
def upgrade():
    context = op.get_context()

    # Upgrading to this revision WILL clear your directmedia values.
    if context.bind.dialect.name != "postgresql":
        op.alter_column("sippeers", "directmedia", type_=new_type, existing_type=old_type)
    else:
        enum = ENUM("yes", "no", "nonat", "update", "outgoing", name="sip_directmedia_values_v2")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute(
            "ALTER TABLE sippeers ALTER COLUMN directmedia TYPE"
            " sip_directmedia_values_v2 USING"
            " directmedia::text::sip_directmedia_values_v2"
        )

        ENUM(name="sip_directmedia_values").drop(op.get_bind(), checkfirst=False)
def downgrade():
    context = op.get_context()

    if context.bind.dialect.name != 'postgresql':
        op.alter_column('ps_endpoints', 'dtmf_mode',
                        type_=old_type,
                        existing_type=new_type)
    else:
        enum = ENUM('rfc4733', 'inband', 'info',
                    name='pjsip_dtmf_mode_values')
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
                   ' pjsip_dtmf_mode_values USING'
                   ' dtmf_mode::text::pjsip_dtmf_mode_values')

        ENUM(name="pjsip_dtmf_mode_values_v2").drop(op.get_bind(), checkfirst=False)
def upgrade():
    context = op.get_context()

    # Upgrading to this revision WILL clear your directmedia values.
    if context.bind.dialect.name != 'postgresql':
        op.alter_column('ps_endpoints', 'dtmf_mode',
                        type_=new_type,
                        existing_type=old_type)
    else:
        enum = ENUM('rfc4733', 'inband', 'info', 'auto',
                    name='pjsip_dtmf_mode_values_v2')
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE ps_endpoints ALTER COLUMN dtmf_mode TYPE'
                   ' pjsip_dtmf_mode_values_v2 USING'
                   ' dtmf_mode::text::pjsip_dtmf_mode_values_v2')

        ENUM(name="pjsip_dtmf_mode_values").drop(op.get_bind(), checkfirst=False)
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    enum = ENUM('unverified', 'valid', 'rejected',          name='nu_item_enum', create_type=False)
    enum.create(op.get_bind(), checkfirst=True)

    op.execute("ALTER TABLE nu_release_item ALTER COLUMN reviewed DROP DEFAULT")

    op.alter_column('nu_release_item', 'reviewed',
               existing_type=sa.BOOLEAN(),
               type_=enum,
               existing_nullable=False,
               nullable=False,
               server_default=sa.text("'unverified'"),
               existing_server_default=sa.text('false'),
               postgresql_using="CASE WHEN reviewed = false THEN 'unverified'::nu_item_enum ELSE 'valid'::nu_item_enum END"
               )

    op.execute("ALTER TABLE nu_release_item ALTER COLUMN reviewed SET DEFAULT 'unverified'")
def downgrade():
    context = op.get_context()

    op.execute(tcr.update().where(tcr.c.directmedia == u"outgoing").values(directmedia=None))

    if context.bind.dialect.name != "postgresql":
        op.alter_column("sippeers", "directmedia", type_=old_type, existing_type=new_type)
    else:
        enum = ENUM("yes", "no", "nonat", "update", name="sip_directmedia_values")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute(
            "ALTER TABLE sippeers ALTER COLUMN directmedia TYPE"
            " sip_directmedia_values USING"
            " directmedia::text::sip_directmedia_values"
        )

        ENUM(name="sip_directmedia_values_v2").drop(op.get_bind(), checkfirst=False)
def upgrade():
    context = op.get_context()

    # Upgrading to this revision WILL clear your directmedia values.
    if context.bind.dialect.name == 'sqlite':
        with op.batch_alter_table('sippeers') as batch_op:
            batch_op.alter_column('directmedia', type_=new_type)
    elif context.bind.dialect.name != 'postgresql':
        op.alter_column('sippeers', 'directmedia',
                        type_=new_type,
                        existing_type=old_type)
    else:
        enum = ENUM("yes", "no", "nonat", "update", "outgoing",
                    name="sip_directmedia_values_v2")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
                   ' sip_directmedia_values_v2 USING'
                   ' directmedia::text::sip_directmedia_values_v2')

        ENUM(name="sip_directmedia_values").drop(op.get_bind(), checkfirst=False)
def downgrade():

    provider_enum = ENUM("loadtesting", "firetext", "mmg", "ses", "twilio", name="providers", create_type=True)
    provider_enum.create(op.get_bind(), checkfirst=False)

    op.add_column("provider_statistics", sa.Column("provider", provider_enum, autoincrement=False, nullable=True))
    op.alter_column("provider_statistics", "provider_id", existing_type=postgresql.UUID(), nullable=True)
    op.add_column("provider_rates", sa.Column("provider", provider_enum, autoincrement=False, nullable=True))
    op.alter_column("provider_rates", "provider_id", existing_type=postgresql.UUID(), nullable=True)

    op.execute(
        "UPDATE provider_rates set provider = 'mmg' where provider_id = (select id from provider_details where identifier = 'mmg')"
    )
    op.execute(
        "UPDATE provider_rates set provider = 'firetext' where provider_id = (select id from provider_details where identifier = 'firetext')"
    )
    op.execute(
        "UPDATE provider_rates set provider = 'ses' where provider_id = (select id from provider_details where identifier = 'ses')"
    )
    op.execute(
        "UPDATE provider_rates set provider = 'loadtesting' where provider_id = (select id from provider_details where identifier = 'loadtesting')"
    )

    op.execute(
        "UPDATE provider_statistics set provider = 'mmg' where provider_id = (select id from provider_details where identifier = 'mmg')"
    )
    op.execute(
        "UPDATE provider_statistics set provider = 'firetext' where provider_id = (select id from provider_details where identifier = 'firetext')"
    )
    op.execute(
        "UPDATE provider_statistics set provider = 'ses' where provider_id = (select id from provider_details where identifier = 'ses')"
    )
    op.execute(
        "UPDATE provider_statistics set provider = 'loadtesting' where provider_id = (select id from provider_details where identifier = 'loadtesting')"
    )

    op.alter_column("provider_rates", "provider", existing_type=postgresql.UUID(), nullable=False)

    op.alter_column("provider_statistics", "provider", existing_type=postgresql.UUID(), nullable=False)
def downgrade():
    context = op.get_context()

    op.execute(tcr.update().where(tcr.c.directmedia==u'outgoing')
               .values(directmedia=None))

    if context.bind.dialect.name == 'sqlite':
        with op.batch_alter_table('sippeers') as batch_op:
            batch_op.alter_column('directmedia', type_=old_type)
    elif context.bind.dialect.name != 'postgresql':
        op.alter_column('sippeers', 'directmedia',
                        type_=old_type,
                        existing_type=new_type)
    else:
        enum = ENUM("yes", "no", "nonat", "update",
                    name="sip_directmedia_values")
        enum.create(op.get_bind(), checkfirst=False)

        op.execute('ALTER TABLE sippeers ALTER COLUMN directmedia TYPE'
                   ' sip_directmedia_values USING'
                   ' directmedia::text::sip_directmedia_values')

        ENUM(name="sip_directmedia_values_v2").drop(op.get_bind(),
                                                checkfirst=False)