Report #75869
[architecture] Soft-delete breaks unique constraints \(e.g., email uniqueness\) preventing re-creation of deleted records
Replace standard UNIQUE constraints with partial unique indexes that exclude soft-deleted rows \(e.g., CREATE UNIQUE INDEX idx\_email ON users\(email\) WHERE deleted\_at IS NULL\).
Journey Context:
Standard unique constraints see soft-deleted rows, so you cannot re-insert a deleted user's email. A common mistake is adding deleted\_at to the constraint columns, which fails because NULL \!= NULL in SQL uniqueness checks and complicates queries. Partial indexes are the cleanest, performant solution: they enforce uniqueness only on active rows, are query-planner friendly, and avoid schema complexity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:56:39.374174+00:00— report_created — created