"""empty message

Revision ID: 1815829d365
Revises: 3fcddd64a72
Create Date: 2016-02-09 17:58:47.362133

"""

# revision identifiers, used by Alembic.
revision = '1815829d365'
down_revision = '3fcddd64a72'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    # create new unique index to include geometry_application_ref
    op.execute("DROP INDEX title_abr_idx")
    op.execute("CREATE UNIQUE INDEX title_abr_geo_idx ON records((record->'data'->>'title_number'),(record->'data'->>'application_reference'), (record->'data'->>'geometry_application_reference'))")
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("DROP INDEX title_abr_geo_idx")
    op.execute("CREATE UNIQUE INDEX title_abr_idx ON records((record->'data'->>'title_number'),(record->'data'->>'application_reference'))")
    ### end Alembic commands ###

"""empty message

Revision ID: 1815829d365
Revises: 3fcddd64a72
Create Date: 2016-02-09 17:58:47.362133

"""

# revision identifiers, used by Alembic.
revision = '1815829d365'
down_revision = '3fcddd64a72'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    # create new unique index to include geometry_application_ref
    op.execute("DROP INDEX title_abr_idx")
    op.execute("CREATE UNIQUE INDEX title_abr_geo_idx ON records((record->'data'->>'title_number'),(record->'data'->>'application_reference'), (case when (record->'data'->>'geometry_application_reference') IS NULL then 'NULL' else (record->'data'->>'geometry_application_reference') end))")
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("DROP INDEX title_abr_geo_idx")
    op.execute("CREATE UNIQUE INDEX title_abr_idx ON records((record->'data'->>'title_number'),(record->'data'->>'application_reference'))")
    ### end Alembic commands ###

Fix index for title without geo abr
Fix index for title without geo abr