"""Track GovCrawler to RAG export state.

Revision ID: 0010_add_rag_export_state
Revises: 0009_add_target_checkpoint
Create Date: 2026-05-07
"""
from alembic import op
import sqlalchemy as sa


revision = "0010_add_rag_export_state"
down_revision = "0009_add_target_checkpoint"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("article", sa.Column("rag_export_status", sa.String(20)))
    op.add_column("article", sa.Column("rag_export_started_at", sa.DateTime()))
    op.add_column("article", sa.Column("rag_export_finished_at", sa.DateTime()))
    op.add_column("article", sa.Column("rag_export_error", sa.Text()))
    op.add_column("article", sa.Column("rag_export_task_ids", sa.JSON()))
    op.create_index(
        "ix_article_rag_export_status",
        "article",
        ["rag_export_status"],
    )


def downgrade() -> None:
    op.drop_index("ix_article_rag_export_status", table_name="article")
    op.drop_column("article", "rag_export_task_ids")
    op.drop_column("article", "rag_export_error")
    op.drop_column("article", "rag_export_finished_at")
    op.drop_column("article", "rag_export_started_at")
    op.drop_column("article", "rag_export_status")
