"""Add parsing statuses to ResumeStatus enum

Revision ID: dba37152ae9a
Revises: 4e19b8fe4a88
Create Date: 2025-09-02 14:45:30.749202

"""

from collections.abc import Sequence

import sqlalchemy as sa
import sqlmodel
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "dba37152ae9a"
down_revision: str | Sequence[str] | None = "4e19b8fe4a88"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # Add new ENUM values to ResumeStatus
    op.execute("ALTER TYPE resumestatus ADD VALUE IF NOT EXISTS 'PARSING'")
    op.execute("ALTER TYPE resumestatus ADD VALUE IF NOT EXISTS 'PARSED'")
    op.execute("ALTER TYPE resumestatus ADD VALUE IF NOT EXISTS 'PARSE_FAILED'")

    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("resume", sa.Column("parsed_data", sa.JSON(), nullable=True))
    op.add_column(
        "resume",
        sa.Column("parse_error", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("resume", "parse_error")
    op.drop_column("resume", "parsed_data")
    # ### end Alembic commands ###

    # Note: Cannot remove ENUM values in PostgreSQL, they are permanent once added
    # If needed, would require recreating the ENUM type
