def upgrade(active_plugins=None, options=None):
    if not migration.should_run(active_plugins, migration_for_plugins):
        return

    op.create_table(
        'lsn',
        sa.Column('net_id',
                  sa.String(length=36), nullable=False),
        sa.Column('lsn_id',
                  sa.String(length=36), nullable=False),
        sa.PrimaryKeyConstraint('lsn_id'))

    op.create_table(
        'lsn_port',
        sa.Column('lsn_port_id',
                  sa.String(length=36), nullable=False),
        sa.Column('lsn_id',
                  sa.String(length=36), nullable=False),
        sa.Column('sub_id',
                  sa.String(length=36), nullable=False, unique=True),
        sa.Column('mac_addr',
                  sa.String(length=32), nullable=False, unique=True),
        sa.ForeignKeyConstraint(['lsn_id'], ['lsn.lsn_id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('lsn_port_id'))
示例#2
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE')
    )

    from dexter.models import Role, User, db
    for r in Role.create_defaults():
        db.session.add(r)
    db.session.commit()

    # give all current users the monitor role
    monitor = Role.query.filter(Role.name == 'monitor').one()
    for u in User.query.all():
        u.roles = [monitor]
    db.session.commit()
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('testjob', 'caseorder')
    op.create_table('test',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('jobName', sa.VARCHAR(length=64), nullable=True),
    sa.Column('jobType', sa.INTEGER(), nullable=True),
    sa.Column('relateCases', sa.BLOB(), nullable=True),
    sa.Column('relateDevices', sa.BLOB(), nullable=True),
    sa.Column('testapk', sa.VARCHAR(length=512), nullable=True),
    sa.Column('appPackage', sa.VARCHAR(length=64), nullable=True),
    sa.Column('appActivity', sa.VARCHAR(length=64), nullable=True),
    sa.Column('result', sa.INTEGER(), nullable=True),
    sa.Column('reportID', sa.INTEGER(), nullable=True),
    sa.Column('status', sa.INTEGER(), nullable=True),
    sa.Column('createdtime', sa.DATETIME(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('email', sa.VARCHAR(length=64), nullable=True),
    sa.Column('username', sa.VARCHAR(length=64), nullable=True),
    sa.Column('password', sa.VARCHAR(length=128), nullable=True),
    sa.Column('createdtime', sa.DATETIME(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
示例#4
0
def upgrade():
    op.drop_table('metrics')
    op.create_table('metrics_historical',
                    sa.Column('timestamp', sa.DateTime(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('challenge_slug', sa.String(), nullable=False),
                    sa.Column('status', sa.String(), nullable=False),
                    sa.Column('count', sa.Integer(), nullable=True),
                    sa.PrimaryKeyConstraint('timestamp',
                                            'user_id',
                                            'challenge_slug',
                                            'status')
                    )
    op.create_index('idx_metrics_challengeslug',
                    'metrics_historical',
                    ['challenge_slug'],
                    unique=False)
    op.create_index('idx_metrics_status',
                    'metrics_historical',
                    ['status'],
                    unique=False)
    op.create_index('idx_metrics_userid',
                    'metrics_historical',
                    ['user_id'],
                    unique=False)
    op.create_table('metrics_aggregate',
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('challenge_slug', sa.String(), nullable=False),
                    sa.Column('status', sa.String(), nullable=False),
                    sa.Column('count', sa.Integer(), nullable=True),
                    sa.PrimaryKeyConstraint('user_id',
                                            'challenge_slug',
                                            'status')
                    )
示例#5
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles_authorities',
    sa.Column('authority_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['authority_id'], ['authorities.id'], ),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], )
    )
    op.create_index('roles_authorities_ix', 'roles_authorities', ['authority_id', 'role_id'], unique=True)
    op.create_table('roles_certificates',
    sa.Column('certificate_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['certificate_id'], ['certificates.id'], ),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], )
    )
    op.create_index('roles_certificates_ix', 'roles_certificates', ['certificate_id', 'role_id'], unique=True)
    op.create_index('certificate_associations_ix', 'certificate_associations', ['domain_id', 'certificate_id'], unique=True)
    op.create_index('certificate_destination_associations_ix', 'certificate_destination_associations', ['destination_id', 'certificate_id'], unique=True)
    op.create_index('certificate_notification_associations_ix', 'certificate_notification_associations', ['notification_id', 'certificate_id'], unique=True)
    op.create_index('certificate_replacement_associations_ix', 'certificate_replacement_associations', ['certificate_id', 'certificate_id'], unique=True)
    op.create_index('certificate_source_associations_ix', 'certificate_source_associations', ['source_id', 'certificate_id'], unique=True)
    op.create_index('roles_users_ix', 'roles_users', ['user_id', 'role_id'], unique=True)

    ### end Alembic commands ###

    # migrate existing authority_id relationship to many_to_many
    conn = op.get_bind()
    for id, authority_id in conn.execute(text('select id, authority_id from roles where authority_id is not null')):
        stmt = text('insert into roles_authorities (role_id, authority_id) values (:role_id, :authority_id)')
        stmt = stmt.bindparams(role_id=id, authority_id=authority_id)
        op.execute(stmt)
def upgrade():
    op.create_table('venue',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=False),
        sa.Column('proposal_space_id', sa.Integer(), nullable=False),
        sa.Column('description_text', sa.UnicodeText(), nullable=False),
        sa.Column('description_html', sa.UnicodeText(), nullable=False),
        sa.Column('address1', sa.Unicode(length=160), nullable=False),
        sa.Column('address2', sa.Unicode(length=160), nullable=False),
        sa.Column('city', sa.Unicode(length=30), nullable=False),
        sa.Column('state', sa.Unicode(length=30), nullable=False),
        sa.Column('postcode', sa.Unicode(length=20), nullable=False),
        sa.Column('country', sa.Unicode(length=2), nullable=False),
        sa.Column('latitude', sa.Numeric(precision=8, scale=5), nullable=True),
        sa.Column('longitude', sa.Numeric(precision=8, scale=5), nullable=True),
        sa.Column('name', sa.Unicode(length=250), nullable=False),
        sa.Column('title', sa.Unicode(length=250), nullable=False),
        sa.ForeignKeyConstraint(['proposal_space_id'], ['proposal_space.id'], ),
        sa.UniqueConstraint('proposal_space_id', 'name'),
        sa.PrimaryKeyConstraint('id')
        )
    op.create_table('venue_room',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=False),
        sa.Column('venue_id', sa.Integer(), nullable=False),
        sa.Column('description_text', sa.UnicodeText(), nullable=False),
        sa.Column('description_html', sa.UnicodeText(), nullable=False),
        sa.Column('name', sa.Unicode(length=250), nullable=False),
        sa.Column('title', sa.Unicode(length=250), nullable=False),
        sa.ForeignKeyConstraint(['venue_id'], ['venue.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('venue_id', 'name')
        )
def upgrade():
    op.create_table(
        'a10_certificates',
        sa.Column('tenant_id', sa.String(255), nullable=True),
        sa.Column('id', sa.String(36), primary_key=True, nullable=False),
        sa.Column('created_at', sa.DateTime, nullable=False),
        sa.Column('updated_at', sa.DateTime, nullable=False),
        sa.Column('name', sa.String(255), nullable=False),
        sa.Column('description', sa.Text(1024), nullable=True),
        sa.Column('cert_data', sa.Text(8000), nullable=False),
        sa.Column('key_data', sa.Text(8000), nullable=False),
        sa.Column('intermediate_data', sa.Text(8000), nullable=True),
        sa.Column('password', sa.String(1024), nullable=True),
    )

    op.create_table(
        'a10_certificatelistenerbindings',
        sa.Column('id', sa.String(36), primary_key=True, nullable=False),
        sa.Column('created_at', sa.DateTime, nullable=False),
        sa.Column('updated_at', sa.DateTime, nullable=False),
        sa.Column('tenant_id', sa.String(36), nullable=False),
        sa.Column('certificate_id', sa.String(36),
                  sa.ForeignKey(u'a10_certificates.id'),
                  nullable=False),
        sa.Column('listener_id', sa.String(36), nullable=False)
    )
def upgrade():
    url = context.config.powervc_config.DATABASE.connection
    engine = session.create_engine(url)
    # In previous release, we do not use alembic or any other migration,
    # as we need to support migration case, we need to check if the table
    # exists or not
    if engine.dialect.has_table(engine.connect(), tablename):
        alembic_util.msg("table has been already exists!")
        return
    op.create_table(
        tablename,
        sa.Column('id', sa.String(36),
                  primary_key=True,
                  default=uuidutils.generate_uuid),
        sa.Column('obj_type', sa.Enum(constants.OBJ_TYPE_NETWORK,
                                      constants.OBJ_TYPE_SUBNET,
                                      constants.OBJ_TYPE_PORT,
                                      name='mapping_object_type'),
                  nullable=False),
        sa.Column('status', sa.Enum(constants.STATUS_CREATING,
                                    constants.STATUS_ACTIVE,
                                    constants.STATUS_DELETING,
                                    name='mapping_state'),
                  nullable=False),
        sa.Column('sync_key', sa.String(255), nullable=False),
        sa.Column('local_id', sa.String(36)),
        sa.Column('pvc_id', sa.String(36)),
        sa.Column('update_data', sa.String(512))
    )
def upgrade():
    op.create_table(
        'vpn_endpoint_groups',
        sa.Column('id', sa.String(length=36), nullable=False,
                  primary_key=True),
        sa.Column('tenant_id', sa.String(length=attr.TENANT_ID_MAX_LEN),
                  index=True),
        sa.Column('name', sa.String(length=attr.NAME_MAX_LEN)),
        sa.Column('description', sa.String(length=attr.DESCRIPTION_MAX_LEN)),
        sa.Column('endpoint_type',
                  sa.Enum(constants.SUBNET_ENDPOINT, constants.CIDR_ENDPOINT,
                          constants.VLAN_ENDPOINT, constants.NETWORK_ENDPOINT,
                          constants.ROUTER_ENDPOINT,
                          name='endpoint_type'),
                  nullable=False),
    )
    op.create_table(
        'vpn_endpoints',
        sa.Column('endpoint', sa.String(length=255), nullable=False),
        sa.Column('endpoint_group_id', sa.String(36), nullable=False),
        sa.ForeignKeyConstraint(['endpoint_group_id'],
                                ['vpn_endpoint_groups.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('endpoint', 'endpoint_group_id'),
    )
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'user', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=255), nullable=False),
        sa.Column('password', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('username'))
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('radio_hostlanguage',
    sa.Column('language_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('host_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['host_id'], [u'radio_host.id'], name=u'radio_hostlanguage_host_id_fkey'),
    sa.ForeignKeyConstraint(['language_id'], [u'radio_language.id'], name=u'radio_hostlanguage_language_id_fkey'),
    sa.PrimaryKeyConstraint()
    )
    op.create_table('radio_host',
    sa.Column('id', sa.INTEGER(), server_default="nextval('radio_host_id_seq'::regclass)", nullable=False),
    sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('title', sa.VARCHAR(length=8), autoincrement=False, nullable=True),
    sa.Column('firstname', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('middlename', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('lastname', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('email', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('additionalcontact', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
    sa.Column('phone_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('gender_code', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('privacy_code', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['phone_id'], [u'telephony_phonenumber.id'], name=u'radio_host_phone_id_fkey'),
    sa.PrimaryKeyConstraint('id', name=u'radio_host_pkey')
    )
示例#12
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('associate_disruption_pt_object',
    sa.Column('disruption_id', postgresql.UUID(), nullable=False),
    sa.Column('pt_object_id', postgresql.UUID(), nullable=False),
    sa.ForeignKeyConstraint(['disruption_id'], ['disruption.id'], ),
    sa.ForeignKeyConstraint(['pt_object_id'], ['pt_object.id'], ),
    sa.PrimaryKeyConstraint('disruption_id', 'pt_object_id', name='disruption_pt_object_pk')
    )
    connection = op.get_bind()
    result = connection.execute('select pt.id as pt_id, dd.id as dis_id, dd.created_at as created_at,'
                                ' dd.localization_id as loc_id '
                                'from disruption as dd left OUTER join pt_object as pt '
                                'on pt.uri = dd.localization_id')
    for row in result:
        # Pt_object exist in database
        if row['pt_id']:
            pt_object_id = row['pt_id']
        else:
            # Pt_object not exist in database
            op.execute("INSERT INTO pt_object (created_at, id, type, uri) VALUES ('{}', '{}', '{}', '{}')".
                       format(row['created_at'], row['dis_id'], 'stop_area', row['loc_id']))
            pt_object_id = row['dis_id']

        op.execute("INSERT INTO associate_disruption_pt_object (disruption_id, pt_object_id) VALUES ('{}', '{}')".
                   format(row['dis_id'], pt_object_id))

    op.drop_column(u'disruption', 'localization_id')
示例#13
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('videos',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('site', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('keyvalue',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('value', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
示例#15
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('carpark',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('auto_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.Unicode(), nullable=True),
    sa.Column('operator', sa.Unicode(), nullable=True),
    sa.Column('scheme_status', sa.Unicode(), nullable=True),
    sa.Column('part_time_award', sa.Unicode(), nullable=True),
    sa.Column('phone', sa.Unicode(), nullable=True),
    sa.Column('street_1', sa.Unicode(), nullable=True),
    sa.Column('street_2', sa.Unicode(), nullable=True),
    sa.Column('street_3', sa.Unicode(), nullable=True),
    sa.Column('town', sa.Unicode(), nullable=True),
    sa.Column('county', sa.Unicode(), nullable=True),
    sa.Column('postcode', sa.Unicode(), nullable=True),
    sa.Column('physical_type', sa.Unicode(), nullable=True),
    sa.Column('payment_type', sa.Unicode(), nullable=True),
    sa.Column('number_of_spaces', sa.Integer(), nullable=True),
    sa.Column('disabled_spaces', sa.Integer(), nullable=True),
    sa.Column('cycles', sa.Unicode(), nullable=True),
    sa.Column('motobike', sa.Unicode(), nullable=True),
    sa.Column('cars', sa.Unicode(), nullable=True),
    sa.Column('bus', sa.Unicode(), nullable=True),
    sa.Column('coach', sa.Unicode(), nullable=True),
    sa.Column('truck_parking_area', sa.Unicode(), nullable=True),
    sa.Column('longitude', sa.Unicode(), nullable=True),
    sa.Column('latitude', sa.Unicode(), nullable=True),
    sa.Column('geom', geoalchemy2.types.Geography(spatial_index=False), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
示例#16
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('whisky',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('distillery', sa.String(length=64), nullable=True),
    sa.Column('slug', sa.String(length=64), nullable=True),
    sa.Column('body', sa.Integer(), nullable=True),
    sa.Column('sweetness', sa.Integer(), nullable=True),
    sa.Column('smoky', sa.Integer(), nullable=True),
    sa.Column('medicinal', sa.Integer(), nullable=True),
    sa.Column('tobacco', sa.Integer(), nullable=True),
    sa.Column('honey', sa.Integer(), nullable=True),
    sa.Column('spicy', sa.Integer(), nullable=True),
    sa.Column('winey', sa.Integer(), nullable=True),
    sa.Column('nutty', sa.Integer(), nullable=True),
    sa.Column('malty', sa.Integer(), nullable=True),
    sa.Column('fruity', sa.Integer(), nullable=True),
    sa.Column('floral', sa.Integer(), nullable=True),
    sa.Column('postcode', sa.String(length=16), nullable=True),
    sa.Column('latitude', sa.Integer(), nullable=True),
    sa.Column('longitude', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(u'ix_whisky_distillery', 'whisky', ['distillery'], unique=True)
    op.create_index(u'ix_whisky_slug', 'whisky', ['slug'], unique=True)
    op.create_table('correlation',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('reference', sa.Integer(), nullable=True),
    sa.Column('whisky', sa.Integer(), nullable=True),
    sa.Column('r', sa.Float(), nullable=True),
    sa.ForeignKeyConstraint(['whisky'], ['whisky.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(u'ix_correlation_r', 'correlation', ['r'], unique=False)
    op.create_index(u'ix_correlation_reference', 'correlation', ['reference'], unique=False)
示例#17
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('URL',
    sa.Column('link', sa.String(length=50), nullable=False),
    sa.Column('ID', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('link')
    )
def upgrade():
    op.create_table('arquero',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('email', sa.String(250), nullable=True, unique=True),
        sa.Column('nombre', sa.String(1024), nullable=False),
        sa.Column('apellido', sa.String(1024), nullable=False)
    )
def upgrade():
    op.create_table(
        'user',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('username', sa.Unicode(255), index=True, nullable=False),
        sa.Column('phone_number', sa.Unicode(45)),
        sa.Column('use_two_factor', sa.Enum('none', 'sms', 'voice',
                                            'authenticator',
                                            name='two_factor_types'),
                  server_default='none', nullable=False)
    )

    op.create_table(
        'cci_template',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('title', sa.Unicode(255), index=True, nullable=False),
        sa.Column('os', sa.Unicode(255)),
        sa.Column('cpus', sa.Integer, nullable=False, server_default='0'),
        sa.Column('memory', sa.Integer, nullable=False, server_default='0'),
        sa.Column('network', sa.Integer, nullable=False, server_default='100'),
        sa.Column('private_network_only', sa.Boolean, nullable=False,
                  server_default='0'),
        sa.Column('dedicated_host', sa.Boolean, nullable=False,
                  server_default='0'),
        sa.Column('owner_id', sa.Integer, sa.ForeignKey('user.id'))
    )
def upgrade():
    op.create_table(
        'user',
        sa.Column('login', sa.Unicode(100), primary_key=True),
        sa.Column('name', sa.Unicode(100)),
        sa.Column('password', sa.Unicode(100)),
        sa.Column('email', sa.Unicode(100)))
示例#21
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('allowed_service_urls',
    sa.Column('id', sa.String(), nullable=False),
    sa.Column('service_url', sa.String(), nullable=True),
    sa.Column('tenant', sa.String(), nullable=True),
    sa.Column('info', sa.String(), nullable=True),
    sa.Column('created_at', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('service_url_to_cloudify_with_limits',
    sa.Column('id', sa.String(), nullable=False),
    sa.Column('deployment_limits', sa.Integer(), nullable=True),
    sa.Column('number_of_deployments', sa.Integer(), nullable=True),
    sa.Column('cloudify_host', sa.String(), nullable=True),
    sa.Column('cloudify_port', sa.String(), nullable=True),
    sa.Column('created_at', sa.String(), nullable=True),
    sa.Column('updated_at', sa.String(), nullable=True),
    sa.Column('serviceurl_id', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['serviceurl_id'], ['allowed_service_urls.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('org_id_to_cloudify_with_limits')
    op.drop_table('allowed_org_ids')
    op.drop_table('keystore_url_to_cloudify_with_limits')
    op.drop_table('allowed_ketstore_urls')
示例#22
0
def create_new_tables():
    print("Create remaining tables")
    bind = op.get_bind()
    Admin.__table__.create(bind)
    #op.drop_table("Challenges")
    op.create_table('challenge',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('transaction_id', sa.Unicode(length=64), nullable=False),
    sa.Column('data', sa.Unicode(length=512), nullable=True),
    sa.Column('challenge', sa.Unicode(length=512), nullable=True),
    sa.Column('session', sa.Unicode(length=512), nullable=True),
    sa.Column('serial', sa.Unicode(length=40), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('expiration', sa.DateTime(), nullable=True),
    sa.Column('received_count', sa.Integer(), nullable=True),
    sa.Column('otp_valid', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )

    # drop old tables
    op.drop_table("MachineTokenOptions")
    op.drop_table("MachineUserOptions")
    op.drop_table("MachineUser")
    op.drop_table("MachineToken")
    op.drop_table("ClientMachine")

    op.drop_table("TokenRealm_old")
    op.drop_table("Realm_old")
    op.drop_table("Token_old")
示例#23
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('site_administration',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('allow_user_registrations', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
def upgrade(active_plugins=None, options=None):
    if not migration.should_run(active_plugins, migration_for_plugins):
        return

    op.create_table(
        'dvr_host_macs',
        sa.Column('host', sa.String(length=255), nullable=False),
        sa.Column('mac_address', sa.String(length=32),
                  nullable=False, unique=True),
        sa.PrimaryKeyConstraint('host')
    )
    op.create_table(
        'ml2_dvr_port_bindings',
        sa.Column('port_id', sa.String(length=36), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=False),
        sa.Column('router_id', sa.String(length=36), nullable=True),
        sa.Column('vif_type', sa.String(length=64), nullable=False),
        sa.Column('vif_details', sa.String(length=4095),
                  nullable=False, server_default=''),
        sa.Column('vnic_type', sa.String(length=64),
                  nullable=False, server_default='normal'),
        sa.Column('profile', sa.String(length=4095),
                  nullable=False, server_default=''),
        sa.Column('cap_port_filter', sa.Boolean(), nullable=False),
        sa.Column('driver', sa.String(length=64), nullable=True),
        sa.Column('segment', sa.String(length=36), nullable=True),
        sa.Column(u'status', sa.String(16), nullable=False),
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['segment'], ['ml2_network_segments.id'],
                                ondelete='SET NULL'),
        sa.PrimaryKeyConstraint('port_id', 'host')
    )
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('title_page_data',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('resource_id', sa.String(), nullable=False),
    sa.Column('title', sa.String(), nullable=True),
    sa.Column('authorOne', sa.String(), nullable=True),
    sa.Column('authorTwo', sa.String(), nullable=True),
    sa.Column('authorTwoChecked', sa.String(), nullable=True),
    sa.Column('authorThree', sa.String(), nullable=True),
    sa.Column('authorThreeChecked', sa.String(), nullable=True),
    sa.Column('based_on', sa.String(), nullable=True),
    sa.Column('based_onChecked', sa.String(), nullable=True),
    sa.Column('address', sa.String(), nullable=True),
    sa.Column('addressChecked', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('phoneChecked', sa.String(), nullable=True),
    sa.Column('cell', sa.String(), nullable=True),
    sa.Column('cellChecked', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('emailChecked', sa.String(), nullable=True),
    sa.Column('registered', sa.String(), nullable=True),
    sa.Column('registeredChecked', sa.String(), nullable=True),
    sa.Column('other', sa.String(), nullable=True),
    sa.Column('otherChecked', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('resource_id')
    )
    op.create_index('ix_title_page_data_resource_id', 'title_page_data', ['resource_id'], unique=False)
示例#26
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('meta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('last_edited', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
def upgrade():
    op.create_table(
			'user',
			sa.Column('username', sa.String(50), primary_key=True),
			sa.Column('first_name',sa.String(50)),
			sa.Column('last_name',sa.String(50)),
		)
def upgrade():
    op.create_table(u'exploitability_reports',
    sa.Column(u'signature_id', sa.INTEGER(), nullable=False),
    sa.Column(u'report_date', sa.DATE(), nullable=False),
    sa.Column(u'null_count', sa.INTEGER(), server_default='0', nullable=False),
    sa.Column(u'none_count', sa.INTEGER(), server_default='0', nullable=False),
    sa.Column(u'low_count', sa.INTEGER(), server_default='0', nullable=False),
    sa.Column(u'medium_count', sa.INTEGER(), server_default='0', nullable=False),
    sa.Column(u'high_count', sa.INTEGER(), server_default='0', nullable=False),
    sa.ForeignKeyConstraint(['signature_id'], [u'signatures.signature_id'], ),
    sa.PrimaryKeyConstraint()
    )
    # We can probably get away with just applying this to the parent table
    # If there are performance problems on stage, break this out and apply to all
    # child partitions first, then reports_clean last.
    op.add_column(u'reports_clean', sa.Column(u'exploitability', sa.TEXT(), nullable=True))
    app_path=os.getcwd()
    procs = [
        '001_update_reports_clean.sql'
        , 'update_exploitability.sql'
        , 'backfill_exploitability.sql'
     ]
    for myfile in [app_path + '/socorro/external/postgresql/raw_sql/procs/' + line for line in procs]:
        proc = open(myfile, 'r').read()
        op.execute(proc)
def upgrade():
	op.create_table(
        'User',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('username', sa.String(100), nullable=False, unique=True),
        sa.Column('lastTweet', sa.String(200)),
    )
def upgrade():
    op.create_table('portgroups',
                    sa.Column('created_at', sa.DateTime(), nullable=True),
                    sa.Column('updated_at', sa.DateTime(), nullable=True),
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('uuid', sa.String(length=36), nullable=True),
                    sa.Column('name', sa.String(length=255), nullable=True),
                    sa.Column('node_id', sa.Integer(), nullable=True),
                    sa.Column('address', sa.String(length=18), nullable=True),
                    sa.Column('extra', sa.Text(), nullable=True),
                    sa.ForeignKeyConstraint(['node_id'], ['nodes.id'], ),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('uuid', name='uniq_portgroups0uuid'),
                    sa.UniqueConstraint('address',
                                        name='uniq_portgroups0address'),
                    sa.UniqueConstraint('name', name='uniq_portgroups0name'),
                    mysql_ENGINE='InnoDB',
                    mysql_DEFAULT_CHARSET='UTF8')
    op.add_column(u'ports', sa.Column('local_link_connection', sa.Text(),
                                      nullable=True))
    op.add_column(u'ports', sa.Column('portgroup_id', sa.Integer(),
                                      nullable=True))
    op.add_column(u'ports', sa.Column('pxe_enabled', sa.Boolean(),
                                      default=True))
    op.create_foreign_key('fk_portgroups_ports', 'ports', 'portgroups',
                          ['portgroup_id'], ['id'])
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.rename_table('user', 'temp_user')
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False, autoincrement=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('password', sa.String(length=128), nullable=True),
    sa.Column('reset_password', sa.String(length=128), nullable=True),
    sa.Column('salt', sa.String(length=128), nullable=True),
    sa.Column('avatar', sa.String(), nullable=True),
    sa.Column('tokens', sa.Text(), nullable=True),
    sa.Column('is_super_admin', sa.Boolean(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.Column('is_verified', sa.Boolean(), nullable=True),
    sa.Column('signup_at', sa.DateTime(), nullable=True),
    sa.Column('last_accessed_at', sa.DateTime(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('deleted_at', sa.DateTime(), nullable=True),
    sa.Column('firstname', sa.String(), nullable=True),
    sa.Column('lastname', sa.String(), nullable=True),
    sa.Column('details', sa.String(), nullable=True),
    sa.Column('contact', sa.String(), nullable=True),
    sa.Column('facebook', sa.String(), nullable=True),
    sa.Column('twitter', sa.String(), nullable=True),
    sa.Column('instagram', sa.String(), nullable=True),
    sa.Column('google', sa.String(), nullable=True),
    sa.Column('avatar_uploaded', sa.String(), nullable=True),
    sa.Column('thumbnail', sa.String(), nullable=True),
    sa.Column('small', sa.String(), nullable=True),
    sa.Column('icon', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )

    #for missing migrations from the naming schema refactor
    op.drop_constraint(u'session_microlocation_id_fkey', 'sessions', type_='foreignkey')
    op.create_foreign_key(u'sessions_microlocation_id_fkey', 'sessions', 'microlocations', ['microlocation_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'session_session_type_id_fkey','sessions', type_='foreignkey')
    op.create_foreign_key(u'sessions_session_type_id_fkey', 'sessions', 'session_types', ['session_type_id'], ['id'], ondelete = 'CASCADE')
    op.drop_constraint(u'ticket_event_id_fkey', 'tickets', type_='foreignkey')
    op.create_foreign_key(u'tickets_event_id_fkey', 'tickets', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'eventsusers_event_id_fkey', 'event_user', type_='foreignkey')
    op.create_foreign_key(u'event_user_event_id_fkey', 'event_user', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'social_link_event_id_fkey', 'social_links', type_='foreignkey')
    op.create_foreign_key(u'social_links_event_id_fkey', 'social_links', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'role_invite_event_id_fkey', 'role_invites', type_='foreignkey')
    op.create_foreign_key(u'role_invites_event_id_fkey', 'role_invites', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'email_notification_event_id_fkey', 'email_notifications', type_='foreignkey')
    op.create_foreign_key(u'email_notifications_event_id_fkey', 'email_notifications', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'session_event_id_fkey', 'sessions', type_='foreignkey')
    op.create_foreign_key(u'sessions_event_id_fkey', 'sessions', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'session_type_event_id_fkey', 'session_types', type_='foreignkey')
    op.create_foreign_key(u'session_types_event_id_fkey', 'session_types', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'microlocation_event_id_fkey', 'microlocations', type_='foreignkey')
    op.create_foreign_key(u'microlocations_event_id_fkey', 'microlocations', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'event_copyright_event_id_fkey', 'event_copyrights', type_='foreignkey')
    op.create_foreign_key(u'event_copyrights_event_id_fkey', 'event_copyrights', 'events', ['event_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'role_invite_role_id_fkey', 'role_invites', type_='foreignkey')
    op.create_foreign_key(u'role_invites_role_id_fkey', 'role_invites', 'roles', ['role_id'], ['id'], ondelete = 'CASCADE')

    op.execute(
        "INSERT INTO users SELECT temp_user.* , user_detail.firstname, user_detail.lastname, user_detail.details, user_detail.contact, user_detail.facebook, user_detail.twitter, user_detail.instagram, user_detail.google, user_detail.avatar_uploaded, user_detail.thumbnail, user_detail.small, user_detail.icon FROM temp_user INNER JOIN user_detail ON temp_user.id = user_detail.user_id",
        execution_options=None)

    op.drop_constraint(u'user_detail_user_id_fkey', 'user_detail', type_='foreignkey')
    op.drop_constraint(u'access_codes_marketer_id_fkey', 'access_codes', type_='foreignkey')
    op.create_foreign_key(u'access_codes_marketer_id_fkey', 'access_codes', 'users', ['marketer_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'booked_ticket_user_id_fkey', 'booked_ticket', type_='foreignkey')
    op.create_foreign_key(u'booked_ticket_user_id_fkey', 'booked_ticket', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'discount_codes_marketer_id_fkey', 'discount_codes', type_='foreignkey')
    op.create_foreign_key(u'discount_codes_marketer_id_fkey', 'discount_codes', 'users', ['marketer_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'email_notification_user_id_fkey', 'email_notifications', type_='foreignkey')
    op.create_foreign_key(u'email_notifications_user_id_fkey', 'email_notifications', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'event_invoices_user_id_fkey', 'event_invoices', type_='foreignkey')
    op.create_foreign_key(u'event_invoices_user_id_fkey', 'event_invoices', 'users', ['user_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'eventsusers_user_id_fkey', 'event_user', type_='foreignkey')
    op.create_foreign_key(u'event_user_user_id_fkey', 'event_user', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'import_jobs_user_id_fkey', 'import_jobs', type_='foreignkey')
    op.create_foreign_key(u'import_jobs_user_id_fkey', 'import_jobs', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'invites_user_id_fkey', 'invites', type_='foreignkey')
    op.create_foreign_key(u'invites_user_id_fkey', 'invites', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'notification_user_id_fkey', 'notification', type_='foreignkey')
    op.create_foreign_key(u'notification_user_id_fkey', 'notification', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'orders_user_id_fkey', 'orders', type_='foreignkey')
    op.drop_constraint(u'orders_marketer_id_fkey', 'orders', type_='foreignkey')
    op.create_foreign_key(u'orders_user_id_fkey', 'orders', 'users', ['user_id'], ['id'], ondelete='SET NULL')
    op.create_foreign_key(u'orders_marketer_id_fkey', 'orders', 'users', ['marketer_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'speaker_user_id_fkey', 'speaker', type_='foreignkey')
    op.create_foreign_key(u'speaker_user_id_fkey', 'speaker', 'users', ['user_id'], ['id'], ondelete='SET NULL')
    op.drop_constraint(u'transaction_user_id_fkey', 'transaction', type_='foreignkey')
    op.create_foreign_key(u'transaction_user_id_fkey', 'transaction', 'users', ['user_id'], ['id'])
    op.drop_constraint(u'user_system_role_user_id_fkey', 'user_system_role', type_='foreignkey')
    op.create_foreign_key(u'user_system_role_user_id_fkey', 'user_system_role', 'users', ['user_id'], ['id'], ondelete='CASCADE')
    op.drop_constraint(u'users_events_roles_user_id_fkey', 'users_events_roles', type_='foreignkey')
    op.create_foreign_key(u'users_events_roles_user_id_fkey', 'users_events_roles', 'users', ['user_id'], ['id'], ondelete='CASCADE')

    op.drop_table('temp_user')
    op.drop_table('user_detail')
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###

    op.create_table('temp_user',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('email', sa.VARCHAR(length=120), autoincrement=False, nullable=True),
    sa.Column('password', sa.VARCHAR(length=128), autoincrement=False, nullable=True),
    sa.Column('reset_password', sa.VARCHAR(length=128), autoincrement=False, nullable=True),
    sa.Column('salt', sa.VARCHAR(length=128), autoincrement=False, nullable=True),
    sa.Column('avatar', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('tokens', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('is_super_admin', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('is_admin', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('is_verified', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('signup_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('last_accessed_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('deleted_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name=u'user_pkey'),
    sa.UniqueConstraint('email', name=u'user_email_key'),
    postgresql_ignore_search_path=False
    )
    op.create_table('user_detail',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('firstname', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('lastname', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('details', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('avatar', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('contact', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('facebook', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('twitter', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('instagram', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('google', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('avatar_uploaded', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('thumbnail', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('small', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('icon', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name=u'user_detail_pkey')
    )

    op.drop_constraint(u'users_events_roles_user_id_fkey', 'users_events_roles', type_='foreignkey')
    op.create_foreign_key(u'users_events_roles_user_id_fkey', 'users_events_roles', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'user_system_role_user_id_fkey', 'user_system_role', type_='foreignkey')
    op.create_foreign_key(u'user_system_role_user_id_fkey', 'user_system_role', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'transaction_user_id_fkey', 'transaction', type_='foreignkey')
    op.create_foreign_key(u'transaction_user_id_fkey', 'transaction', 'temp_user', ['user_id'], ['id'])
    op.drop_constraint(u'speaker_user_id_fkey', 'speaker', type_='foreignkey')
    op.create_foreign_key(u'speaker_user_id_fkey', 'speaker', 'temp_user', ['user_id'], ['id'], ondelete=u'SET NULL')
    op.drop_constraint(u'orders_marketer_id_fkey', 'orders', type_='foreignkey')
    op.drop_constraint(u'orders_user_id_fkey', 'orders', type_='foreignkey')
    op.create_foreign_key(u'orders_marketer_id_fkey', 'orders', 'temp_user', ['marketer_id'], ['id'],
                          ondelete=u'SET NULL')
    op.create_foreign_key(u'orders_user_id_fkey', 'orders', 'temp_user', ['user_id'], ['id'], ondelete=u'SET NULL')
    op.drop_constraint(u'notification_user_id_fkey', 'notification', type_='foreignkey')
    op.create_foreign_key(u'notification_user_id_fkey', 'notification', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'invites_user_id_fkey', 'invites', type_='foreignkey')
    op.create_foreign_key(u'invites_user_id_fkey', 'invites', 'temp_user', ['user_id'], ['id'], ondelete=u'CASCADE')
    op.drop_constraint(u'import_jobs_user_id_fkey', 'import_jobs', type_='foreignkey')
    op.create_foreign_key(u'import_jobs_user_id_fkey', 'import_jobs', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'event_user_user_id_fkey', 'event_user', type_='foreignkey')
    op.create_foreign_key(u'event_user_user_id_fkey', 'event_user', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'event_invoices_user_id_fkey', 'event_invoices', type_='foreignkey')
    op.create_foreign_key(u'event_invoices_user_id_fkey', 'event_invoices', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'SET NULL')
    op.drop_constraint(u'email_notifications_user_id_fkey', 'email_notifications', type_='foreignkey')
    op.create_foreign_key(u'email_notifications_user_id_fkey', 'email_notifications', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'discount_codes_marketer_id_fkey', 'discount_codes', type_='foreignkey')
    op.create_foreign_key(u'discount_codes_marketer_id_fkey', 'discount_codes', 'temp_user', ['marketer_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'booked_ticket_user_id_fkey', 'booked_ticket', type_='foreignkey')
    op.create_foreign_key(u'booked_ticket_user_id_fkey', 'booked_ticket', 'temp_user', ['user_id'], ['id'],
                          ondelete=u'CASCADE')
    op.drop_constraint(u'access_codes_marketer_id_fkey', 'access_codes', type_='foreignkey')
    op.create_foreign_key(u'access_codes_marketer_id_fkey', 'access_codes', 'temp_user', ['marketer_id'], ['id'],
                          ondelete=u'CASCADE')
    op.create_foreign_key(u'user_detail_user_id_fkey', 'user_detail', 'temp_user', ['user_id'], ['id'], ondelete='CASCADE')

    op.execute("INSERT INTO temp_user SELECT id, email, password, reset_password, salt, avatar, tokens, is_super_admin, is_admin, is_verified, signup_at, last_accessed_at, created_at, deleted_at from users")
    op.execute("INSERT INTO user_detail SELECT id, firstname, lastname, details, avatar, contact, facebook, twitter, instagram, google, avatar_uploaded, thumbnail, small, icon, id from users")
    op.rename_table('temp_user', 'user')
    op.drop_table('users')
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('genre',
    sa.Column('id', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_genre_id'), 'genre', ['id'], unique=False)
    op.create_table('movie',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('imdb_id', sa.Integer(), nullable=True),
    sa.Column('tmdb_id', sa.Integer(), nullable=True),
    sa.Column('poster_path', sa.String(), nullable=True),
    sa.Column('release_date', sa.Date(), nullable=True),
    sa.Column('budget', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_movie_id'), 'movie', ['id'], unique=False)
    op.create_index(op.f('ix_movie_title'), 'movie', ['title'], unique=False)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
    op.create_table('movie_genre',
    sa.Column('movie', sa.Integer(), nullable=False),
    sa.Column('genre', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['genre'], ['genre.id'], ),
    sa.ForeignKeyConstraint(['movie'], ['movie.id'], ),
    sa.PrimaryKeyConstraint('movie', 'genre')
    )
    op.create_table('rating',
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('movie', sa.Integer(), nullable=False),
    sa.Column('rating', sa.Float(), nullable=False),
    sa.Column('timestamp', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['movie'], ['movie.id'], ),
    sa.ForeignKeyConstraint(['user'], ['users.id'], ),
    sa.PrimaryKeyConstraint('user', 'movie')
    )
    op.create_table('tag',
    sa.Column('user', sa.Integer(), nullable=False),
    sa.Column('movie', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('timestamp', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['movie'], ['movie.id'], ),
    sa.ForeignKeyConstraint(['user'], ['users.id'], ),
    sa.PrimaryKeyConstraint('user', 'movie', 'name')
    )
示例#34
0
def upgrade():
    registration_type_table = op.create_table(
        'registration_type',
        sa.Column('reg_type_cd', sa.CHAR(length=2), primary_key=True),
        sa.Column('description', postgresql.TEXT, nullable=False))

    op.bulk_insert(registration_type_table, [{
        'reg_type_cd':
        'SA',
        'description':
        'PPSA Security Agreement'
    }, {
        'reg_type_cd': 'RL',
        'description': "Repairer's Lien"
    }, {
        'reg_type_cd':
        'FR',
        'description':
        'Marriage/Separation Agreement affecting Manufactured Home under Family Law Act'
    }, {
        'reg_type_cd':
        'LT',
        'description':
        'Land Tax Deferment Lien on a Manufactured Home'
    }, {
        'reg_type_cd':
        'MH',
        'description':
        'Tax Lien under S.27/28 of the Manufactured Home Act'
    }, {
        'reg_type_cd':
        'SG',
        'description':
        'Possession under S.30 of the Sale of Goods Act'
    }, {
        'reg_type_cd':
        'FL',
        'description':
        'FORESTRY - Contractor Lien'
    }, {
        'reg_type_cd':
        'FA',
        'description':
        'FORESTRY - Contractor Charge'
    }, {
        'reg_type_cd':
        'FS',
        'description':
        'FORESTRY - Sub-contractor Charge'
    }, {
        'reg_type_cd':
        'MR',
        'description':
        'Miscellaneous Registration'
    }])

    registration_change_type_table = op.create_table(
        'registration_change_type',
        sa.Column('change_type_cd', sa.CHAR(length=2), primary_key=True),
        sa.Column('description', postgresql.TEXT, nullable=False))

    op.bulk_insert(registration_change_type_table,
                   [{
                       'change_type_cd': 'AC',
                       'description': 'Addition of Collateral'
                   }, {
                       'change_type_cd': 'DR',
                       'description': 'Debtor Release'
                   }, {
                       'change_type_cd': 'DT',
                       'description': 'Debtor Transfer'
                   }, {
                       'change_type_cd': 'PD',
                       'description': 'Partial Discharge'
                   }, {
                       'change_type_cd': 'ST',
                       'description': 'Secured Party Transfer'
                   }, {
                       'change_type_cd': 'SU',
                       'description': 'Substitution of Collateral'
                   }])

    crown_charge_type_table = op.create_table(
        'crown_charge_type',
        sa.Column('crown_charge_type_cd', sa.CHAR(length=2), primary_key=True),
        sa.Column('description', postgresql.TEXT, nullable=False))

    op.bulk_insert(crown_charge_type_table,
                   [{
                       'crown_charge_type_cd': 'SS',
                       'description': 'Social Service Tax'
                   }, {
                       'crown_charge_type_cd': 'IP',
                       'description': 'Insurance Premium Tax'
                   }, {
                       'crown_charge_type_cd': 'MR',
                       'description': 'Mineral Resource Tax'
                   }, {
                       'crown_charge_type_cd': 'PG',
                       'description': 'Petroleum & Natural Gas'
                   }, {
                       'crown_charge_type_cd': 'CC',
                       'description': 'Corporation Capital Tax'
                   }, {
                       'crown_charge_type_cd': 'ET',
                       'description': 'Excise Tax'
                   }, {
                       'crown_charge_type_cd': 'FO',
                       'description': 'Forest'
                   }, {
                       'crown_charge_type_cd': 'LO',
                       'description': 'Logging Tax'
                   }, {
                       'crown_charge_type_cd': 'CT',
                       'description': 'Carbon Tax'
                   }, {
                       'crown_charge_type_cd': 'RA',
                       'description': 'Rural Property Tax'
                   }, {
                       'crown_charge_type_cd': 'PS',
                       'description': 'Provincial Sales Tax'
                   }, {
                       'crown_charge_type_cd': 'DP',
                       'description': 'Consumption Tax and Transition Act'
                   }, {
                       'crown_charge_type_cd': 'HR',
                       'description': 'Hotel Room Tax'
                   }, {
                       'crown_charge_type_cd': 'MI',
                       'description': 'Mining Tax'
                   }, {
                       'crown_charge_type_cd': 'IT',
                       'description': 'Income Tax'
                   }, {
                       'crown_charge_type_cd': 'FT',
                       'description': 'Motor Fuel Tax'
                   }, {
                       'crown_charge_type_cd': 'WL',
                       'description': 'Lien for Unpaid Wages'
                   }, {
                       'crown_charge_type_cd': 'PN',
                       'description': 'Proceeds of Crime Notice'
                   }, {
                       'crown_charge_type_cd': 'HN',
                       'description': 'Heritage Conservation Notice'
                   }, {
                       'crown_charge_type_cd': 'MH',
                       'description': 'Manufactured Home Notice'
                   }, {
                       'crown_charge_type_cd': 'ML',
                       'description': 'Maintenance Lien'
                   }])
示例#35
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'presiden_blackhat',
        sa.Column('filename', sa.TEXT(), autoincrement=False, nullable=True))
示例#36
0
def upgrade():
    op.create_table(
        'order',
        Column('id', UUID(), nullable=False),
        Column('created_at', DateTime(timezone=True), nullable=False),
        Column('side', Enum('buy', 'sell', name='order_side'), nullable=False),
        Column('user_id', UUID(), nullable=False),
        Column('volume', Numeric(precision=36, scale=18), nullable=False),
        Column(
            'remaining_volume',
            Numeric(precision=36, scale=18),
            nullable=False,
        ),
        Column('price', Numeric(precision=36, scale=18), nullable=False),
        Column('filled_at', DateTime(timezone=True), nullable=True),
        Column('canceled_at', DateTime(timezone=True), nullable=True),
        Column('base_currency', Unicode(), nullable=False),
        Column('quote_currency', Unicode(), nullable=False),
        CheckConstraint('price > 0', name='ck_order_price_positive'),
        CheckConstraint(
            'volume > 0 AND '
            'remaining_volume >= 0 AND '
            'remaining_volume <= volume',
            name='ck_order_volume',
        ),
        CheckConstraint(
            'base_currency != quote_currency',
            name='ck_order_currency',
        ),
        CheckConstraint(
            'filled_at IS NULL OR remaining_volume = 0',
            name='ck_order_filled',
        ),
        CheckConstraint(
            'canceled_at IS NULL OR remaining_volume > 0',
            name='ck_order_canceled',
        ),
        ForeignKeyConstraint(
            ['base_currency', 'quote_currency'],
            ['market.base_currency', 'market.quote_currency'],
        ),
        ForeignKeyConstraint(
            ['base_currency'],
            ['currency.id'],
        ),
        ForeignKeyConstraint(
            ['quote_currency'],
            ['currency.id'],
        ),
        ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ),
        PrimaryKeyConstraint('id'),
        UniqueConstraint('id', 'base_currency', 'quote_currency'),
    )
    op.create_index(
        op.f('ix_order_created_at'),
        'order',
        ['created_at'],
        unique=False,
    )
    op.create_index(
        op.f('ix_order_user_id'),
        'order',
        ['user_id'],
        unique=False,
    )
示例#37
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'device', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=256), nullable=True),
        sa.Column('description', sa.String(length=2048), nullable=True),
        sa.Column('location', sa.String(length=1024), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('description'),
        sa.UniqueConstraint('name'))
    op.create_table(
        'issue', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=256), nullable=False),
        sa.Column('description', sa.String(length=1024), nullable=False),
        sa.Column('type',
                  sa.Enum('MAINT_REQD', 'EQUIP_DAMAGED', name='issuetype'),
                  nullable=False),
        sa.Column('device_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['device_id'],
            ['device.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table('security_config',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=120), nullable=False),
                    sa.Column('device_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['device_id'],
                        ['device.id'],
                    ), sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('name'))
    op.create_table(
        'sensor', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=120), nullable=True),
        sa.Column('identifier', sa.String(length=128), nullable=True),
        sa.Column('description', sa.String(length=1024), nullable=True),
        sa.Column('device_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['device_id'],
            ['device.id'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('identifier'),
        sa.UniqueConstraint('name'))
    op.create_table('server_config',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=120), nullable=False),
                    sa.Column('device_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['device_id'],
                        ['device.id'],
                    ), sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('name'))
    op.create_table(
        'config_item', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=256), nullable=False),
        sa.Column('description', sa.String(length=2048), nullable=False),
        sa.Column('value', sa.String(length=1024), nullable=False),
        sa.Column('sec_conf_id', sa.Integer(), nullable=True),
        sa.Column('serv_conf_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['sec_conf_id'],
            ['security_config.id'],
        ), sa.ForeignKeyConstraint(
            ['serv_conf_id'],
            ['server_config.id'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('description'),
        sa.UniqueConstraint('name'))
    op.create_table(
        'data_point', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('value', sa.Float(), nullable=False),
        sa.Column('unit',
                  sa.Enum('HZ', 'J', 'DB', 'F', 'C', 'KWH', name='unit'),
                  nullable=False),
        sa.Column('sensor_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['sensor_id'],
            ['sensor.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'user', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('first_name', sa.String(length=75), nullable=False),
        sa.Column('last_name', sa.String(length=75), nullable=False),
        sa.Column('email', sa.String(length=120), nullable=False),
        sa.Column('password_hash', sa.String(length=128), nullable=False),
        sa.Column('token', sa.String(length=32), nullable=True),
        sa.Column('role',
                  sa.Enum('USER',
                          'TECHNICIAN',
                          'MANAGER',
                          'ADMIN',
                          name='role'),
                  nullable=False),
        sa.Column('sec_conf_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['sec_conf_id'],
            ['security_config.id'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'),
        sa.UniqueConstraint('token'))
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('injured_position',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('injured_position_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='injured_position_pkey')
                    )
    op.create_table('cross_location',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('cross_location_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='cross_location_pkey')
                    )
    op.create_table('geo_area',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('geo_area_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='geo_area_pkey')
                    )
    op.create_table('road_intactness',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_intactness_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_intactness_pkey')
                    )
    op.create_table('road_surface',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_surface_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_surface_pkey')
                    )
    op.create_table('day_night',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('day_night_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='day_night_pkey')
                    )
    op.create_table('cross_direction',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('cross_direction_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='cross_direction_pkey')
                    )
    op.create_table('population_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('population_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='population_type_pkey')
                    )
    op.create_table('road_sign',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_sign_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_sign_pkey')
                    )
    op.create_table('road_object',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_object_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_object_pkey')
                    )
    op.create_table('age_group',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('age_group_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='age_group_pkey')
                    )
    op.create_table('location_accuracy',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('location_accuracy_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='location_accuracy_pkey')
                    )
    op.create_table('municipal_status',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('municipal_status_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='municipal_status_pkey')
                    )
    op.create_table('didnt_cross',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('didnt_cross_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='didnt_cross_pkey')
                    )
    op.create_table('road_control',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_control_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_control_pkey')
                    )
    op.create_table('medical_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('medical_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='medical_type_pkey')
                    )
    op.create_table('vehicle_attribution',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('vehicle_attribution_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='vehicle_attribution_pkey')
                    )
    op.create_table('sex',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('sex_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='sex_pkey')
                    )
    op.create_table('injury_severity',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('injury_severity_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='injury_severity_pkey')
                    )
    op.create_table('object_distance',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('object_distance_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='object_distance_pkey')
                    )
    op.create_table('vehicle_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('vehicle_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='vehicle_type_pkey')
                    )
    op.create_table('driving_directions',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('driving_directions_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='driving_directions_pkey')
                    )
    op.create_table('police_unit',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('police_unit_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='police_unit_pkey')
                    )
    op.create_table('safety_measures_use',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('safety_measures_use_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='safety_measures_use_pkey')
                    )
    op.create_table('vehicle_status',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('vehicle_status_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='vehicle_status_pkey')
                    )
    op.create_table('total_weight',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('total_weight_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='total_weight_pkey')
                    )
    op.create_table('yishuv_shape',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('yishuv_shape_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='yishuv_shape_pkey')
                    )
    op.create_table('provider_code',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('provider_code_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='provider_code_pkey')
                    )
    op.create_table('natural_area',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('natural_area_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='natural_area_pkey')
                    )
    op.create_table('accident_month',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('accident_month_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='accident_month_pkey')
                    )
    op.create_table('day_in_week',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('day_in_week_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='day_in_week_pkey')
                    )
    op.create_table('hospital_time',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('hospital_time_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='hospital_time_pkey')
                    )
    op.create_table('district',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('district_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='district_pkey')
                    )
    op.create_table('accident_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('accident_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='accident_type_pkey')
                    )
    op.create_table('day_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('day_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='day_type_pkey')
                    )
    op.create_table('injured_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('injured_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='injured_type_pkey')
                    )
    op.create_table('late_deceased',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('late_deceased_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='late_deceased_pkey')
                    )
    op.create_table('columns_description',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('column_description', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='columns_description_pkey')
                    )
    op.create_table('engine_volume',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('engine_volume_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='engine_volume_pkey')
                    )
    op.create_table('road_width',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_width_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_width_pkey')
                    )
    op.create_table('release_dest',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('release_dest_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='release_dest_pkey')
                    )
    op.create_table('one_lane',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('one_lane_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='one_lane_pkey')
                    )
    op.create_table('road_light',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_light_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_light_pkey')
                    )
    op.create_table('region',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('region_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='region_pkey')
                    )
    op.create_table('road_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_type_pkey')
                    )
    op.create_table('accident_severity',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('accident_severity_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='accident_severity_pkey')
                    )
    op.create_table('safety_measures',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('safety_measures_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='safety_measures_pkey')
                    )
    op.create_table('traffic_light',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('traffic_light_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='traffic_light_pkey')
                    )
    op.create_table('speed_limit',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('speed_limit_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='speed_limit_pkey')
                    )
    op.create_table('accident_hour_raw',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('accident_hour_raw_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='accident_hour_raw_pkey')
                    )
    op.create_table('involved_type',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('involved_type_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='involved_type_pkey')
                    )
    op.create_table('cross_mode',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('cross_mode_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='cross_mode_pkey')
                    )
    op.create_table('road_shape',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('road_shape_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='road_shape_pkey')
                    )
    op.create_table('multi_lane',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('multi_lane_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='multi_lane_pkey')
                    )
    op.create_table('weather',
                    sa.Column('id', sa.INTEGER(), nullable=False),
                    sa.Column('weather_hebrew', sa.TEXT(), autoincrement=False, nullable=True),
                    sa.Column('provider_code', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.Column('year', sa.INTEGER(), autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('id', name='weather_pkey')
                    )
示例#39
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'users', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=255), nullable=False),
        sa.Column('email', sa.String(length=255), nullable=False),
        sa.Column('secure_password', sa.String(length=255), nullable=False),
        sa.Column('bio', sa.String(length=255), nullable=True),
        sa.Column('profile_pic_path', sa.String(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'),
        sa.UniqueConstraint('username'))
    op.create_table('pitches', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('title', sa.String(length=255), nullable=False),
                    sa.Column('content', sa.String(), nullable=True),
                    sa.Column('category', sa.String(length=40), nullable=True),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('time', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('profile_photos',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('pic_path', sa.String(), nullable=True),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('comments', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('comment', sa.Text(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('pitch_id', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['pitch_id'],
                        ['pitches.id'],
                    ), sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('downvotes', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('pitch_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['pitch_id'],
                        ['pitches.id'],
                    ), sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('upvotes', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('pitch_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['pitch_id'],
                        ['pitches.id'],
                    ), sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('category',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('categoryname', sa.String(length=255), nullable=True),
    sa.Column('description', sa.Text(length=500), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_category_categoryname'), 'category', ['categoryname'], unique=True)
    op.create_table('customer',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('customername', sa.String(length=255), nullable=True),
    sa.Column('contactname', sa.String(length=255), nullable=True),
    sa.Column('address', sa.String(length=255), nullable=True),
    sa.Column('city', sa.String(length=255), nullable=True),
    sa.Column('postalcode', sa.String(length=255), nullable=True),
    sa.Column('country', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_customer_address'), 'customer', ['address'], unique=False)
    op.create_index(op.f('ix_customer_city'), 'customer', ['city'], unique=False)
    op.create_index(op.f('ix_customer_contactname'), 'customer', ['contactname'], unique=False)
    op.create_index(op.f('ix_customer_country'), 'customer', ['country'], unique=False)
    op.create_index(op.f('ix_customer_customername'), 'customer', ['customername'], unique=False)
    op.create_index(op.f('ix_customer_postalcode'), 'customer', ['postalcode'], unique=False)
    op.create_table('employee',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('lastname', sa.String(length=255), nullable=True),
    sa.Column('firstname', sa.String(length=255), nullable=True),
    sa.Column('birthdate', sa.Date(), nullable=True),
    sa.Column('notes', sa.Text(length=1000), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_employee_firstname'), 'employee', ['firstname'], unique=False)
    op.create_index(op.f('ix_employee_lastname'), 'employee', ['lastname'], unique=False)
    op.create_table('shipper',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('productname', sa.String(length=255), nullable=True),
    sa.Column('phone', sa.String(length=25), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_shipper_phone'), 'shipper', ['phone'], unique=False)
    op.create_index(op.f('ix_shipper_productname'), 'shipper', ['productname'], unique=False)
    op.create_table('supplier',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('suppliername', sa.String(length=255), nullable=True),
    sa.Column('contactname', sa.String(length=255), nullable=True),
    sa.Column('address', sa.String(length=255), nullable=True),
    sa.Column('city', sa.String(length=255), nullable=True),
    sa.Column('postalcode', sa.String(length=255), nullable=True),
    sa.Column('country', sa.String(length=255), nullable=True),
    sa.Column('phone', sa.String(length=25), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_supplier_address'), 'supplier', ['address'], unique=False)
    op.create_index(op.f('ix_supplier_city'), 'supplier', ['city'], unique=False)
    op.create_index(op.f('ix_supplier_contactname'), 'supplier', ['contactname'], unique=False)
    op.create_index(op.f('ix_supplier_country'), 'supplier', ['country'], unique=False)
    op.create_index(op.f('ix_supplier_phone'), 'supplier', ['phone'], unique=False)
    op.create_index(op.f('ix_supplier_postalcode'), 'supplier', ['postalcode'], unique=False)
    op.create_index(op.f('ix_supplier_suppliername'), 'supplier', ['suppliername'], unique=False)
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('about_me', sa.String(length=255), nullable=True),
    sa.Column('last_seen', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('followers',
    sa.Column('follower_id', sa.Integer(), nullable=True),
    sa.Column('followed_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['followed_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['follower_id'], ['user.id'], )
    )
    op.create_table('order',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('customer_id', sa.Integer(), nullable=True),
    sa.Column('employee_id', sa.Integer(), nullable=True),
    sa.Column('orderdate', sa.Date(), nullable=True),
    sa.Column('shipper_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['customer_id'], ['customer.id'], ),
    sa.ForeignKeyConstraint(['employee_id'], ['employee.id'], ),
    sa.ForeignKeyConstraint(['shipper_id'], ['shipper.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('post',
    sa.Column('body', sa.String(length=140), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_post_timestamp'), 'post', ['timestamp'], unique=False)
    op.create_table('product',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('productname', sa.String(length=255), nullable=True),
    sa.Column('supplier_id', sa.Integer(), nullable=True),
    sa.Column('category_id', sa.Integer(), nullable=True),
    sa.Column('unit', sa.Integer(), nullable=True),
    sa.Column('price', sa.Numeric(), nullable=True),
    sa.ForeignKeyConstraint(['category_id'], ['category.id'], ),
    sa.ForeignKeyConstraint(['supplier_id'], ['supplier.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_product_productname'), 'product', ['productname'], unique=False)
    op.create_table('order_detail',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('order_id', sa.Integer(), nullable=True),
    sa.Column('product_id', sa.Integer(), nullable=True),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['order_id'], ['order.id'], ),
    sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
示例#41
0
def downgrade():
    op.create_table(
        "manifest_uploads",
        sa.Column("_created",
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=True),
        sa.Column("_updated",
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=True),
        sa.Column("_etag",
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
        sa.Column("gcs_xlsx_uri",
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=False),
        sa.Column("uploader_email",
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=True),
        sa.Column("trial_id",
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=False),
        sa.Column("manifest_type",
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=False),
        sa.Column(
            "metadata_patch",
            postgresql.JSONB(astext_type=sa.Text()),
            autoincrement=False,
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["trial_id"],
            ["trial_metadata.trial_id"],
            name="manifest_uploads_trial_id_fkey",
        ),
        sa.ForeignKeyConstraint(
            ["uploader_email"],
            ["users.email"],
            name="manifest_uploads_uploader_email_fkey",
            onupdate="CASCADE",
        ),
        sa.PrimaryKeyConstraint("id", name="manifest_uploads_pkey"),
    )
    op.create_index("ix_manifest_uploads_trial_id",
                    "manifest_uploads", ["trial_id"],
                    unique=False)

    conn = op.get_bind()

    # Transfer data from upload_jobs to manifest_uploads
    conn.execute("""
        INSERT INTO manifest_uploads(_created, _updated, _etag, gcs_xlsx_uri, metadata_patch, manifest_type, uploader_email, trial_id)
        SELECT _created, _updated, _etag, gcs_xlsx_uri, metadata_patch, upload_type, uploader_email, trial_id from upload_jobs
        """)

    # Drop manifest records
    conn.execute("DELETE FROM upload_jobs WHERE multifile = true")
    conn.execute("ALTER TYPE upload_job_status RENAME TO assay_upload_status")
    conn.execute("ALTER TABLE upload_jobs RENAME TO assay_uploads")
    conn.execute(
        "ALTER TABLE assay_uploads RENAME COLUMN upload_type TO assay_type")
    conn.execute(
        "ALTER TABLE assay_uploads RENAME COLUMN metadata_patch TO assay_patch"
    )
    conn.execute(
        "ALTER TABLE assay_uploads ALTER COLUMN gcs_file_map SET NOT NULL")
    conn.execute("ALTER TABLE assay_uploads DROP COLUMN multifile")
    conn.execute(
        "ALTER TABLE assay_uploads DROP CONSTRAINT check_gcs_file_map")

    op.drop_index("ix_manifest_uploads_trial_id",
                  table_name="manifest_uploads")
    op.drop_table("manifest_uploads")

    conn.execute(
        "ALTER INDEX upload_jobs_gcs_gcs_file_map_idx RENAME TO assay_uploads_gcs_gcs_file_map_idx"
    )
    conn.execute(
        "ALTER INDEX ix_upload_jobs_trial_id RENAME TO ix_assay_uploads_trial_id"
    )
    conn.execute("ALTER TYPE upload_job_status RENAME TO assay_upload_status")
示例#42
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('corporation', sa.Column('id',
                                             sa.Integer(),
                                             nullable=False),
                    sa.Column('timestamp', sa.DateTime(), nullable=True),
                    sa.Column('creator_user_id', sa.Integer(), nullable=True),
                    sa.Column('slug', sa.String(length=128), nullable=True),
                    sa.Column('active', sa.Boolean(), nullable=True),
                    sa.Column('archived', sa.Boolean(), nullable=True),
                    sa.Column('name', sa.String(length=64), nullable=True),
                    sa.Column('about', sa.String(length=140), nullable=True),
                    sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('corporation', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_corporation_slug'), ['slug'],
                              unique=True)

    op.create_table('role', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('active', sa.Boolean(), nullable=True),
                    sa.Column('archived', sa.Boolean(), nullable=True),
                    sa.Column('code', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=120), nullable=False),
                    sa.Column('about', sa.String(length=120), nullable=True),
                    sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('role', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_role_about'), ['about'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_role_code'), ['code'],
                              unique=False)
        batch_op.create_index(batch_op.f('ix_role_name'), ['name'],
                              unique=True)

    op.create_table(
        'user', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('username', sa.String(length=64), nullable=True),
        sa.Column('password_hash', sa.String(length=128), nullable=True),
        sa.Column('email', sa.String(length=120), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('user', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_user_email'), ['email'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_user_slug'), ['slug'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_user_username'), ['username'],
                              unique=True)

    op.create_table(
        'admin', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.Column('email', sa.String(length=120), nullable=True),
        sa.Column('phone', sa.Integer(), nullable=True),
        sa.Column('first_role_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('corporation_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['corporation_id'],
            ['corporation.id'],
        ), sa.ForeignKeyConstraint(
            ['first_role_id'],
            ['role.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('admin', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_admin_email'), ['email'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_admin_phone'), ['phone'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_admin_slug'), ['slug'],
                              unique=True)

    op.create_table(
        'client', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('corporation_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['corporation_id'],
            ['corporation.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('client', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_client_slug'), ['slug'],
                              unique=True)

    op.create_table(
        'company', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.Column('corporation_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['corporation_id'],
            ['corporation.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('company', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_company_slug'), ['slug'],
                              unique=True)

    op.create_table(
        'employee', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('first_name', sa.String(length=64), nullable=True),
        sa.Column('last_name', sa.String(length=64), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.Column('email', sa.String(length=120), nullable=True),
        sa.Column('phone', sa.Integer(), nullable=True),
        sa.Column('first_role_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('corporation_id', sa.Integer(), nullable=True),
        sa.Column('company_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['company_id'],
            ['company.id'],
        ), sa.ForeignKeyConstraint(
            ['corporation_id'],
            ['corporation.id'],
        ), sa.ForeignKeyConstraint(
            ['first_role_id'],
            ['role.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('employee', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_employee_email'), ['email'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_employee_phone'), ['phone'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_employee_slug'), ['slug'],
                              unique=True)

    op.create_table(
        'group_client_places', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('slug_link', sa.String(length=128), nullable=True),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('about', sa.String(length=140), nullable=True),
        sa.Column('company_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['company_id'],
            ['company.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('group_client_places', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_group_client_places_slug'),
                              ['slug'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_group_client_places_slug_link'),
                              ['slug_link'],
                              unique=True)

    op.create_table(
        'client_place', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('timestamp', sa.DateTime(), nullable=True),
        sa.Column('creator_user_id', sa.Integer(), nullable=True),
        sa.Column('slug', sa.String(length=128), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=True),
        sa.Column('archived', sa.Boolean(), nullable=True),
        sa.Column('slug_link', sa.String(length=128), nullable=True),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('company_id', sa.Integer(), nullable=True),
        sa.Column('group_client_places_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['company_id'],
            ['company.id'],
        ),
        sa.ForeignKeyConstraint(
            ['group_client_places_id'],
            ['group_client_places.id'],
        ), sa.PrimaryKeyConstraint('id'))
    with op.batch_alter_table('client_place', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_client_place_slug'), ['slug'],
                              unique=True)
        batch_op.create_index(batch_op.f('ix_client_place_slug_link'),
                              ['slug_link'],
                              unique=True)

    op.create_table(
        'employees_to_groups_client_places',
        sa.Column('employee_id', sa.Integer(), nullable=True),
        sa.Column('group_client_places_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['employee_id'],
            ['employee.id'],
        ),
        sa.ForeignKeyConstraint(
            ['group_client_places_id'],
            ['group_client_places.id'],
        ))
    op.create_table(
        'employees_to_client_places',
        sa.Column('employee_id', sa.Integer(), nullable=True),
        sa.Column('client_place_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['client_place_id'],
            ['client_place.id'],
        ), sa.ForeignKeyConstraint(
            ['employee_id'],
            ['employee.id'],
        ))
示例#43
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('service',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('logo_url', sa.String(length=128), nullable=True),
    sa.Column('website_url', sa.String(length=128), nullable=True),
    sa.Column('main_contact_name', sa.String(length=64), nullable=True),
    sa.Column('main_contact_phone', sa.String(length=32), nullable=True),
    sa.Column('has_screening_yn', sa.String(length=1), nullable=True),
    sa.Column('fpl_cutoff', sa.Integer(), nullable=True),
    sa.Column('uninsured_only_yn', sa.String(length=1), nullable=True),
    sa.Column('medicaid_ineligible_only_yn', sa.String(length=1), nullable=True),
    sa.Column('residence_requirement_yn', sa.String(length=1), nullable=True),
    sa.Column('time_in_area_requirement_yn', sa.String(length=1), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('role',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.Column('default', sa.Boolean(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_role_default'), 'role', ['default'], unique=False)
    op.create_table('patient',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('full_name', sa.String(length=128), nullable=True),
    sa.Column('first_name', sa.String(length=64), nullable=True),
    sa.Column('middle_name', sa.String(length=64), nullable=True),
    sa.Column('last_name', sa.String(length=64), nullable=True),
    sa.Column('dob', sa.Date(), nullable=True),
    sa.Column('ssn', sa.String(length=11), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('gender', sa.String(length=2), nullable=True),
    sa.Column('transgender', sa.String(length=3), nullable=True),
    sa.Column('race', sa.String(length=16), nullable=True),
    sa.Column('race_other', sa.String(length=32), nullable=True),
    sa.Column('ethnicity', sa.String(length=32), nullable=True),
    sa.Column('languages', sa.String(length=64), nullable=True),
    sa.Column('languages_other', sa.String(length=64), nullable=True),
    sa.Column('has_interpreter_yn', sa.String(length=1), nullable=True),
    sa.Column('education_level', sa.String(length=16), nullable=True),
    sa.Column('marital_status', sa.String(length=16), nullable=True),
    sa.Column('veteran_yn', sa.String(length=1), nullable=True),
    sa.Column('housing_status', sa.String(length=16), nullable=True),
    sa.Column('housing_status_other', sa.String(length=32), nullable=True),
    sa.Column('time_in_area', sa.String(length=16), nullable=True),
    sa.Column('city_or_county_of_residence', sa.String(length=64), nullable=True),
    sa.Column('temp_visa_yn', sa.String(length=1), nullable=True),
    sa.Column('has_transport_yn', sa.String(length=1), nullable=True),
    sa.Column('student_status', sa.String(length=16), nullable=True),
    sa.Column('employment_status', sa.String(length=16), nullable=True),
    sa.Column('years_unemployed', sa.Integer(), nullable=True),
    sa.Column('months_unemployed', sa.Integer(), nullable=True),
    sa.Column('employment_changes', sa.String(length=32), nullable=True),
    sa.Column('spouse_employment_status', sa.String(length=16), nullable=True),
    sa.Column('spouse_years_unemployed', sa.Integer(), nullable=True),
    sa.Column('spouse_months_unemployed', sa.Integer(), nullable=True),
    sa.Column('spouse_employment_changes', sa.String(length=16), nullable=True),
    sa.Column('years_at_current_employer', sa.String(length=32), nullable=True),
    sa.Column('spouse_years_at_current_employer', sa.String(length=32), nullable=True),
    sa.Column('last_healthcare', sa.String(length=128), nullable=True),
    sa.Column('insurance_status', sa.String(length=32), nullable=True),
    sa.Column('coverage_type', sa.String(length=32), nullable=True),
    sa.Column('coverage_type_other', sa.String(length=32), nullable=True),
    sa.Column('has_prescription_coverage_yn', sa.String(length=1), nullable=True),
    sa.Column('has_vcc', sa.String(length=1), nullable=True),
    sa.Column('has_pcp_yn', sa.String(length=1), nullable=True),
    sa.Column('has_psychiatrist_yn', sa.String(length=1), nullable=True),
    sa.Column('wants_psychiatrist_yn', sa.String(length=1), nullable=True),
    sa.Column('eligible_insurance_types', sa.String(length=64), nullable=True),
    sa.Column('applied_for_vets_benefits_yn', sa.String(length=1), nullable=True),
    sa.Column('eligible_for_vets_benefits_yn', sa.String(length=1), nullable=True),
    sa.Column('applied_for_medicaid_yn', sa.String(length=1), nullable=True),
    sa.Column('denied_medicaid_yn', sa.String(length=1), nullable=True),
    sa.Column('medicaid_date_effective', sa.Date(), nullable=True),
    sa.Column('applied_for_ssd_yn', sa.String(length=1), nullable=True),
    sa.Column('ssd_date_effective', sa.Date(), nullable=True),
    sa.Column('care_due_to_accident_yn', sa.String(length=1), nullable=True),
    sa.Column('accident_work_related_yn', sa.String(length=1), nullable=True),
    sa.Column('recently_lost_insurance_yn', sa.String(length=1), nullable=True),
    sa.Column('head_of_household_yn', sa.String(length=1), nullable=True),
    sa.Column('filed_taxes_yn', sa.String(length=1), nullable=True),
    sa.Column('claimed_as_dependent_yn', sa.String(length=1), nullable=True),
    sa.Column('how_food_and_shelter', sa.String(length=128), nullable=True),
    sa.Column('how_other_expenses', sa.String(length=128), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('document_image',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('file_name', sa.String(length=64), nullable=True),
    sa.Column('file_description', sa.String(length=64), nullable=True),
    sa.Column('data_full', sa.LargeBinary(), nullable=True),
    sa.Column('data_large', sa.LargeBinary(), nullable=True),
    sa.Column('data_small', sa.LargeBinary(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('employer',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('employer_name', sa.String(length=64), nullable=True),
    sa.Column('phone_number', sa.String(length=32), nullable=True),
    sa.Column('employee', sa.String(length=16), nullable=True),
    sa.Column('start_date', sa.Date(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('emergency_contact',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('full_name', sa.String(length=64), nullable=True),
    sa.Column('relationship', sa.String(length=64), nullable=True),
    sa.Column('phone_number', sa.String(length=32), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('referral_permission',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('from_service_id', sa.Integer(), nullable=True),
    sa.Column('to_service_id', sa.Integer(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['from_service_id'], ['service.id'], ),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['to_service_id'], ['service.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('address',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('address1', sa.String(length=64), nullable=True),
    sa.Column('address2', sa.String(length=64), nullable=True),
    sa.Column('city', sa.String(length=64), nullable=True),
    sa.Column('state', sa.String(length=2), nullable=True),
    sa.Column('zip_code', sa.String(length=10), nullable=True),
    sa.Column('address_description', sa.String(length=64), nullable=True),
    sa.Column('address_description_other', sa.String(length=64), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('service_referral_email',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('service_location',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('contact_name', sa.String(length=64), nullable=True),
    sa.Column('phone_number', sa.String(length=32), nullable=True),
    sa.Column('address', sa.String(length=64), nullable=True),
    sa.Column('latitude', sa.Float(), nullable=True),
    sa.Column('longitude', sa.Float(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('sliding_scale',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('scale_name', sa.String(length=64), nullable=True),
    sa.Column('fpl_low', sa.Float(), nullable=True),
    sa.Column('fpl_high', sa.Float(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('household_member',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('full_name', sa.String(length=64), nullable=True),
    sa.Column('dob', sa.Date(), nullable=True),
    sa.Column('ssn', sa.String(length=11), nullable=True),
    sa.Column('relationship', sa.String(length=32), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('phone_number',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('phone_number', sa.String(length=32), nullable=True),
    sa.Column('number_description', sa.String(length=64), nullable=True),
    sa.Column('number_description_other', sa.String(length=64), nullable=True),
    sa.Column('primary_yn', sa.String(length=1), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('app_user',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('password', sa.String(length=128), nullable=True),
    sa.Column('authenticated', sa.Boolean(), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.Column('last_login_at', sa.DateTime(), nullable=True),
    sa.Column('current_login_at', sa.DateTime(), nullable=True),
    sa.Column('last_login_ip', sa.String(length=16), nullable=True),
    sa.Column('current_login_ip', sa.String(length=16), nullable=True),
    sa.Column('login_count', sa.Integer(), nullable=True),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('full_name', sa.String(length=64), nullable=True),
    sa.Column('phone_number', sa.String(length=32), nullable=True),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('income_source',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('source', sa.String(length=64), nullable=True),
    sa.Column('monthly_amount', sa.Integer(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('service_translation',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('language_code', sa.String(length=16), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('patient_screening_result',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('service_id', sa.Integer(), nullable=True),
    sa.Column('eligible_yn', sa.String(length=1), nullable=True),
    sa.Column('sliding_scale_id', sa.Integer(), nullable=True),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.ForeignKeyConstraint(['service_id'], ['service.id'], ),
    sa.ForeignKeyConstraint(['sliding_scale_id'], ['sliding_scale.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('roles_users',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('app_user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['app_user_id'], ['app_user.id'], ),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('sliding_scale_fee',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sliding_scale_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=128), nullable=True),
    sa.Column('price_absolute', sa.Integer(), nullable=True),
    sa.Column('price_percentage', sa.Integer(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['sliding_scale_id'], ['sliding_scale.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('patient_referral',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('from_app_user_id', sa.Integer(), nullable=True),
    sa.Column('to_service_id', sa.Integer(), nullable=True),
    sa.Column('status', sa.String(length=9), nullable=True),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['from_app_user_id'], ['app_user.id'], ),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.ForeignKeyConstraint(['to_service_id'], ['service.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('action_log',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('transaction_id', sa.Integer(), nullable=True),
    sa.Column('action_timestamp', sa.DateTime(), nullable=True),
    sa.Column('table_name', sa.String(length=64), nullable=True),
    sa.Column('row_id', sa.Integer(), nullable=True),
    sa.Column('app_user_id', sa.Integer(), nullable=True),
    sa.Column('action', sa.String(length=1), nullable=True),
    sa.Column('row_data', postgresql.HSTORE(), nullable=True),
    sa.Column('changed_fields', postgresql.HSTORE(), nullable=True),
    sa.ForeignKeyConstraint(['app_user_id'], ['app_user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('unsaved_form',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('app_user_id', sa.Integer(), nullable=True),
    sa.Column('patient_id', sa.Integer(), nullable=True),
    sa.Column('page_name', sa.String(length=128), nullable=True),
    sa.Column('form_json', postgresql.JSON(), nullable=True),
    sa.Column('last_modified_by_id', sa.Integer(), nullable=True),
    sa.Column('created_by_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['app_user_id'], ['app_user.id'], ),
    sa.ForeignKeyConstraint(['created_by_id'], ['app_user.id'], name='fk_created_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['last_modified_by_id'], ['app_user.id'], name='fk_last_modified_by_id', use_alter=True),
    sa.ForeignKeyConstraint(['patient_id'], ['patient.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
示例#44
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tb_free_category',
                    sa.Column('creat_time', sa.DateTime(), nullable=True),
                    sa.Column('update_time', sa.DateTime(), nullable=True),
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=64), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    op.create_table('tb_thinking_category',
                    sa.Column('creat_time', sa.DateTime(), nullable=True),
                    sa.Column('update_time', sa.DateTime(), nullable=True),
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=64), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_user', sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_name', sa.String(length=32), nullable=False),
        sa.Column('password_hash', sa.String(length=128), nullable=True),
        sa.Column('signature', sa.String(length=512), nullable=True),
        sa.Column('avatar_url', sa.String(length=256), nullable=True),
        sa.Column('gender', sa.Enum('MAN', 'WOMAN'), nullable=True),
        sa.Column('last_login', sa.DateTime(), nullable=True),
        sa.Column('is_admin', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_name'))
    op.create_table('tb_work_category',
                    sa.Column('creat_time', sa.DateTime(), nullable=True),
                    sa.Column('update_time', sa.DateTime(), nullable=True),
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=64), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_free_article', sa.Column('creat_time',
                                     sa.DateTime(),
                                     nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=256), nullable=False),
        sa.Column('source', sa.String(length=64), nullable=True),
        sa.Column('digest', sa.String(length=512), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('clicks', sa.Integer(), nullable=True),
        sa.Column('image_url', sa.String(length=256), nullable=True),
        sa.Column('status', sa.Integer(), nullable=True),
        sa.Column('reason', sa.String(length=256), nullable=True),
        sa.Column('free_category_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['free_category_id'],
            ['tb_free_category.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_thinking_article',
        sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=256), nullable=False),
        sa.Column('source', sa.String(length=64), nullable=True),
        sa.Column('digest', sa.String(length=512), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('clicks', sa.Integer(), nullable=True),
        sa.Column('image_url', sa.String(length=256), nullable=True),
        sa.Column('status', sa.Integer(), nullable=True),
        sa.Column('reason', sa.String(length=256), nullable=True),
        sa.Column('thinking_category_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['thinking_category_id'],
            ['tb_thinking_category.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_work_article', sa.Column('creat_time',
                                     sa.DateTime(),
                                     nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=256), nullable=False),
        sa.Column('source', sa.String(length=64), nullable=True),
        sa.Column('digest', sa.String(length=512), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('clicks', sa.Integer(), nullable=True),
        sa.Column('image_url', sa.String(length=256), nullable=True),
        sa.Column('status', sa.Integer(), nullable=True),
        sa.Column('reason', sa.String(length=256), nullable=True),
        sa.Column('work_category_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ),
        sa.ForeignKeyConstraint(
            ['work_category_id'],
            ['tb_work_category.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_free_comment', sa.Column('creat_time',
                                     sa.DateTime(),
                                     nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('like_count', sa.Integer(), nullable=True),
        sa.Column('free_article_id', sa.Integer(), nullable=False),
        sa.Column('free_parent_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['free_article_id'],
            ['tb_free_article.id'],
        ), sa.ForeignKeyConstraint(
            ['free_parent_id'],
            ['tb_free_comment.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_thinking_comment',
        sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('like_count', sa.Integer(), nullable=True),
        sa.Column('thinking_article_id', sa.Integer(), nullable=False),
        sa.Column('thinking_parent_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['thinking_article_id'],
            ['tb_thinking_article.id'],
        ),
        sa.ForeignKeyConstraint(
            ['thinking_parent_id'],
            ['tb_thinking_comment.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_user_collection', sa.Column('user_id',
                                        sa.Integer(),
                                        nullable=False),
        sa.Column('free_article_id', sa.Integer(), nullable=False),
        sa.Column('work_article_id', sa.Integer(), nullable=False),
        sa.Column('thinking_article_id', sa.Integer(), nullable=False),
        sa.Column('create_time', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(
            ['free_article_id'],
            ['tb_free_article.id'],
        ),
        sa.ForeignKeyConstraint(
            ['thinking_article_id'],
            ['tb_thinking_article.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ),
        sa.ForeignKeyConstraint(
            ['work_article_id'],
            ['tb_work_article.id'],
        ),
        sa.PrimaryKeyConstraint('user_id', 'free_article_id',
                                'work_article_id', 'thinking_article_id'))
    op.create_table(
        'tb_work_comment', sa.Column('creat_time',
                                     sa.DateTime(),
                                     nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('content', sa.Text(), nullable=False),
        sa.Column('like_count', sa.Integer(), nullable=True),
        sa.Column('work_article_id', sa.Integer(), nullable=False),
        sa.Column('work_parent_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ),
        sa.ForeignKeyConstraint(
            ['work_article_id'],
            ['tb_work_article.id'],
        ), sa.ForeignKeyConstraint(
            ['work_parent_id'],
            ['tb_work_comment.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'tb_free_comment_like',
        sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('free_comment_id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['free_comment_id'],
            ['tb_free_comment.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('free_comment_id', 'user_id'))
    op.create_table(
        'thinking__comment_like',
        sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('thinking_comment_id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['thinking_comment_id'],
            ['tb_thinking_comment.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ), sa.PrimaryKeyConstraint('thinking_comment_id', 'user_id'))
    op.create_table(
        'work__comment_like',
        sa.Column('creat_time', sa.DateTime(), nullable=True),
        sa.Column('update_time', sa.DateTime(), nullable=True),
        sa.Column('work_comment_id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['tb_user.id'],
        ),
        sa.ForeignKeyConstraint(
            ['work_comment_id'],
            ['tb_work_comment.id'],
        ), sa.PrimaryKeyConstraint('work_comment_id', 'user_id'))
示例#45
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'modifiers', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('mod', sa.Integer(), nullable=False),
        sa.Column('type', sa.String(length=50), nullable=True),
        sa.Column('is_slot_activated', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'users', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=50), nullable=False),
        sa.Column('email', sa.String(length=250), nullable=False),
        sa.Column('hashword', sa.String(length=250), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'),
        sa.UniqueConstraint('username'))
    op.create_table(
        'assets', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('category', sa.String(length=50), nullable=True),
        sa.Column('title', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(), nullable=False),
        sa.Column('color', sa.String(length=50), nullable=True),
        sa.Column('icon', sa.String(length=50), nullable=True),
        sa.Column('image', sa.String(length=250), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('value', sa.Integer(), nullable=True),
        sa.Column('max', sa.Integer(), nullable=True),
        sa.Column('is_allowed_multiple', sa.Boolean(), nullable=False),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table('chronicles', sa.Column('id', sa.Integer(),
                                            nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('title', sa.String(length=50), nullable=False),
                    sa.Column('description', sa.String(), nullable=False),
                    sa.Column('color', sa.String(length=50), nullable=True),
                    sa.Column('icon', sa.String(length=50), nullable=True),
                    sa.Column('image', sa.String(length=250), nullable=True),
                    sa.Column('created_at', sa.DateTime(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'entities', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('type', sa.String(length=50), nullable=False),
        sa.Column('category', sa.String(length=50), nullable=True),
        sa.Column('title', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(), nullable=False),
        sa.Column('color', sa.String(length=50), nullable=True),
        sa.Column('icon', sa.String(length=50), nullable=True),
        sa.Column('image', sa.String(length=250), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('location_id', sa.Integer(), nullable=True),
        sa.Column('generated_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['location_id'],
            ['entities.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table('meters', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('category', sa.String(length=50), nullable=True),
                    sa.Column('title', sa.String(length=50), nullable=False),
                    sa.Column('description', sa.String(), nullable=False),
                    sa.Column('color', sa.String(length=50), nullable=True),
                    sa.Column('icon', sa.String(length=50), nullable=True),
                    sa.Column('image', sa.String(length=250), nullable=True),
                    sa.Column('created_at', sa.DateTime(), nullable=False),
                    sa.Column('min', sa.Integer(), nullable=False),
                    sa.Column('max', sa.Integer(), nullable=False),
                    sa.Column('algorithm', sa.String(), nullable=False),
                    sa.Column('base', sa.Integer(), nullable=False),
                    sa.Column('mod', sa.String(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('statuses', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('category', sa.String(length=50), nullable=True),
                    sa.Column('title', sa.String(length=50), nullable=False),
                    sa.Column('description', sa.String(), nullable=False),
                    sa.Column('color', sa.String(length=50), nullable=True),
                    sa.Column('icon', sa.String(length=50), nullable=True),
                    sa.Column('image', sa.String(length=250), nullable=True),
                    sa.Column('created_at', sa.DateTime(), nullable=False),
                    sa.Column('duration', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'asset_modifiers', sa.Column('asset_id', sa.Integer(), nullable=False),
        sa.Column('modifier_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['asset_id'],
            ['assets.id'],
        ), sa.ForeignKeyConstraint(
            ['modifier_id'],
            ['modifiers.id'],
        ), sa.PrimaryKeyConstraint('asset_id', 'modifier_id'))
    op.create_table('entity_assets',
                    sa.Column('entity_id', sa.Integer(), nullable=False),
                    sa.Column('asset_id', sa.Integer(), nullable=False),
                    sa.Column('quantity', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['asset_id'],
                        ['assets.id'],
                    ), sa.ForeignKeyConstraint(
                        ['entity_id'],
                        ['entities.id'],
                    ), sa.PrimaryKeyConstraint('entity_id', 'asset_id'))
    op.create_table('entity_meters',
                    sa.Column('entity_id', sa.Integer(), nullable=False),
                    sa.Column('meter_id', sa.Integer(), nullable=False),
                    sa.Column('points', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['entity_id'],
                        ['entities.id'],
                    ), sa.ForeignKeyConstraint(
                        ['meter_id'],
                        ['meters.id'],
                    ), sa.PrimaryKeyConstraint('entity_id', 'meter_id'))
    op.create_table('entity_statuses',
                    sa.Column('entity_id', sa.Integer(), nullable=False),
                    sa.Column('status_id', sa.Integer(), nullable=False),
                    sa.Column('expiry', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['entity_id'],
                        ['entities.id'],
                    ), sa.ForeignKeyConstraint(
                        ['status_id'],
                        ['statuses.id'],
                    ), sa.PrimaryKeyConstraint('entity_id', 'status_id'))
    op.create_table(
        'player_characters',
        sa.Column('player_id', sa.Integer(), nullable=False),
        sa.Column('character_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['character_id'],
            ['entities.id'],
        ), sa.ForeignKeyConstraint(
            ['player_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('player_id', 'character_id'))
    op.create_table(
        'slots', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('chronicle_id', sa.Integer(), nullable=False),
        sa.Column('category', sa.String(length=50), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ['chronicle_id'],
            ['chronicles.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'status_modifiers', sa.Column('status_id',
                                      sa.Integer(),
                                      nullable=False),
        sa.Column('modifier_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(
            ['modifier_id'],
            ['modifiers.id'],
        ), sa.ForeignKeyConstraint(
            ['status_id'],
            ['statuses.id'],
        ), sa.PrimaryKeyConstraint('status_id', 'modifier_id'))
    op.create_table(
        'tales', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(), nullable=False),
        sa.Column('color', sa.String(length=50), nullable=True),
        sa.Column('icon', sa.String(length=50), nullable=True),
        sa.Column('image', sa.String(length=250), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('chronicle_id', sa.Integer(), nullable=False),
        sa.Column('first_thread_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['chronicle_id'],
            ['chronicles.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table('entity_slots',
                    sa.Column('entity_id', sa.Integer(), nullable=False),
                    sa.Column('slot_id', sa.Integer(), nullable=False),
                    sa.Column('filler_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['entity_id'],
                        ['entities.id'],
                    ), sa.ForeignKeyConstraint(
                        ['filler_id'],
                        ['entities.id'],
                    ), sa.ForeignKeyConstraint(
                        ['slot_id'],
                        ['slots.id'],
                    ), sa.PrimaryKeyConstraint('entity_id', 'slot_id'))
    op.create_table(
        'threads', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(), nullable=False),
        sa.Column('color', sa.String(length=50), nullable=True),
        sa.Column('icon', sa.String(length=50), nullable=True),
        sa.Column('image', sa.String(length=250), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('tale_id', sa.Integer(), nullable=False),
        sa.Column('is_sequitur', sa.Boolean(), nullable=False),
        sa.Column('is_returnable', sa.Boolean(), nullable=False),
        sa.Column('x', sa.Integer(), nullable=False),
        sa.Column('y', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['tale_id'], ['tales.id'], ondelete='cascade'),
        sa.PrimaryKeyConstraint('id'))
    op.create_table('asset_effects',
                    sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('type', sa.String(length=50), nullable=True),
                    sa.Column('category', sa.String(length=50), nullable=True),
                    sa.Column('thread_id', sa.Integer(), nullable=False),
                    sa.Column('created_at', sa.DateTime(), nullable=False),
                    sa.Column('asset_id', sa.Integer(), nullable=False),
                    sa.Column('quantity', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['asset_id'],
                        ['assets.id'],
                    ), sa.ForeignKeyConstraint(
                        ['thread_id'],
                        ['threads.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'choices', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('title', sa.String(length=50), nullable=False),
        sa.Column('description', sa.String(), nullable=False),
        sa.Column('color', sa.String(length=50), nullable=True),
        sa.Column('icon', sa.String(length=50), nullable=True),
        sa.Column('image', sa.String(length=250), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('prev_thread_id', sa.Integer(), nullable=False),
        sa.Column('next_thread_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['next_thread_id'], ['threads.id'],
                                ondelete='cascade'),
        sa.ForeignKeyConstraint(['prev_thread_id'], ['threads.id'],
                                ondelete='cascade'),
        sa.PrimaryKeyConstraint('id'))
    op.create_table('asset_locks', sa.Column('id',
                                             sa.Integer(),
                                             nullable=False),
                    sa.Column('type', sa.String(length=50), nullable=True),
                    sa.Column('category', sa.String(length=50), nullable=True),
                    sa.Column('choice_id', sa.Integer(), nullable=False),
                    sa.Column('created_at', sa.DateTime(), nullable=False),
                    sa.Column('asset_id', sa.Integer(), nullable=False),
                    sa.Column('quantity', sa.Integer(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['asset_id'],
                        ['assets.id'],
                    ), sa.ForeignKeyConstraint(
                        ['choice_id'],
                        ['choices.id'],
                    ), sa.PrimaryKeyConstraint('id'))
示例#46
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ih_area_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_facility_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_user_profile',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=32), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('mobile', sa.String(length=11), nullable=False),
    sa.Column('real_name', sa.String(length=32), nullable=True),
    sa.Column('id_card', sa.String(length=20), nullable=True),
    sa.Column('avatar_url', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('mobile'),
    sa.UniqueConstraint('name')
    )
    op.create_table('ih_house_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('area_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=64), nullable=False),
    sa.Column('price', sa.Integer(), nullable=True),
    sa.Column('address', sa.String(length=512), nullable=True),
    sa.Column('room_count', sa.Integer(), nullable=True),
    sa.Column('acreage', sa.Integer(), nullable=True),
    sa.Column('unit', sa.String(length=32), nullable=True),
    sa.Column('capacity', sa.Integer(), nullable=True),
    sa.Column('beds', sa.String(length=64), nullable=True),
    sa.Column('deposit', sa.Integer(), nullable=True),
    sa.Column('min_days', sa.Integer(), nullable=True),
    sa.Column('max_days', sa.Integer(), nullable=True),
    sa.Column('order_count', sa.Integer(), nullable=True),
    sa.Column('index_image_url', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['area_id'], ['ih_area_info.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['ih_user_profile.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_house_facility',
    sa.Column('house_id', sa.Integer(), nullable=False),
    sa.Column('facility_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['facility_id'], ['ih_facility_info.id'], ),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.PrimaryKeyConstraint('house_id', 'facility_id')
    )
    op.create_table('ih_house_image',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('house_id', sa.Integer(), nullable=False),
    sa.Column('url', sa.String(length=256), nullable=False),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('ih_order_info',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('house_id', sa.Integer(), nullable=False),
    sa.Column('begin_date', sa.DateTime(), nullable=False),
    sa.Column('end_date', sa.DateTime(), nullable=False),
    sa.Column('days', sa.Integer(), nullable=False),
    sa.Column('house_price', sa.Integer(), nullable=False),
    sa.Column('amount', sa.Integer(), nullable=False),
    sa.Column('status', sa.Enum('WAIT_ACCEPT', 'WAIT_PAYMENT', 'PAID', 'WAIT_COMMENT', 'COMPLETE', 'CANCELED', 'REJECTED'), nullable=True),
    sa.Column('comment', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['house_id'], ['ih_house_info.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['ih_user_profile.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ih_order_info_status'), 'ih_order_info', ['status'], unique=False)
示例#47
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('goals',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('goal_slug', sa.String(), nullable=True),
    sa.Column('goal_text', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('goal_slug'),
    sa.UniqueConstraint('goal_text')
    )
    op.create_table('other',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('data_reference_type', sa.String(), nullable=True),
    sa.Column('data_key', sa.String(), nullable=True),
    sa.Column('data_value', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('students',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('phone', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('phone')
    )
    op.create_table('teachers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('about', sa.Text(), nullable=True),
    sa.Column('rating', sa.Float(), nullable=True),
    sa.Column('picture', sa.String(), nullable=True),
    sa.Column('price', sa.Float(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('requests',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('student_id', sa.Integer(), nullable=True),
    sa.Column('goal', sa.String(), nullable=True),
    sa.Column('have_time', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['student_id'], ['students.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('teacher_goals',
    sa.Column('teacher_id', sa.Integer(), nullable=True),
    sa.Column('goal_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ),
    sa.ForeignKeyConstraint(['teacher_id'], ['teachers.id'], )
    )
    op.create_table('timetables',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('teacher_id', sa.Integer(), nullable=True),
    sa.Column('weekday', sa.String(), nullable=True),
    sa.Column('time', sa.Time(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['teacher_id'], ['teachers.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('bookings',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('student_id', sa.Integer(), nullable=True),
    sa.Column('teacher_id', sa.Integer(), nullable=True),
    sa.Column('timetable_id', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['student_id'], ['students.id'], ),
    sa.ForeignKeyConstraint(['teacher_id'], ['teachers.id'], ),
    sa.ForeignKeyConstraint(['timetable_id'], ['timetables.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "set",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("bonuses", sa.PickleType(), nullable=True),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "user",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("username", sa.String(), nullable=False),
        sa.Column("email", sa.String(), nullable=False),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "custom_set",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("name", sa.String(), nullable=True),
        sa.Column("description", sa.String(), nullable=True),
        sa.Column("owner_id", postgresql.UUID(), nullable=True),
        sa.Column("creation_date", sa.DateTime(), nullable=True),
        sa.Column("level", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["owner_id"], ["user.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "custom_set_exos",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("stat", sa.String(), nullable=True),
        sa.Column("value", sa.Integer(), nullable=True),
        sa.Column("custom_set_id", postgresql.UUID(), nullable=True),
        sa.ForeignKeyConstraint(["custom_set_id"], ["custom_set.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "custom_set_stats",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("scrolledVitality", sa.Integer(), nullable=True),
        sa.Column("scrolledWisdom", sa.Integer(), nullable=True),
        sa.Column("scrolledStrength", sa.Integer(), nullable=True),
        sa.Column("scrolledIntelligence", sa.Integer(), nullable=True),
        sa.Column("scrolledChance", sa.Integer(), nullable=True),
        sa.Column("scrolledAgility", sa.Integer(), nullable=True),
        sa.Column("baseVitality", sa.Integer(), nullable=True),
        sa.Column("baseWisdom", sa.Integer(), nullable=True),
        sa.Column("baseStrength", sa.Integer(), nullable=True),
        sa.Column("baseIntelligence", sa.Integer(), nullable=True),
        sa.Column("baseChance", sa.Integer(), nullable=True),
        sa.Column("baseAgility", sa.Integer(), nullable=True),
        sa.Column("custom_set_id", postgresql.UUID(), nullable=True),
        sa.ForeignKeyConstraint(["custom_set_id"], ["custom_set.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "item",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("itemType", sa.String(), nullable=False),
        sa.Column("set_id", postgresql.UUID(), nullable=True),
        sa.Column("level", sa.Integer(), nullable=False),
        sa.Column("imageUrl", sa.String(), nullable=True),
        sa.Column("custom_set_id", postgresql.UUID(), nullable=True),
        sa.ForeignKeyConstraint(["custom_set_id"], ["custom_set.uuid"],),
        sa.ForeignKeyConstraint(["set_id"], ["set.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "item_conditions",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("item_id", postgresql.UUID(), nullable=True),
        sa.Column("stat_type", sa.String(), nullable=True),
        sa.Column("conditionType", sa.String(), nullable=True),
        sa.Column("limit", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["item_id"], ["item.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
    op.create_table(
        "item_stats",
        sa.Column(
            "uuid",
            postgresql.UUID(as_uuid=True),
            server_default=sa.text("uuid_generate_v4()"),
            nullable=False,
        ),
        sa.Column("item_id", postgresql.UUID(), nullable=True),
        sa.Column("stat", sa.String(), nullable=True),
        sa.Column("minValue", sa.Integer(), nullable=True),
        sa.Column("maxValue", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["item_id"], ["item.uuid"],),
        sa.PrimaryKeyConstraint("uuid"),
    )
示例#49
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'feedback', sa.Column('feedback_id', sa.Integer(), nullable=False),
        sa.Column('user_ID', sa.String(length=80), nullable=True),
        sa.Column('prediction', sa.Integer(), nullable=True),
        sa.Column('rating',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True),
        sa.Column('feedback',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True), sa.PrimaryKeyConstraint('feedback_id'))
    op.create_table(
        'prediction', sa.Column('prediction_id', sa.Integer(), nullable=False),
        sa.Column('analysis_model_name', sa.String(length=40), nullable=True),
        sa.Column('score', sa.Float(), nullable=True),
        sa.Column('model_id', sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint('prediction_id'))
    op.create_table(
        'prepared_data',
        sa.Column('prepared_id', sa.String(length=80), nullable=False),
        sa.Column('project_ID', sa.Integer(), nullable=True),
        sa.Column('preprared_data',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True),
        sa.Column('sample_ID', sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint('prepared_id'))
    op.create_table(
        'project', sa.Column('project_id',
                             sa.String(length=80),
                             nullable=False),
        sa.Column('raw_data_id', sa.Integer(), nullable=True),
        sa.Column('algo', sa.String(length=40), nullable=True),
        sa.Column('user_id', sa.String(length=80), nullable=True),
        sa.PrimaryKeyConstraint('project_id'))
    op.create_table(
        'raw_data', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.String(length=80), nullable=True),
        sa.Column('raw_data_set',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'reviwer', sa.Column('project_id',
                             sa.String(length=80),
                             nullable=False),
        sa.PrimaryKeyConstraint('project_id'))
    op.create_table(
        'sample_data', sa.Column('sample_ID', sa.Integer(), nullable=False),
        sa.Column('sample_Data',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True),
        sa.Column('trained_model', postgresql.BYTEA(), nullable=True),
        sa.PrimaryKeyConstraint('sample_ID'))
    op.create_table(
        'trained_model_result',
        sa.Column('model_id', sa.Integer(), nullable=False),
        sa.Column('model', postgresql.BYTEA(), nullable=True),
        sa.Column('project_id', sa.Integer(), nullable=True),
        sa.Column('parameter',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True), sa.PrimaryKeyConstraint('model_id'))
    op.create_table(
        'user', sa.Column('user_id', sa.String(length=80), nullable=False),
        sa.Column('prediction',
                  postgresql.JSON(astext_type=sa.Text()),
                  nullable=True),
        sa.Column('project_id', sa.String(length=80), nullable=True),
        sa.PrimaryKeyConstraint('user_id'))
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('category',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('category', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=255), nullable=True),
    sa.Column('bio', sa.String(), nullable=True),
    sa.Column('email', sa.String(), nullable=True),
    sa.Column('profile_pic', sa.String(), nullable=True),
    sa.Column('pass_secure', sa.String(length=200), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('posts',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=True),
    sa.Column('blog', sa.Text(), nullable=True),
    sa.Column('time', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('category_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['category_id'], ['category.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('comments',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('comment', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('dislike',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('like',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('post_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
def downgrade():
    op.create_table(
        'team',
        sa.Column('id',
                  sa.INTEGER(),
                  server_default=sa.text(u"nextval('team_id_seq'::regclass)"),
                  nullable=False),
        sa.Column('created_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('title',
                  sa.VARCHAR(length=250),
                  autoincrement=False,
                  nullable=False),
        sa.Column('userid',
                  sa.VARCHAR(length=22),
                  autoincrement=False,
                  nullable=False),
        sa.Column('owners', sa.BOOLEAN(), autoincrement=False, nullable=False),
        sa.Column('orgid',
                  sa.VARCHAR(length=22),
                  autoincrement=False,
                  nullable=False),
        sa.Column('members', sa.BOOLEAN(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name=u'team_pkey'),
        postgresql_ignore_search_path=False)
    op.create_table(
        'organization',
        sa.Column('id',
                  sa.INTEGER(),
                  server_default=sa.text(
                      u"nextval('organization_id_seq'::regclass)"),
                  nullable=False),
        sa.Column('created_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('domain',
                  sa.VARCHAR(length=253),
                  autoincrement=False,
                  nullable=True),
        sa.Column('logo_image',
                  sa.VARCHAR(length=250),
                  autoincrement=False,
                  nullable=True),
        sa.Column('cover_image',
                  sa.VARCHAR(length=250),
                  autoincrement=False,
                  nullable=True),
        sa.Column('description',
                  sa.TEXT(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('userid',
                  sa.VARCHAR(length=22),
                  autoincrement=False,
                  nullable=False),
        sa.Column('name',
                  sa.VARCHAR(length=250),
                  autoincrement=False,
                  nullable=False),
        sa.Column('title',
                  sa.VARCHAR(length=250),
                  autoincrement=False,
                  nullable=False),
        sa.Column('admin_team_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('hiring_team_id',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['admin_team_id'], [u'team.id'],
                                name=u'organization_admin_team_id_fkey',
                                ondelete=u'SET NULL'),
        sa.ForeignKeyConstraint(['hiring_team_id'], [u'team.id'],
                                name=u'organization_hiring_team_id_fkey',
                                ondelete=u'SET NULL'),
        sa.PrimaryKeyConstraint('id', name=u'organization_pkey'),
        postgresql_ignore_search_path=False)
    op.create_table(
        'org_location', sa.Column('id', sa.INTEGER(), nullable=False),
        sa.Column('created_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('latitude', sa.NUMERIC(), autoincrement=False,
                  nullable=True),
        sa.Column('longitude',
                  sa.NUMERIC(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.Column('title',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('address1',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('address2',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('city',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('state',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('postcode',
                  sa.VARCHAR(length=16),
                  autoincrement=False,
                  nullable=True),
        sa.Column('country',
                  sa.VARCHAR(length=80),
                  autoincrement=False,
                  nullable=True),
        sa.Column('geonameid',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('url_id', sa.INTEGER(), autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['org_id'], [u'organization.id'],
                                name=u'org_location_org_id_fkey'),
        sa.PrimaryKeyConstraint('id', name=u'org_location_pkey'))
    op.create_table(
        'users_teams',
        sa.Column('created_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('updated_at',
                  postgresql.TIMESTAMP(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('user_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('team_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['team_id'], [u'team.id'],
                                name=u'users_teams_team_id_fkey'),
        sa.ForeignKeyConstraint(['user_id'], [u'user.id'],
                                name=u'users_teams_user_id_fkey'),
        sa.PrimaryKeyConstraint('user_id', 'team_id',
                                name=u'users_teams_pkey'))
    op.add_column(
        'jobpost',
        sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key(u'jobpost_org_id_fkey', 'jobpost', 'organization',
                          ['org_id'], ['id'])
    op.create_index('ix_jobpost_org_id', 'jobpost', ['org_id'], unique=False)
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'users', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=64), nullable=True),
        sa.Column('email', sa.String(length=64), nullable=True),
        sa.Column('password_hash', sa.String(length=128), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_index(op.f('ix_users_username'),
                    'users', ['username'],
                    unique=True)
    op.create_table(
        'carts', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('nf_calories',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_total_fat',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_saturated_fat',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_cholesterol',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_sodium',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_total_carbohydrate',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_dietary_fiber',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_sugars',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_protein',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['users.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'food_items', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('nf_calories',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_total_fat',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_saturated_fat',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_cholesterol',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_sodium',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_total_carbohydrate',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_dietary_fiber',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_sugars',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('nf_protein',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('serving_qty',
                  sa.Numeric(decimal_return_scale=2),
                  nullable=True),
        sa.Column('serving_unit', sa.String(length=32), nullable=True),
        sa.Column('cart_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['cart_id'],
            ['carts.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_food_items_name'),
                    'food_items', ['name'],
                    unique=False)
示例#53
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tags',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.Text(), nullable=False),
    sa.Column('email', sa.Text(), nullable=False),
    sa.Column('password', sa.Text(), nullable=False),
    sa.Column('image', sa.Text(), nullable=True),
    sa.Column('bio', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('email', 'password', name='unique_username_email')
    )
    op.create_table('articles',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('description', sa.Text(), nullable=False),
    sa.Column('body', sa.Text(), nullable=False),
    sa.Column('slug', sa.Text(), nullable=False),
    sa.Column('title', sa.Text(), nullable=False),
    sa.Column('author_user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['author_user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('slug')
    )
    op.create_table('follows',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('followee_user_id', sa.Integer(), nullable=False),
    sa.Column('follower_user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['followee_user_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['follower_user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('followee_user_id', 'follower_user_id')
    )
    op.create_table('article_tags',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('article_id', sa.Integer(), nullable=False),
    sa.Column('tag_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['article_id'], ['articles.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ),
    sa.PrimaryKeyConstraint('article_id', 'tag_id')
    )
    op.create_table('comments',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('article_id', sa.Integer(), nullable=False),
    sa.Column('body', sa.Text(), nullable=False),
    sa.Column('author_user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['article_id'], ['articles.id'], ),
    sa.ForeignKeyConstraint(['author_user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('favorites',
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('article_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['article_id'], ['articles.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'article_id')
    )
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('environment',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('width', sa.Integer(), nullable=True),
    sa.Column('height', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('message',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('content', sa.String(length=256), nullable=True),
    sa.Column('color', sa.String(length=24), nullable=True),
    sa.Column('mods', sa.String(length=256), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('object_effect',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('health', sa.Integer(), nullable=True),
    sa.Column('weight', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('thread',
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('thread_hash', sa.String(length=64), nullable=True),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=16), nullable=True),
    sa.Column('password_hash', sa.String(length=100), nullable=True),
    sa.Column('password_salt', sa.String(length=10), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('email',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=75), nullable=True),
    sa.Column('verified', sa.Boolean(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('game_object',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('width', sa.Integer(), nullable=True),
    sa.Column('height', sa.Integer(), nullable=True),
    sa.Column('posx', sa.Integer(), nullable=True),
    sa.Column('posy', sa.Integer(), nullable=True),
    sa.Column('acquirable', sa.Boolean(), nullable=True),
    sa.Column('collidable', sa.Boolean(), nullable=True),
    sa.Column('environment_id', sa.Integer(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['environment_id'], ['environment.id'], ),
    sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('inventory_object',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('use_effect', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['use_effect'], ['object_effect.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_status',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('health', sa.Integer(), nullable=True),
    sa.Column('weight', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_thread',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('thread_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['thread_id'], ['thread.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    op.create_table('game_inventory',
    sa.Column('game_object_id', sa.Integer(), nullable=True),
    sa.Column('inventory_object_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['game_object_id'], ['game_object.id'], ),
    sa.ForeignKeyConstraint(['inventory_object_id'], ['inventory_object.id'], )
    )
    op.create_table('user_inventory',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('quantity', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('inventory_object_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['inventory_object_id'], ['inventory_object.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
示例#55
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    if get_version() != -1:
        return

    op.create_table('version',
                    sa.Column('name', sa.String(length=32), nullable=False),
                    sa.Column('value', sa.Integer(), nullable=False),
                    sa.PrimaryKeyConstraint('name'))
    op.create_table(
        'user', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('email', sa.String(length=256), nullable=False),
        sa.Column('password', sa.String(length=256), nullable=True),
        sa.Column('active', sa.Boolean(), nullable=False),
        sa.Column('confirmed_at', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'))
    op.create_table(
        'role', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('description', sa.String(length=256), nullable=False),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name'))
    op.create_table(
        'setting', sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('setting', sa.String(length=256), nullable=False),
        sa.Column('value', sa.String(length=1024), nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('user_id', 'setting'))
    op.create_table('roles_users',
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.Column('role_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['role_id'],
                        ['role.id'],
                    ), sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['user.id'],
                    ))
    op.create_table('servergroup', sa.Column('id',
                                             sa.Integer(),
                                             nullable=False),
                    sa.Column('user_id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=128), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['user.id'],
                    ), sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('user_id', 'name'))
    op.create_table(
        'server', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('servergroup_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('host', sa.String(length=128), nullable=False),
        sa.Column('port', sa.Integer(), nullable=False),
        sa.Column('maintenance_db', sa.String(length=64), nullable=False),
        sa.Column('username', sa.String(length=64), nullable=False),
        sa.Column('ssl_mode', sa.String(length=16), nullable=False),
        sa.ForeignKeyConstraint(
            ['servergroup_id'],
            ['servergroup.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('id'))
    db.engine.execute("""
INSERT INTO "role"
VALUES(1, 'Administrators', 'pgAdmin Administrators Role')
        """)
    db.engine.execute("""
INSERT INTO "roles_users"
VALUES(1, 1);
    """)
    db.engine.execute("""
INSERT INTO "servergroup"
VALUES(1, 1, 'Servers')
""")

    email, password = user_info()
    current_salt = getattr(config, 'SECURITY_PASSWORD_SALT',
                           base64.urlsafe_b64encode(os.urandom(32)).decode())
    if current_app.extensions.get('security') is None:
        current_app.config['SECURITY_PASSWORD_SALT'] = current_salt
        user_datastore = SQLAlchemyUserDatastore(db, User, Role)
        Security(current_app, user_datastore, register_blueprint=False)
    else:
        current_app.config['SECURITY_PASSWORD_SALT'] = current_salt
    setattr(config, 'SECURITY_PASSWORD_SALT', current_salt)
    password = encrypt_password(password)

    db.engine.execute("""
INSERT INTO "user"
    VALUES(1, '%s',
           '%s',
           1, NULL)
    """ % (email, password))
    db.engine.execute("""
INSERT INTO "version"
VALUES('ConfigDB', 2);
    """)
示例#56
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('info_category',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('info_user',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('nick_name', sa.String(length=32), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('mobile', sa.String(length=11), nullable=False),
    sa.Column('avatar_url', sa.String(length=256), nullable=True),
    sa.Column('last_login', sa.DateTime(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.Column('signature', sa.String(length=512), nullable=True),
    sa.Column('gender', sa.Enum('MAN', 'WOMAN'), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('mobile'),
    sa.UniqueConstraint('nick_name')
    )
    op.create_table('info_news',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=256), nullable=False),
    sa.Column('source', sa.String(length=64), nullable=False),
    sa.Column('digest', sa.String(length=512), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('clicks', sa.Integer(), nullable=True),
    sa.Column('index_image_url', sa.String(length=256), nullable=True),
    sa.Column('category_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('reason', sa.String(length=256), nullable=True),
    sa.ForeignKeyConstraint(['category_id'], ['info_category.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['info_user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('info_user_fans',
    sa.Column('follower_id', sa.Integer(), nullable=False),
    sa.Column('followed_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['followed_id'], ['info_user.id'], ),
    sa.ForeignKeyConstraint(['follower_id'], ['info_user.id'], ),
    sa.PrimaryKeyConstraint('follower_id', 'followed_id')
    )
    op.create_table('info_comment',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('news_id', sa.Integer(), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('like_count', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['news_id'], ['info_news.id'], ),
    sa.ForeignKeyConstraint(['parent_id'], ['info_comment.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['info_user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('info_user_collection',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('news_id', sa.Integer(), nullable=False),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['news_id'], ['info_news.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['info_user.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'news_id')
    )
    op.create_table('info_comment_like',
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.Column('comment_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['comment_id'], ['info_comment.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['info_user.id'], ),
    sa.PrimaryKeyConstraint('comment_id', 'user_id')
    )
def upgrade():
    op.create_table(
        'track_principals',
        sa.Column('read_access', sa.Boolean(), nullable=False),
        sa.Column('full_access', sa.Boolean(), nullable=False),
        sa.Column('permissions', postgresql.ARRAY(sa.String()), nullable=False),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('track_id', sa.Integer(), nullable=False, index=True),
        sa.Column('local_group_id', sa.Integer(), nullable=True, index=True),
        sa.Column('mp_group_provider', sa.String(), nullable=True),
        sa.Column('event_role_id', sa.Integer(), nullable=True, index=True),
        sa.Column('mp_group_name', sa.String(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True, index=True),
        sa.Column(
            'type',
            PyIntEnum(PrincipalType, exclude_values={PrincipalType.network}),
            nullable=False,
        ),
        sa.Column('email', sa.String(), nullable=True, index=True),
        sa.CheckConstraint('NOT full_access', name='no_full_access'),
        sa.CheckConstraint('NOT read_access', name='no_read_access'),
        sa.CheckConstraint('email IS NULL OR email = lower(email)', name='lowercase_email'),
        sa.CheckConstraint('read_access OR full_access OR array_length(permissions, 1) IS NOT NULL', name='has_privs'),
        sa.CheckConstraint(
            'type != 1 OR (email IS NULL AND event_role_id IS NULL AND local_group_id IS NULL AND '
            'mp_group_name IS NULL AND mp_group_provider IS NULL AND user_id IS NOT NULL)', name='valid_user'),
        sa.CheckConstraint(
            'type != 2 OR (email IS NULL AND event_role_id IS NULL AND mp_group_name IS NULL AND '
            'mp_group_provider IS NULL AND user_id IS NULL AND local_group_id IS NOT NULL)', name='valid_local_group'),
        sa.CheckConstraint(
            'type != 3 OR (email IS NULL AND event_role_id IS NULL AND local_group_id IS NULL AND '
            'user_id IS NULL AND mp_group_name IS NOT NULL AND mp_group_provider IS NOT NULL)',
            name='valid_multipass_group'
        ),
        sa.CheckConstraint(
            'type != 4 OR (event_role_id IS NULL AND local_group_id IS NULL AND mp_group_name IS NULL AND '
            'mp_group_provider IS NULL AND user_id IS NULL AND email IS NOT NULL)', name='valid_email'),
        sa.CheckConstraint(
            'type != 6 OR (email IS NULL AND local_group_id IS NULL AND mp_group_name IS NULL AND '
            'mp_group_provider IS NULL AND user_id IS NULL AND event_role_id IS NOT NULL)', name='valid_event_role'),
        sa.ForeignKeyConstraint(['event_role_id'], ['events.roles.id']),
        sa.ForeignKeyConstraint(['local_group_id'], ['users.groups.id']),
        sa.ForeignKeyConstraint(['track_id'], ['events.tracks.id']),
        sa.ForeignKeyConstraint(['user_id'], ['users.users.id']),
        sa.PrimaryKeyConstraint('id'),
        schema='events',
    )

    op.create_index(
        None,
        'track_principals',
        ['mp_group_provider', 'mp_group_name'],
        unique=False,
        schema='events',
    )
    op.create_index(
        'ix_uq_track_principals_email',
        'track_principals',
        ['email', 'track_id'],
        unique=True,
        schema='events',
        postgresql_where=sa.text('type = 4'),
    )
    op.create_index(
        'ix_uq_track_principals_local_group',
        'track_principals',
        ['local_group_id', 'track_id'],
        unique=True,
        schema='events',
        postgresql_where=sa.text('type = 2'),
    )
    op.create_index(
        'ix_uq_track_principals_mp_group',
        'track_principals',
        ['mp_group_provider', 'mp_group_name', 'track_id'],
        unique=True,
        schema='events',
        postgresql_where=sa.text('type = 3'),
    )
    op.create_index(
        'ix_uq_track_principals_user',
        'track_principals',
        ['user_id', 'track_id'],
        unique=True,
        schema='events',
        postgresql_where=sa.text('type = 1'),
    )

    _upgrade_permissions()

    op.drop_table('track_conveners', schema='events')
    op.drop_table('track_abstract_reviewers', schema='events')
示例#58
0
def upgrade():
    amendement_location = op.create_table(
        "amendement_location",
        sa.Column("pk", sa.Integer(), nullable=False),
        sa.Column("amendement_pk", sa.Integer(), nullable=False),
        sa.Column("user_table_pk", sa.Integer(), nullable=True),
        sa.Column("shared_table_pk", sa.Integer(), nullable=True),
        sa.Column("batch_pk", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ["amendement_pk"],
            ["amendements.pk"],
            name=op.f("amendement_location_amendement_pk_fkey"),
            ondelete="cascade",
        ),
        sa.ForeignKeyConstraint(
            ["batch_pk"], ["batches.pk"],
            name=op.f("amendement_location_batch_pk_fkey")),
        sa.ForeignKeyConstraint(
            ["shared_table_pk"],
            ["shared_tables.pk"],
            name=op.f("amendement_location_shared_table_pk_fkey"),
        ),
        sa.ForeignKeyConstraint(
            ["user_table_pk"],
            ["user_tables.pk"],
            name=op.f("amendement_location_user_table_pk_fkey"),
        ),
        sa.PrimaryKeyConstraint("pk"),
    )
    op.create_index(
        "ix_amendement_location__amendement_pk",
        "amendement_location",
        ["amendement_pk"],
        unique=True,
    )

    # Migrate data
    connection = op.get_bind()
    amendements = connection.execute(
        "SELECT pk, user_table_pk, shared_table_pk, batch_pk FROM amendements;"
    )
    op.bulk_insert(
        amendement_location,
        [{
            "amendement_pk": pk,
            "user_table_pk": user_table_pk,
            "shared_table_pk": shared_table_pk,
            "batch_pk": batch_pk,
        } for pk, user_table_pk, shared_table_pk, batch_pk in amendements],
    )

    op.drop_index(
        "ix_amendement_user_contents__amendement_pk",
        table_name="amendement_user_contents",
    )
    op.create_index(
        "ix_amendement_user_contents__amendement_pk",
        "amendement_user_contents",
        ["amendement_pk"],
        unique=True,
    )
    op.drop_constraint("amendements_batch_pk_fkey",
                       "amendements",
                       type_="foreignkey")
    op.drop_constraint("amendements_shared_table_pk_fkey",
                       "amendements",
                       type_="foreignkey")
    op.drop_constraint("amendements_user_table_pk_fkey",
                       "amendements",
                       type_="foreignkey")
    op.drop_column("amendements", "shared_table_pk")
    op.drop_column("amendements", "user_table_pk")
    op.drop_column("amendements", "batch_pk")
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'user', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=50), nullable=False),
        sa.Column('password',
                  sa.String(length=255),
                  server_default='',
                  nullable=False),
        sa.Column('reset_password_token',
                  sa.String(length=100),
                  server_default='',
                  nullable=False),
        sa.Column('email', sa.String(length=75), nullable=False),
        sa.Column('confirmed_at', sa.DateTime(), nullable=True),
        sa.Column('is_active',
                  sa.Boolean(),
                  server_default='0',
                  nullable=False),
        sa.Column('first_name',
                  sa.String(length=100),
                  server_default='',
                  nullable=False),
        sa.Column('last_name',
                  sa.String(length=100),
                  server_default='',
                  nullable=False),
        sa.Column('string_property_01', sa.String(length=80), nullable=True),
        sa.Column('string_property_02', sa.String(length=80), nullable=True),
        sa.Column('string_property_03', sa.String(length=80), nullable=True),
        sa.Column('string_property_04', sa.String(length=80), nullable=True),
        sa.Column('string_property_05', sa.String(length=80), nullable=True),
        sa.Column('integer_property_01', sa.Integer(), nullable=True),
        sa.Column('integer_property_02', sa.Integer(), nullable=True),
        sa.Column('integer_property_03', sa.Integer(), nullable=True),
        sa.Column('integer_property_04', sa.Integer(), nullable=True),
        sa.Column('integer_property_05', sa.Integer(), nullable=True),
        sa.Column('integer_property_06', sa.Integer(), nullable=True),
        sa.Column('integer_property_07', sa.Integer(), nullable=True),
        sa.Column('integer_property_08', sa.Integer(), nullable=True),
        sa.Column('integer_property_09', sa.Integer(), nullable=True),
        sa.Column('integer_property_10', sa.Integer(), nullable=True),
        sa.Column('boolean_property_01', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_02', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_03', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_04', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_05', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_06', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_07', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_08', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_09', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_10', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_11', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_12', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_13', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_14', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_15', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_16', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_17', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_18', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_19', sa.Boolean(), nullable=True),
        sa.Column('boolean_property_20', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'),
        sa.UniqueConstraint('username'))
    op.create_table('project', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=50), nullable=False),
                    sa.Column('owner_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['owner_id'],
                        ['user.id'],
                    ), sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('name'))
    op.create_table('branch', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=50), nullable=False),
                    sa.Column('owner_id', sa.Integer(), nullable=True),
                    sa.Column('origin_id', sa.Integer(), nullable=True),
                    sa.Column('project_id', sa.Integer(), nullable=True),
                    sa.Column('expires', sa.Boolean(), nullable=False),
                    sa.Column('expiration', sa.DateTime(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['origin_id'],
                        ['branch.id'],
                    ), sa.ForeignKeyConstraint(
                        ['owner_id'],
                        ['user.id'],
                    ), sa.ForeignKeyConstraint(
                        ['project_id'],
                        ['project.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('named_tag', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('name', sa.String(length=20), nullable=False),
                    sa.Column('project_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['project_id'],
                        ['project.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('thread', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('title', sa.Unicode(length=80), nullable=False),
                    sa.Column('owner_id', sa.Integer(), nullable=True),
                    sa.Column('project_id', sa.Integer(), nullable=True),
                    sa.Column('flag', sa.String(length=10), nullable=False),
                    sa.Column('posted_at', sa.DateTime(), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['owner_id'],
                        ['user.id'],
                    ), sa.ForeignKeyConstraint(
                        ['project_id'],
                        ['project.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'comment', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('lineage', sa.String(length=200), nullable=True),
        sa.Column('thread_id', sa.Integer(), nullable=True),
        sa.Column('owner_id', sa.Integer(), nullable=True),
        sa.Column('content', sa.Unicode(length=2000), nullable=False),
        sa.Column('posted_at', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ['owner_id'],
            ['user.id'],
        ), sa.ForeignKeyConstraint(
            ['thread_id'],
            ['thread.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'custom_tag', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('thread_id', sa.Integer(), nullable=True),
        sa.Column('named_tag_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['named_tag_id'],
            ['named_tag.id'],
        ), sa.ForeignKeyConstraint(
            ['thread_id'],
            ['thread.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'file_tag', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('thread_id', sa.Integer(), nullable=True),
        sa.Column('filename', sa.String(length=50), nullable=False),
        sa.ForeignKeyConstraint(
            ['thread_id'],
            ['thread.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_table('free_tag', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('thread_id', sa.Integer(), nullable=True),
                    sa.Column('name', sa.String(length=20), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['thread_id'],
                        ['thread.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('user_tag', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('thread_id', sa.Integer(), nullable=True),
                    sa.Column('user_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['thread_id'],
                        ['thread.id'],
                    ), sa.ForeignKeyConstraint(
                        ['user_id'],
                        ['user.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table('likes', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('comment_id', sa.Integer(), nullable=True),
                    sa.Column('owner_id', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['comment_id'],
                        ['comment.id'],
                    ), sa.ForeignKeyConstraint(
                        ['owner_id'],
                        ['user.id'],
                    ), sa.PrimaryKeyConstraint('id'))
示例#60
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('campuses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('localization', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('messages',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.Column('last_name', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=128), nullable=False),
    sa.Column('body', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('programs',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('contacts',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('description', sa.String(length=128), nullable=False),
    sa.Column('telephone_number', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=128), nullable=True),
    sa.Column('campus_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['campus_id'], ['campuses.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('courses',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=False),
    sa.Column('class_hours', sa.Integer(), nullable=True),
    sa.Column('weekly_meetings', sa.Integer(), nullable=True),
    sa.Column('term_load', sa.Integer(), nullable=True),
    sa.Column('acronym', sa.String(length=10), nullable=True),
    sa.Column('program_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['program_id'], ['programs.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=64), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('lattes', sa.String(length=256), nullable=True),
    sa.Column('confirmed', sa.Boolean(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_index(op.f('ix_users_lattes'), 'users', ['lattes'], unique=True)
    op.create_table('documents',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('filename', sa.String(length=128), nullable=False),
    sa.Column('uploader_id', sa.Integer(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('creation_date', sa.DateTime(), nullable=True),
    sa.Column('course_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['course_id'], ['courses.id'], ),
    sa.ForeignKeyConstraint(['uploader_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('news',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=256), nullable=False),
    sa.Column('link', sa.String(length=256), nullable=True),
    sa.Column('body', sa.Text(), nullable=True),
    sa.Column('published', sa.Boolean(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('opportunities',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=256), nullable=False),
    sa.Column('institution', sa.String(length=256), nullable=False),
    sa.Column('vacancies_amount', sa.Integer(), nullable=True),
    sa.Column('published', sa.Boolean(), nullable=True),
    sa.Column('link', sa.String(length=256), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('vles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('link', sa.String(length=256), nullable=False),
    sa.Column('author_id', sa.Integer(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('creation_date', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('images',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('filename', sa.String(length=128), nullable=False),
    sa.Column('alternate', sa.String(length=512), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('last_modified', sa.DateTime(), nullable=True),
    sa.Column('creation_date', sa.DateTime(), nullable=True),
    sa.Column('news_id', sa.Integer(), nullable=True),
    sa.Column('opportunity_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['news_id'], ['news.id'], ),
    sa.ForeignKeyConstraint(['opportunity_id'], ['opportunities.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )