Report #11740
[architecture] Soft-delete conflicts with unique database constraints
Use partial unique indexes that exclude soft-deleted rows \(e.g., WHERE deleted\_at IS NULL\) or compound unique indexes on \(column, deleted\_at\) allowing only one NULL.
Journey Context:
Simply adding deleted\_at to a unique constraint prevents restoring records because historical deleted entries conflict with new inserts. Partial indexes enforce uniqueness only on active rows, but require database-specific syntax \(PostgreSQL partial indexes, SQL Server filtered indexes\). MySQL lacks native filtered indexes, requiring workarounds like making deleted\_at part of the key with a sentinel value for active records.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:13:12.226487+00:00— report_created — created