"""default_views

Revision: 0053
Revision ID: 78a2be497a8
Revises: 7790b50d0be
Create Date: 2016-03-20 10:27:35.183434

"""

# revision identifiers, used by Alembic.
revision = '78a2be497a8'
down_revision = '7790b50d0be'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa

def upgrade():
    op.execute("""
        INSERT INTO views (card_id, title, icon, group_type_id, mode, mode_options)
        SELECT
            c.id, 'Default', 'home', c.default_card_group_type_id, 'kanban', '{"showUngroupedCards": true}'::jsonb
        FROM
            cards c
        WHERE
            c.parent_id is null
    """)
    op.execute("""
        INSERT INTO views (card_id, title, icon, group_type_id, filter, mode, mode_options)
        SELECT
            c.id, 'My cards', 'check-square-o', c.default_card_group_type_id, '@me', 'table', '{"showUngroupedCards": true}'::jsonb
        FROM
            cards c
        WHERE
            c.parent_id is null
    """)
    op.execute("""
        INSERT INTO views (card_id, title, icon, group_type_id, filter, mode, mode_options)
        SELECT
            c.id, 'Due this week', 'calendar-check-o', c.default_card_group_type_id, 'due:week', 'kanban', '{"showUngroupedCards": true}'::jsonb
        FROM
            cards c
        WHERE
            c.parent_id is null
    """)


def downgrade():
    pass
