university-final-iot-backend/migrations/versions/43e5ad1c4393_.py

51 lines
1.6 KiB
Python
Raw Normal View History

2018-11-01 00:45:14 +00:00
"""empty message
Revision ID: 43e5ad1c4393
Revises: c09252c2c547
Create Date: 2018-11-01 00:58:07.570743
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '43e5ad1c4393'
down_revision = 'c09252c2c547'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('access_levels', sa.Column('permissions',
sa.ARRAY(sa.String()), nullable=True))
access_levels = sa.table('access_levels', sa.column('id', sa.Integer),
sa.column('permissions', sa.ARRAY(sa.String)))
op.execute(access_levels.update().where(access_levels.c.id == op.inline_literal(1)).
values({'permissions':
['VIEW_DEVICE', 'MODIFY_DEVICE',
'DELETE_DEVICE', 'WIDGET_READ',
'WIDGET_WRITE', 'CONFIGURATION_READ',
'CONFIGURATION_WRITE', 'SECRET_READ']})
)
op.alter_column('access_levels', 'permissions',
existing_type=sa.ARRAY(sa.String()),
nullable=False)
op.alter_column('dashboard_widgets', 'device_id',
existing_type=sa.INTEGER(),
nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('dashboard_widgets', 'device_id',
existing_type=sa.INTEGER(),
nullable=True)
op.drop_column('access_levels', 'permissions')
# ### end Alembic commands ###