Report #86460
[architecture] Soft-delete pattern breaks unique constraints \(e.g., cannot reuse email after user deletion\)
Use partial unique indexes that exclude soft-deleted rows: CREATE UNIQUE INDEX idx\_users\_email ON users\(email\) WHERE deleted\_at IS NULL;
Journey Context:
Standard unique indexes block re-registration with the same email because the soft-deleted row still exists. Common wrong fixes include: making email nullable \(breaks NOT NULL requirements\), adding deleted\_at to the unique constraint \(allows only one deleted account per email, then breaks\). Partial indexes are the clean SQL solution—supported by PostgreSQL, MySQL 8.0.13\+, SQLite 3.8.0\+—allowing true uniqueness among active records while ignoring deleted ones.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:42:35.434815+00:00— report_created — created