-- Migration: Add timeout_at to command_queue -- Date: 2026-10-12 -- Purpose: Pipeline Worker timeout / self-healing (Phase 1 of pipeline worker refactor) -- consume() stamps timeout_at = NOW() + timeout_seconds; the worker monitor -- task and the external command_monitor reset rows whose timeout_at has passed. ALTER TABLE command_queue ADD COLUMN IF NOT EXISTS timeout_at TIMESTAMP WITH TIME ZONE; COMMENT ON COLUMN command_queue.timeout_at IS 'Command timeout timestamp (set on consume, cleared on reset)'; CREATE INDEX IF NOT EXISTS idx_command_queue_timeout ON command_queue(timeout_at) WHERE status = 'processing';