"""project_color

Revision: 0087
Revision ID: 4e8995b8a6a6
Revises: 37726611a9ea
Create Date: 2017-03-10 13:59:57.657910

"""

# revision identifiers, used by Alembic.
revision = '4e8995b8a6a6'
down_revision = '37726611a9ea'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.add_column('projects', sa.Column('color', sa.String(), nullable=True))
    op.execute("""
        UPDATE projects SET color = (SELECT board_bgcolor FROM cards WHERE id = projects.top_level_card_id)
    """)


def downgrade():
    op.drop_column('projects', 'color')
