1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- """Add makehidden permission
- Revision ID: 63eabbb0e837
- Revises: 05da2ac3bd49
- Create Date: 2017-09-03 23:43:54.316625
- """
- from alembic import op
- import sqlalchemy as sa
- # revision identifiers, used by Alembic.
- revision = '63eabbb0e837'
- down_revision = '05da2ac3bd49'
- branch_labels = ()
- depends_on = None
- def upgrade():
- # ### commands auto generated by Alembic - please adjust! ###
- with op.batch_alter_table('groups', schema=None) as batch_op:
- batch_op.add_column(
- sa.Column('makehidden', sa.Boolean(), nullable=True)
- )
- with op.batch_alter_table('groups', schema=None) as batch_op:
- groups = sa.sql.table(
- 'groups',
- sa.sql.column('makehidden'),
- sa.sql.column('admin'), sa.sql.column('super_mod'), sa.sql.column('mod')
- )
- batch_op.execute(
- groups.update().where(
- sa.or_(
- groups.c.admin == True,
- groups.c.mod == True,
- groups.c.super_mod == True
- )
- ).values(makehidden=True)
- )
- batch_op.execute(
- groups.update().where(sa.and_(
- groups.c.admin != True,
- groups.c.mod != True,
- groups.c.super_mod != True
- )).values(makehidden=False)
- )
- batch_op.alter_column('makehidden', existing_type=sa.Boolean(), nullable=False)
- # ### end Alembic commands ###
- def downgrade():
- # ### commands auto generated by Alembic - please adjust! ###
- with op.batch_alter_table('groups', schema=None) as batch_op:
- batch_op.drop_column('makehidden')
- # ### end Alembic commands ###
|