"""Add unique constraint for inline shares

Revision ID: b7656826d33c
Revises: b167b3275d8e
Create Date: 2020-05-13 14:50:17.816444

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "b7656826d33c"
down_revision = "b167b3275d8e"
branch_labels = None
depends_on = None


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


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