"""add pattern taxonomy fields

Revision ID: 006
Revises: 005
Create Date: 2025-07-05

"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "006"
down_revision: str | None = "005"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # Add pattern_type and display_order to patterns table
    op.add_column("patterns", sa.Column("pattern_type", sa.String(50), nullable=True))
    op.add_column("patterns", sa.Column("display_order", sa.Integer(), nullable=True))

    # Add is_optimal to question_patterns junction table
    op.add_column(
        "question_patterns",
        sa.Column("is_optimal", sa.Boolean(), server_default="false", nullable=False),
    )


def downgrade() -> None:
    op.drop_column("question_patterns", "is_optimal")
    op.drop_column("patterns", "display_order")
    op.drop_column("patterns", "pattern_type")
