Deleting a session with linked session_worktrees or agent_sessions rows threw a FK violation (500 on DELETE /api/sessions/:id). Both FKs now ON DELETE CASCADE. Idempotent migration: drops the old constraint and re-adds with CASCADE only if confdeltype != 'c'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>