def upgrade():
    op.create_table('event', sa.Column('id', sa.Integer(), nullable=False),
                    sa.Column('date', sa.Date(), nullable=False),
                    sa.Column('price', postgresql.MONEY(), nullable=False),
                    sa.Column('name', sa.String(length=128), nullable=False),
                    sa.Column('created_on', sa.DateTime(), nullable=False),
                    sa.Column('modified_on', sa.DateTime(), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_event_date'), 'event', ['date'], unique=False)
    op.create_index(op.f('ix_event_name'), 'event', ['name'], unique=False)

    conn = op.get_bind()
    date = str(datetime.now())
    conn.execute("""
    insert into event
        (name, date, price, created_on, modified_on)
            values
        (
            'Godsmack Concert',
            '09-25-2020',
            129.99,
            '{0}',
            '{0}'
        );
    """.format(date))
Exemplo n.º 2
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('individual_contributor',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('city', sa.String(length=30), nullable=True),
    sa.Column('state', sa.String(length=2), nullable=True),
    sa.Column('zip', sa.String(length=9), nullable=True),
    sa.Column('employer', sa.String(length=38), nullable=True),
    sa.Column('occupation', sa.String(length=38), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('individual_contribution',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('committee_id', sa.Integer(), nullable=False),
    sa.Column('contributor_id', sa.Integer(), nullable=False),
    sa.Column('amendment_indicator', postgresql.ENUM('N', 'A', 'T', name='amendment_indicator'), nullable=True),
    sa.Column('report_type', sa.String(length=3), nullable=True),
    sa.Column('primary_general_indicator', sa.String(length=5), nullable=True),
    sa.Column('fec_image_ref', sa.String(length=18), nullable=True),
    sa.Column('transaction_type', sa.String(length=3), nullable=True),
    sa.Column('entity_type', sa.String(length=3), nullable=True),
    sa.Column('date', sa.Date(), nullable=True),
    sa.Column('amount', postgresql.MONEY(), nullable=True),
    sa.Column('committee_fec_id', sa.String(length=9), nullable=True),
    sa.Column('other_fec_id', sa.String(length=9), nullable=True),
    sa.ForeignKeyConstraint(['committee_id'], ['committee.id'], ),
    sa.ForeignKeyConstraint(['contributor_id'], ['individual_contributor.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('individual_contribution',
                    'amount',
                    existing_type=sa.Numeric(precision=18, scale=2),
                    type_=postgresql.MONEY(),
                    existing_nullable=True)
Exemplo n.º 4
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'books',
        sa.Column('price',
                  postgresql.MONEY(),
                  autoincrement=False,
                  nullable=True))
Exemplo n.º 5
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'price',
        sa.Column('reported',
                  postgresql.TIMESTAMP(timezone=True),
                  autoincrement=False,
                  nullable=True))
    op.add_column(
        'price',
        sa.Column('price',
                  postgresql.MONEY(),
                  autoincrement=False,
                  nullable=True))
Exemplo n.º 6
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'product', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('author', sa.Text(), nullable=False),
        sa.Column('category', sa.Text(), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('image', postgresql.BYTEA(), nullable=True),
        sa.Column('price', postgresql.MONEY(), nullable=False),
        sa.Column('stock', sa.Integer(), server_default='0', nullable=False),
        sa.Column('rating', sa.Float(), nullable=True),
        sa.Column('reviews', sa.Integer(), server_default='0', nullable=False),
        sa.Column('created_at',
                  sa.DateTime(timezone=True),
                  server_default=sa.text('now()'),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(timezone=True),
                  server_default=sa.text('now()'),
                  nullable=False), sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_product_id'), 'product', ['id'], unique=False)
    op.create_index(op.f('ix_product_name'), 'product', ['name'], unique=True)
Exemplo n.º 7
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('diet',
                    sa.Column('id_diet',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('diet_name',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('id_diet', name='diet_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table('resident',
                    sa.Column('id_resident',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('gender',
                              sa.VARCHAR(length=8),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('surname',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('name',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('patronymic',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('room_number',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('birthday',
                              sa.DATE(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('place_number',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('start_day',
                              sa.DATE(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('final_day',
                              sa.DATE(),
                              autoincrement=False,
                              nullable=True),
                    sa.ForeignKeyConstraint(['place_number'],
                                            ['canteen_place.canteen_number'],
                                            name='place_number'),
                    sa.ForeignKeyConstraint(['room_number'],
                                            ['living_room.room_number'],
                                            name='resident_room_number_fkey'),
                    sa.PrimaryKeyConstraint('id_resident',
                                            name='resident_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table(
        'appointment',
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('id_procedure',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_procedure'],
                                ['medical_procedure.id_procedure'],
                                name='appointment_id_procedure_fkey'),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='appointment_id_resident_fkey'))
    op.create_table('infrastructure',
                    sa.Column('rent_number',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('description',
                              sa.VARCHAR(),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('rent_number',
                                            name='infrastructure_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table('item',
                    sa.Column('id_item',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('item_name',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('id_item', name='item_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table(
        'income',
        sa.Column('operation_number',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('operation_time',
                  sa.DATE(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('sum',
                  postgresql.MONEY(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='id_resident'),
        sa.PrimaryKeyConstraint('operation_number', name='income_pkey'))
    op.create_table('living_room',
                    sa.Column('room_number',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('floor',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=True),
                    sa.Column('room_class',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('room_number',
                                            name='living_room_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table(
        'warehouse',
        sa.Column('id_warehouse',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('number', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column('id_item', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.ForeignKeyConstraint(['id_item'], ['item.id_item'],
                                name='warehouse_id_item_fkey'),
        sa.PrimaryKeyConstraint('id_warehouse', name='warehouse_pkey'))
    op.create_table(
        'consultation',
        sa.Column('id_consultation',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('consultation_name',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='consultation_id_resident_fkey'),
        sa.PrimaryKeyConstraint('id_consultation', name='consultation_pkey'))
    op.create_table('sport_group',
                    sa.Column('id_group',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('group_name',
                              sa.VARCHAR(length=40),
                              autoincrement=False,
                              nullable=True),
                    sa.PrimaryKeyConstraint('id_group',
                                            name='sport_group_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table('canteen_place',
                    sa.Column('canteen_number',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('id_diet',
                              sa.INTEGER(),
                              autoincrement=False,
                              nullable=True),
                    sa.ForeignKeyConstraint(['id_diet'], ['diet.id_diet'],
                                            name='canteen_place_id_diet_fkey'),
                    sa.PrimaryKeyConstraint('canteen_number',
                                            name='canteen_place_pkey'),
                    postgresql_ignore_search_path=False)
    op.create_table(
        'medical_procedure',
        sa.Column('id_procedure',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=False),
        sa.Column('procedure_name',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.PrimaryKeyConstraint('id_procedure', name='medical_procedure_pkey'))
    op.create_table(
        'timetable',
        sa.Column('week_day',
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('start_time',
                  postgresql.TIME(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('finish_time',
                  postgresql.TIME(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('staff_cadr',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['staff_cadr'], ['staff.staff_cadr'],
                                name='staff_cadr'),
        sa.PrimaryKeyConstraint('week_day', name='timetable_pkey'))
    op.create_table(
        'place_rent',
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('rent_number',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='id_resident'),
        sa.ForeignKeyConstraint(['rent_number'],
                                ['infrastructure.rent_number'],
                                name='rent_number'))
    op.create_table(
        'staff',
        sa.Column('staff_cadr',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('surname',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('name',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('patronymic',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('position',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('hours', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.Column('salary',
                  postgresql.MONEY(),
                  autoincrement=False,
                  nullable=True),
        sa.PrimaryKeyConstraint('staff_cadr', name='staff_pkey'))
    op.create_table(
        'sport_membership',
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('id_group', sa.INTEGER(), autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_group'], ['sport_group.id_group'],
                                name='sport_membership_id_group_fkey'),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='sport_membership_id_resident_fkey'))
    op.create_table(
        'parking',
        sa.Column('id_place',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('car_number',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['car_number'], ['car.car_number'],
                                name='parking_car_number_fkey'),
        sa.PrimaryKeyConstraint('id_place', name='parking_pkey'))
    op.create_table(
        'expenses',
        sa.Column('operation_num',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=False),
        sa.Column('operation_data',
                  sa.DATE(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('operation_sum',
                  postgresql.MONEY(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('description',
                  sa.VARCHAR(),
                  autoincrement=False,
                  nullable=True),
        sa.PrimaryKeyConstraint('operation_num', name='expenses_pkey'))
    op.create_table(
        'car',
        sa.Column('car_number',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=False),
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('model',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.Column('color',
                  sa.VARCHAR(length=40),
                  autoincrement=False,
                  nullable=True),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='car_id_resident_fkey'),
        sa.PrimaryKeyConstraint('car_number', name='car_pkey'))
    op.create_table(
        'item_rent',
        sa.Column('id_resident',
                  sa.INTEGER(),
                  autoincrement=False,
                  nullable=True),
        sa.Column('id_item', sa.INTEGER(), autoincrement=False, nullable=True),
        sa.ForeignKeyConstraint(['id_item'], ['item.id_item'],
                                name='item_rent_id_item_fkey'),
        sa.ForeignKeyConstraint(['id_resident'], ['resident.id_resident'],
                                name='item_rent_id_resident_fkey'))
Exemplo n.º 8
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('access',
                    sa.Column('access_id', sa.Integer(), nullable=False),
                    sa.PrimaryKeyConstraint('access_id'))
    op.create_table('badge', sa.Column('badge_id',
                                       sa.Integer(),
                                       nullable=False),
                    sa.Column('name', sa.String(), nullable=True),
                    sa.Column('image_id', sa.BigInteger(), nullable=True),
                    sa.PrimaryKeyConstraint('badge_id'))
    op.create_table('chain', sa.Column('chain_id',
                                       sa.Integer(),
                                       nullable=False),
                    sa.PrimaryKeyConstraint('chain_id'))
    op.create_table('image', sa.Column('image_id',
                                       sa.Integer(),
                                       nullable=False),
                    sa.Column('fspath', sa.String(), nullable=True),
                    sa.Column('imgtype', sa.String(), nullable=True),
                    sa.Column('width', sa.Integer(), nullable=True),
                    sa.Column('height', sa.Integer(), nullable=True),
                    sa.PrimaryKeyConstraint('image_id'),
                    sa.UniqueConstraint('fspath'))
    op.create_table('location',
                    sa.Column('location_id', sa.Integer(), nullable=False),
                    sa.Column('lat', sa.Float(), nullable=True),
                    sa.Column('long', sa.Float(), nullable=True),
                    sa.PrimaryKeyConstraint('location_id'))
    op.create_table(
        'appuser', sa.Column('appuser_id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(), nullable=True),
        sa.Column('password', sa.String(), nullable=True),
        sa.Column('home', sa.Integer(), nullable=True),
        sa.Column('karma', sa.Integer(), nullable=True),
        sa.Column('avatar', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['avatar'], ['image.image_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['home'], ['location.location_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('appuser_id'), sa.UniqueConstraint('username'))
    op.create_table(
        'item', sa.Column('item_id', sa.Integer(), nullable=False),
        sa.Column('code', sa.String(), nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.Column('brand', sa.String(), nullable=True),
        sa.Column('weight', sa.Numeric(), nullable=False),
        sa.Column('weight_unit',
                  sa.String(),
                  server_default=FetchedValue(),
                  nullable=True),
        sa.Column('image_id', sa.Integer(), nullable=True),
        sa.Column('description', sa.Text(), nullable=False),
        sa.ForeignKeyConstraint(['image_id'], ['image.image_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('item_id'), sa.UniqueConstraint('code'))
    op.create_table(
        'store', sa.Column('store_id', sa.Integer(), nullable=False),
        sa.Column('location_id', sa.Integer(), nullable=True),
        sa.Column('chain_id', sa.Integer(), nullable=True),
        sa.Column('name', sa.String(), nullable=True),
        sa.Column('image_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['chain_id'], ['chain.chain_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['image_id'], ['image.image_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['location_id'], ['location.location_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('store_id'))
    op.create_table(
        'badge_appuser', sa.Column('badge_id', sa.Integer(), nullable=False),
        sa.Column('appuser_id', sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(['appuser_id'], ['appuser.appuser_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['badge_id'], ['badge.badge_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('badge_id', 'appuser_id'))
    op.create_table(
        'comment', sa.Column('object_id', sa.Integer(), nullable=False),
        sa.Column('appuser_id', sa.Integer(), nullable=False),
        sa.Column('rating', sa.Numeric(), nullable=True),
        sa.Column('content', sa.Text(), nullable=True),
        sa.Column('type', sa.Integer(), nullable=False),
        sa.CheckConstraint('(content IS NOT NULL) OR (rating IS NOT NULL)'),
        sa.ForeignKeyConstraint(['appuser_id'], ['appuser.appuser_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('object_id', 'type'))
    op.create_table(
        'list', sa.Column('list_id', sa.Integer(), nullable=False),
        sa.Column('owner', sa.Integer(), nullable=True),
        sa.Column('access_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['access_id'], ['access.access_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['owner'], ['appuser.appuser_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('list_id'))
    op.create_table(
        'price', sa.Column('price_id', sa.Integer(), nullable=False),
        sa.Column('currency', sa.String(length=3), nullable=True),
        sa.Column('item_id', sa.Integer(), nullable=True),
        sa.Column('appuser_id', sa.Integer(), nullable=True),
        sa.Column('price', postgresql.MONEY(), nullable=True),
        sa.Column('reported', sa.DateTime(timezone=True), nullable=True),
        sa.Column('store_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['appuser_id'], ['appuser.appuser_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['item_id'], ['item.item_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.ForeignKeyConstraint(['store_id'], ['store.store_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT'),
        sa.PrimaryKeyConstraint('price_id'))
    op.create_table(
        'list_item', sa.Column('item_id', sa.Integer(), nullable=False),
        sa.Column('list_id', sa.Integer(), nullable=False),
        sa.Column('quantity',
                  sa.Integer(),
                  server_default=FetchedValue(),
                  nullable=True),
        sa.ForeignKeyConstraint(['item_id'], ['item.item_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT',
                                name='list_item_item_id_fkey'),
        sa.ForeignKeyConstraint(['list_id'], ['list.list_id'],
                                onupdate='CASCADE',
                                ondelete='RESTRICT',
                                name='list_item_list_id_fkey'),
        sa.PrimaryKeyConstraint('item_id', 'list_id'))
Exemplo n.º 9
0
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('product', 'price',
               existing_type=sa.Numeric(precision=10, scale=2),
               type_=postgresql.MONEY(),
               existing_nullable=False)