-- Migration: Add synthesis column to pipeline.executions
-- This stores the AI-generated synthesis from Stage 4

ALTER TABLE pipeline.executions
ADD COLUMN IF NOT EXISTS synthesis JSONB DEFAULT NULL;

-- Add index for querying executions with synthesis
CREATE INDEX IF NOT EXISTS idx_executions_has_synthesis
ON pipeline.executions ((synthesis IS NOT NULL));

-- Comment
COMMENT ON COLUMN pipeline.executions.synthesis IS 'AI-generated synthesis containing narratives, action plan, and insights from Stage 4';
