"""attribute_containers

Revision: 0080
Revision ID: 30ad9d5dfff6
Revises: 369797b75a28
Create Date: 2016-12-22 11:08:56.517631

"""

# revision identifiers, used by Alembic.
revision = '30ad9d5dfff6'
down_revision = '369797b75a28'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


def upgrade():
    op.add_column('attribute_groups', sa.Column('containers', postgresql.JSONB(), nullable=True))
    op.execute("""UPDATE attributes SET container = '__top__' WHERE container = 'top'""")
    op.execute("""UPDATE attribute_positions SET container = '__top__' WHERE container = 'top'""")


def downgrade():
    op.drop_column('attribute_groups', 'containers')
