"""add pdf_report_url to interview_reports

Revision ID: 86cfa6ee73af
Revises: 9c60c15f7846
Create Date: 2025-09-07 18:20:54.026422

"""

from collections.abc import Sequence

import sqlalchemy as sa
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "86cfa6ee73af"
down_revision: str | Sequence[str] | None = "9c60c15f7846"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "interview_reports",
        sa.Column(
            "pdf_report_url",
            sqlmodel.sql.sqltypes.AutoString(length=500),
            nullable=True,
        ),
    )
    op.drop_index(
        op.f("idx_interview_reports_communication"), table_name="interview_reports"
    )
    op.drop_index(
        op.f("idx_interview_reports_overall_score"), table_name="interview_reports"
    )
    op.drop_index(
        op.f("idx_interview_reports_recommendation"), table_name="interview_reports"
    )
    op.drop_index(
        op.f("idx_interview_reports_session_id"), table_name="interview_reports"
    )
    op.drop_index(
        op.f("idx_interview_reports_technical_skills"), table_name="interview_reports"
    )
    op.alter_column(
        "interview_sessions",
        "transcript",
        existing_type=sa.TEXT(),
        type_=sqlmodel.sql.sqltypes.AutoString(),
        existing_nullable=True,
    )
    op.alter_column(
        "interview_sessions",
        "ai_feedback",
        existing_type=sa.TEXT(),
        type_=sqlmodel.sql.sqltypes.AutoString(),
        existing_nullable=True,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "interview_sessions",
        "ai_feedback",
        existing_type=sqlmodel.sql.sqltypes.AutoString(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.alter_column(
        "interview_sessions",
        "transcript",
        existing_type=sqlmodel.sql.sqltypes.AutoString(),
        type_=sa.TEXT(),
        existing_nullable=True,
    )
    op.create_index(
        op.f("idx_interview_reports_technical_skills"),
        "interview_reports",
        [sa.literal_column("technical_skills_score DESC")],
        unique=False,
    )
    op.create_index(
        op.f("idx_interview_reports_session_id"),
        "interview_reports",
        ["interview_session_id"],
        unique=False,
    )
    op.create_index(
        op.f("idx_interview_reports_recommendation"),
        "interview_reports",
        ["recommendation"],
        unique=False,
    )
    op.create_index(
        op.f("idx_interview_reports_overall_score"),
        "interview_reports",
        [sa.literal_column("overall_score DESC")],
        unique=False,
    )
    op.create_index(
        op.f("idx_interview_reports_communication"),
        "interview_reports",
        [sa.literal_column("communication_score DESC")],
        unique=False,
    )
    op.drop_column("interview_reports", "pdf_report_url")
    # ### end Alembic commands ###
