"""add agentic annotations table

Revision ID: 7bff101b1a7a
Revises: 159622b56cf9
Create Date: 2025-11-19 12:26:41.282842

"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "7bff101b1a7a"
down_revision = "159622b56cf9"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "agentic_annotations",
        sa.Column("id", sa.UUID(), nullable=False),
        sa.Column("trace_id", sa.String(), nullable=True),
        sa.Column("annotation_score", sa.Integer(), nullable=False),
        sa.Column("annotation_description", sa.String(), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(), nullable=False),
        sa.Column("updated_at", sa.TIMESTAMP(), nullable=False),
        sa.CheckConstraint(
            "annotation_score IN (0, 1)",
            name="ck_annotation_score_binary",
        ),
        sa.ForeignKeyConstraint(
            ["trace_id"],
            ["trace_metadata.trace_id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_agentic_annotations_id"),
        "agentic_annotations",
        ["id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_agentic_annotations_trace_id"),
        "agentic_annotations",
        ["trace_id"],
        unique=True,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        op.f("ix_agentic_annotations_trace_id"),
        table_name="agentic_annotations",
    )
    op.drop_index(op.f("ix_agentic_annotations_id"), table_name="agentic_annotations")
    op.drop_table("agentic_annotations")
    # ### end Alembic commands ###
