"""Add name column to sessions table.

The ``name`` column was added to the ``SessionModel`` ORM class but the
corresponding Alembic migration was missing, causing ``session create``
to fail with ``OperationalError: table sessions has no column named name``
when the database was created via Alembic migrations (as opposed to
``Base.metadata.create_all()`` used by the template DB).

Revision ID: m9_001_session_name_column
Revises: m6_006_estimation_report_json
Create Date: 2026-04-04 12:00:00

"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

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


def upgrade() -> None:
    """Add ``name`` column to ``sessions`` table."""
    op.add_column(
        "sessions",
        sa.Column("name", sa.String(255), nullable=True),
    )


def downgrade() -> None:
    """Remove ``name`` column from ``sessions`` table."""
    op.drop_column("sessions", "name")
