Blame alembic/versions/3237fc64b306_read_only_mode_in_projects.py

Vivek Anand ed7e6e
"""Read Only mode in projects
Vivek Anand ed7e6e
Vivek Anand ed7e6e
Revision ID: 3237fc64b306
Vivek Anand ed7e6e
Revises: c34f4b09ef18
Vivek Anand ed7e6e
Create Date: 2017-09-01 22:51:18.232541
Vivek Anand ed7e6e
Vivek Anand ed7e6e
"""
Vivek Anand ed7e6e
Vivek Anand ed7e6e
# revision identifiers, used by Alembic.
Vivek Anand ed7e6e
revision = '3237fc64b306'
Vivek Anand ed7e6e
down_revision = 'c34f4b09ef18'
Vivek Anand ed7e6e
Vivek Anand ed7e6e
from alembic import op
Vivek Anand ed7e6e
import sqlalchemy as sa
Vivek Anand ed7e6e
Vivek Anand ed7e6e
Vivek Anand ed7e6e
def upgrade():
Vivek Anand ed7e6e
    ''' Add a column to mark a project read only '''
Vivek Anand ed7e6e
    op.add_column(
Vivek Anand ed7e6e
        'projects',
Vivek Anand ed7e6e
        sa.Column(
Vivek Anand ed7e6e
            'read_only',
Vivek Anand ed7e6e
            sa.Boolean,
Vivek Anand ed7e6e
            default=True,
Vivek Anand ed7e6e
            nullable=True,
Vivek Anand ed7e6e
        )
Vivek Anand ed7e6e
    )
Vivek Anand ed7e6e
    op.execute(''' UPDATE projects SET read_only=False ''')
Vivek Anand ed7e6e
    op.alter_column(
Vivek Anand ed7e6e
        'projects',
Vivek Anand ed7e6e
        'read_only',
Vivek Anand ed7e6e
        nullable=False,
Vivek Anand ed7e6e
        existing_nullable=True
Vivek Anand ed7e6e
    )
Vivek Anand ed7e6e
Vivek Anand ed7e6e
Vivek Anand ed7e6e
def downgrade():
Vivek Anand ed7e6e
    ''' Remove the read_only column from Projects '''
Vivek Anand ed7e6e
    op.drop_column('projects', 'read_only')