"""tag_positive_confirmation: operator-affirmed correct positives (#1130)

Mirror of tag_suggestion_rejection. "Keep" on a doubted positive records here so
the eval's doubts list stops resurfacing confirmed-correct images every run.

Revision ID: 0057
Revises: 0056
Create Date: 2026-06-28
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "0057"
down_revision: Union[str, None] = "0056"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "tag_positive_confirmation",
        sa.Column(
            "image_record_id", sa.Integer(),
            sa.ForeignKey("image_record.id", ondelete="CASCADE"), primary_key=True,
        ),
        sa.Column(
            "tag_id", sa.Integer(),
            sa.ForeignKey("tag.id", ondelete="CASCADE"), primary_key=True, index=True,
        ),
        sa.Column(
            "confirmed_at", sa.DateTime(timezone=True), nullable=False,
            server_default=sa.func.now(),
        ),
    )


def downgrade() -> None:
    op.drop_table("tag_positive_confirmation")
