"""Phase 2 Plan 04: Add escalation_assignee and natural_language_escalation to agents Revision ID: 003 Revises: 002 Create Date: 2026-03-23 These columns support the human escalation/handoff system: - escalation_assignee: Slack user ID of the human to DM when escalation triggers - natural_language_escalation: tenant-level flag enabling NL phrase detection Both are nullable/defaulted so existing agent rows are unaffected. """ from __future__ import annotations from typing import Sequence, Union import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "003" down_revision: Union[str, None] = "002" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # Add escalation_assignee column — nullable TEXT op.add_column( "agents", sa.Column( "escalation_assignee", sa.Text, nullable=True, comment="Slack user ID of the human to DM on escalation (e.g. U0HUMANID)", ), ) # Add natural_language_escalation column — NOT NULL with default False op.add_column( "agents", sa.Column( "natural_language_escalation", sa.Boolean, nullable=False, server_default=sa.text("FALSE"), comment="Whether natural language escalation phrases trigger handoff", ), ) def downgrade() -> None: op.drop_column("agents", "natural_language_escalation") op.drop_column("agents", "escalation_assignee")