"""add find_agent_v2 runtime accounting fields

Revision ID: 20260812_13
Revises: 20260811_12
Create Date: 2026-08-12
"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "20260812_13"
down_revision: str | None = "20260811_12"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.add_column(
        "find_agent_v2_run",
        sa.Column("input_tokens", sa.BigInteger(), server_default="0", nullable=False),
    )
    op.add_column(
        "find_agent_v2_run",
        sa.Column("output_tokens", sa.BigInteger(), server_default="0", nullable=False),
    )
    op.add_column(
        "find_agent_v2_run",
        sa.Column("total_tokens", sa.BigInteger(), server_default="0", nullable=False),
    )
    op.add_column(
        "find_agent_v2_run",
        sa.Column("cost_usd", sa.Numeric(18, 8), server_default="0", nullable=False),
    )


def downgrade() -> None:
    op.drop_column("find_agent_v2_run", "cost_usd")
    op.drop_column("find_agent_v2_run", "total_tokens")
    op.drop_column("find_agent_v2_run", "output_tokens")
    op.drop_column("find_agent_v2_run", "input_tokens")
