"""Add session_type and title columns to ai_sessions for unified sessions.

Revision ID: 066
Revises: 065
"""
from alembic import op
import sqlalchemy as sa


revision = "066"
down_revision = "065"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "ai_sessions",
        sa.Column(
            "session_type",
            sa.String(10),
            nullable=False,
            server_default="guided",
            comment="Session type: guided (FlowPilot) or chat (assistant)",
        ),
    )
    op.add_column(
        "ai_sessions",
        sa.Column(
            "title",
            sa.String(255),
            nullable=True,
            comment="Display title for chat sessions; guided sessions use problem_summary",
        ),
    )
    op.create_index("ix_ai_sessions_session_type", "ai_sessions", ["session_type"])


def downgrade() -> None:
    op.drop_index("ix_ai_sessions_session_type", table_name="ai_sessions")
    op.drop_column("ai_sessions", "title")
    op.drop_column("ai_sessions", "session_type")
