"""views_limit_to_ref

Revision: 0102
Revision ID: 14a5ced5c36c
Revises: 38487891c2c0
Create Date: 2017-08-03 22:25:49.023672

"""

# revision identifiers, used by Alembic.
revision = '14a5ced5c36c'
down_revision = '38487891c2c0'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.add_column('views', sa.Column('limit_to_ref', sa.Boolean(), nullable=True))
    op.execute('UPDATE views SET limit_to_ref = true WHERE card_ref IS NOT NULL')


def downgrade():
    op.drop_column('views', 'limit_to_ref')
