-- Migration 027: Add transcript storage for session recovery -- Purpose: Store full JSONL transcripts from Claude Code for session recovery (CF-580) -- Context: Replace daemon-based notes syncing with direct transcript ingestion -- Add columns to sessions table for transcript storage ALTER TABLE sessions ADD COLUMN IF NOT EXISTS transcript_jsonl TEXT, ADD COLUMN IF NOT EXISTS transcript_ingested_at TIMESTAMPTZ, ADD COLUMN IF NOT EXISTS transcript_file_path TEXT; -- Index for efficient querying of ingested sessions CREATE INDEX IF NOT EXISTS idx_sessions_transcript_ingested ON sessions(transcript_ingested_at) WHERE transcript_ingested_at IS NOT NULL; -- Index for finding sessions by transcript file path (for recovery) CREATE INDEX IF NOT EXISTS idx_sessions_transcript_file_path ON sessions(transcript_file_path) WHERE transcript_file_path IS NOT NULL; -- Comments for documentation COMMENT ON COLUMN sessions.transcript_jsonl IS 'Full JSONL transcript from Claude Code for complete session audit trail'; COMMENT ON COLUMN sessions.transcript_ingested_at IS 'Timestamp when transcript was ingested into database'; COMMENT ON COLUMN sessions.transcript_file_path IS 'Path to source JSONL file for debugging and recovery';