"""add session_variables JSONB column to sessions

Revision ID: 028
Revises: 027
Create Date: 2026-02-09

Adds session_variables JSONB column for storing variable values
collected during tree navigation (e.g., hostname, ticket_number).
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision: str = '028'
down_revision: Union[str, None] = '027'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        'sessions',
        sa.Column(
            'session_variables',
            postgresql.JSONB(),
            server_default=sa.text("'{}'::jsonb"),
            nullable=False,
        )
    )


def downgrade() -> None:
    op.drop_column('sessions', 'session_variables')
