"""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 ###

@@ -579,16 +579,27 @@
 rence'),
+ (case when
  (record
@@ -634,32 +634,114 @@
 tion_reference')
+ IS NULL then 'NULL' else (record-%3E'data'-%3E%3E'geometry_application_reference') end)
 )%22)%0A    ### end 

Fix index for title without geo abr