"""Add unique constraint for priority

Revision ID: 21574a420c32
Revises: 58d240646830
Create Date: 2019-11-28 18:33:44.521989

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "21574a420c32"
down_revision = "58d240646830"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        "ix_unique_priority_vote",
        "vote",
        ["user_id", "poll_id", "priority"],
        unique=True,
        postgresql_where=sa.text("poll_type = 'priority'"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_unique_priority_vote", table_name="vote")
    # ### end Alembic commands ###
