36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
|
"""Add UserRegion table
|
||
|
|
||
|
Revision ID: 9512773a4a2
|
||
|
Revises: 499f6f08de3
|
||
|
Create Date: 2015-09-01 14:17:08.628052
|
||
|
|
||
|
"""
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = '9512773a4a2'
|
||
|
down_revision = '499f6f08de3'
|
||
|
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
def upgrade(tables):
|
||
|
### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table('userregion',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
||
|
sa.Column('location_id', sa.Integer(), nullable=False),
|
||
|
sa.ForeignKeyConstraint(['location_id'], ['imagestoragelocation.id'], name=op.f('fk_userregion_location_id_imagestoragelocation')),
|
||
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_userregion_user_id_user')),
|
||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_userregion'))
|
||
|
)
|
||
|
op.create_index('userregion_location_id', 'userregion', ['location_id'], unique=False)
|
||
|
op.create_index('userregion_user_id', 'userregion', ['user_id'], unique=False)
|
||
|
### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade(tables):
|
||
|
### commands auto generated by Alembic - please adjust! ###
|
||
|
op.drop_table('userregion')
|
||
|
### end Alembic commands ###
|