-- Migration 026: Add recovery metadata to session_notes
-- Purpose: Track which notes were recovered vs normally saved for CF-572 analytics

ALTER TABLE session_notes
  ADD COLUMN IF NOT EXISTS recovered_from TEXT,
  ADD COLUMN IF NOT EXISTS recovered_at TIMESTAMP WITH TIME ZONE;

CREATE INDEX IF NOT EXISTS idx_session_notes_recovered
  ON session_notes(recovered_from)
  WHERE recovered_from IS NOT NULL;

COMMENT ON COLUMN session_notes.recovered_from
  IS 'Source of recovery: "recovered" (daemon/orphan), "manual" (MCP tool), NULL (normal save)';

COMMENT ON COLUMN session_notes.recovered_at
  IS 'Timestamp when note was recovered (NULL for normal saves)';
