"""update auth_code model unique

Revision ID: d4cdc9db5ed8
Revises: fafdb22e5a16
Create Date: 2026-01-23 15:45:07.166844

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import advanced_alchemy


# revision identifiers, used by Alembic.
revision: str = 'd4cdc9db5ed8'
down_revision: Union[str, Sequence[str], None] = 'fafdb22e5a16'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(op.f('uq_auth_codes_user_id'), 'auth_codes', type_='unique')
    op.create_unique_constraint('unique_user_action', 'auth_codes', ['user_id', 'action'])
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('unique_user_action', 'auth_codes', type_='unique')
    op.create_unique_constraint(op.f('uq_auth_codes_user_id'), 'auth_codes', ['user_id'], postgresql_nulls_not_distinct=False)
    # ### end Alembic commands ###
