Report #45518
[architecture] Soft-delete breaks foreign key constraints and unique indexes in SQL
Use partial unique indexes on \(col, deleted\_at\) WHERE deleted\_at IS NULL, or move deleted rows to an archive table with deferred constraints
Journey Context:
Teams often add deleted\_at and drop FKs, losing referential integrity. Partial indexes allow unique constraints on active rows only \(NULL \!= NULL in SQL\). Archive tables preserve FKs via triggers or app logic but require transaction coordination. Avoid boolean is\_deleted with unique constraints as it prevents re-creating deleted items.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:52:34.673848+00:00— report_created — created