"""Unique constraint on private votes

Revision ID: ba823205d87f
Revises: f9ba798f4042
Create Date: 2020-04-24 15:31:32.065152

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "ba823205d87f"
down_revision = "f9ba798f4042"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        "ix_unique_private_vote_reference",
        "reference",
        ["poll_id", "user_id", "message_id"],
        unique=True,
        postgresql_where=sa.text("type = 'private_vote'"),
    )
    # ### end Alembic commands ###


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