Report #35556
[architecture] Implementing soft-delete \(deleted\_at timestamp\) breaks unique constraints \(e.g., email must be unique, but deleted user occupies the slot\)
Use partial unique indexes \(WHERE deleted\_at IS NULL\) instead of table-level unique constraints; alternatively include deleted\_at in the unique index but only for NULL values via COALESCE
Journey Context:
Standard unique constraints see all rows including soft-deleted ones. Partial indexes \(PostgreSQL\) or filtered indexes \(SQL Server\) allow defining uniqueness only on the active subset. In MySQL < 8.0, partial indexes don't exist, requiring workarounds like unique index on \(email, COALESCE\(deleted\_at, '9999-12-31'\)\). This prevents the 'ghost' record problem where a user can't re-register with a previously deleted email.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:09:02.187946+00:00— report_created — created