-- Add partial unique index so we can upsert on (session, key) ignoring soft-deleted rows.
CREATE UNIQUE INDEX IF NOT EXISTS idx_agent_ltm_session_key
    ON agent_long_term_memory (session, key)
    WHERE deleted_at IS NULL;
