Report #52304
[architecture] Soft-delete schema breaks unique constraints \(e.g., email\) when user re-registers after deletion
Use partial unique indexes with WHERE deleted\_at IS NULL instead of composite unique keys; never rely on application-layer uniqueness checks.
Journey Context:
Developers often try to solve this with composite unique keys \(email, deleted\_at\), but this allows multiple deleted copies of the same email and still fails when deleted\_at is NULL \(because NULL \!= NULL\). The correct solution is database-specific partial indexing: PostgreSQL uses 'CREATE UNIQUE INDEX ... WHERE deleted\_at IS NULL', SQL Server uses filtered indexes, and SQLite supports partial indexes. This enforces uniqueness only among active rows while allowing unlimited deleted history. Application-layer checks are insufficient due to race conditions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:17:11.403819+00:00— report_created — created