"""Add unique partial index for starter deck

Revision ID: 9ea744a4f451
Revises: 5ce887128ab1
Create Date: 2026-01-28 14:09:13.928446

"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "9ea744a4f451"
down_revision: str | Sequence[str] | None = "5ce887128ab1"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        "ix_decks_user_starter_unique",
        "decks",
        ["user_id"],
        unique=True,
        postgresql_where=sa.text("is_starter = true"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        "ix_decks_user_starter_unique",
        table_name="decks",
        postgresql_where=sa.text("is_starter = true"),
    )
    # ### end Alembic commands ###
