-- Migration 028: Add unique index for session checkpoint upserts (CF-572)
-- Ensures at most ONE checkpoint row per session+note_type.
-- Normal session_note_add calls (recovered_from IS NULL) are unaffected.

CREATE UNIQUE INDEX IF NOT EXISTS uq_session_checkpoint
  ON session_notes (session_id, note_type)
  WHERE recovered_from = 'checkpoint';
