"""remove_daterange

Revision: 0088
Revision ID: 57c60056d090
Revises: 4e8995b8a6a6
Create Date: 2017-03-15 09:36:44.212943

"""

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

from alembic import op
import sqlalchemy as sa


def upgrade():
    op.execute("""
        update card_attributes set value = json_build_object('end', value->>0)::jsonb from attributes
        where attributes.id = card_attributes.attribute_id and attributes.type_name = 'date'
    """)
    op.execute("""update attributes set type_name = 'date' where type_name = 'daterange'""")
    op.execute("""update card_attributes set type_name = 'date' where type_name = 'daterange'""")


def downgrade():
    pass
