Move person-delete FK detach to database-level ON DELETE #684
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Follow-up flagged in the review of PR #679 (Phase 5 persons directory, #667) — Markus (architect).
The new
DELETE /api/persons/{id}works by detaching sender/receiver references in application code (@Transactional) before deleting the person, to avoid an FK-orphan 500. That's correct for the service path, but the integrity guarantee lives in Java, not the database — a delete via any other path (a future endpoint, a manualpsql, a batch job) could still orphan or 500.Suggested approach
documents.sender_idFK →ON DELETE SET NULL(a deleted sender just clears the reference), and/ordocument_receivers.person_idFK →ON DELETE CASCADE(drop the join rows).PersonService.deletePersoncan be simplified/removed.Out of scope / notes