"""curated_list_uniq_index Revision ID: 36228e2dcf85 Revises: c237ce8bd100 Create Date: 2018-08-06 10:27:19.821317 """ # revision identifiers, used by Alembic. revision = '36228e2dcf85' down_revision = 'c237ce8bd100' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_constraint('curated_list_item_uniq_idx', 'curated_list_items', type_='unique') op.execute(""" create unique index curated_list_item_unique_in_list_idx on curated_list_items ( list_id, coalesce(track_scid, -1), coalesce(video_ytid, ''), coalesce(track_spyid, '') ) """) ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_unique_constraint('curated_list_item_uniq_idx', 'curated_list_items', ['list_id', 'track_scid', 'video_ytid', 'track_spyid']) ### end Alembic commands ###