university-final-iot-backend/migrations/versions/55611f1868bd_.py

45 lines
1.4 KiB
Python

"""empty message
Revision ID: 55611f1868bd
Revises: 5aa58dcd7a2c
Create Date: 2018-09-23 00:56:34.193022
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '55611f1868bd'
down_revision = '5aa58dcd7a2c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('roles', sa.Column('permissions', sa.ARRAY(sa.String()), nullable=True))
op.create_unique_constraint(None, 'roles', ['display_name'])
role = sa.table('roles', sa.column('id', sa.Integer),
sa.column('permissions', sa.ARRAY(sa.String)))
op.execute(role.update().where(role.c.id == op.inline_literal(1)).
values({'permissions':
['CREATE_DEVICE_TYPE', 'ASSIGN_ROLE',
'CREATE_DEVICE', 'CREATE_DASHBOARD',
'READ_DEVICE_TYPES', 'READ_ROLES']})
)
op.execute(role.update().where(role.c.id == op.inline_literal(2)).
values({'permissions':
['CREATE_DEVICE', 'CREATE_DASHBOARD',
'READ_DEVICE_TYPES', 'READ_ROLES']})
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'roles', type_='unique')
op.drop_column('roles', 'permissions')
# ### end Alembic commands ###