Report #23022
[architecture] Soft delete breaks unique constraints on fields like email
Use partial unique indexes that exclude soft-deleted rows \(e.g., \`WHERE deleted\_at IS NULL\` in PostgreSQL\), or include the deletion timestamp in the unique constraint to allow multiple deleted records but only one active.
Journey Context:
Standard unique indexes prevent reusing an email even if the account is soft-deleted, blocking legitimate re-registration. Partial indexes solve this by only enforcing uniqueness on active rows. Alternative approaches like moving deleted data to a separate history table break foreign key constraints or require complex transaction management. The partial index approach maintains referential integrity while allowing the business logic of 'deleted emails can be reused' without application-level locking or expensive existence checks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T17:03:08.576174+00:00— report_created — created