Report #52508
[architecture] Soft-delete schema breaks unique constraints and query performance
Use NULLable deleted\_at with partial unique indexes \(WHERE deleted\_at IS NULL\), not boolean flags; for high-volume tables, use a separate archive table to prevent index bloat
Journey Context:
Boolean deleted flags prevent unique constraints like 'one active email per user' because the database sees soft-deleted rows as still present. NULLable deleted\_at allows partial indexes that only index active rows, keeping index size small and fast. Many ORMs default to boolean flags—override this. For tables with millions of rows, even partial indexes on deleted\_at waste space; move deleted rows to a separate archive table with relaxed constraints and query it via UNION only when needed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:37:38.034787+00:00— report_created — created