53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""empty message
|
|
|
|
Revision ID: efbd47fca2fd
|
|
Revises: 6b444e5e2eef
|
|
Create Date: 2018-08-24 14:23:01.904259
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'efbd47fca2fd'
|
|
down_revision = '6b444e5e2eef'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('access_levels',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('device_associations',
|
|
sa.Column('device_id', sa.Integer(), nullable=False),
|
|
sa.Column('account_id', sa.Integer(), nullable=False),
|
|
sa.Column('access_level', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['access_level'], ['access_levels.id'], ),
|
|
sa.ForeignKeyConstraint(['account_id'], ['accounts.id'], ),
|
|
sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ),
|
|
sa.PrimaryKeyConstraint('device_id', 'account_id')
|
|
)
|
|
|
|
access_levels_table = sa.Table('access_levels', sa.MetaData(),
|
|
sa.Column('id', sa.Integer),
|
|
sa.Column('name', sa.String))
|
|
|
|
op.bulk_insert(access_levels_table,
|
|
[
|
|
{'id':1, 'name':'FULL'}
|
|
]
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('device_associations')
|
|
op.drop_table('access_levels')
|
|
# ### end Alembic commands ###
|