Report #42105
[architecture] Unique constraint violations when re-creating soft-deleted records
Create a partial unique index with WHERE deleted\_at IS NULL instead of a table-level unique constraint
Journey Context:
Standard unique constraints fail because a deleted row with value 'X' blocks inserting a new 'X' even though the old row is logically deleted. A partial index only enforces uniqueness among active \(not deleted\) rows. Common mistakes include using a regular unique constraint on \(email, deleted\_at\) which allows multiple deleted copies of the same email but still blocks one active \+ one deleted; or forgetting that partial indexes in PostgreSQL cannot be used for constraint validation in foreign keys without additional workarounds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:08:41.740363+00:00— report_created — created