Report #10241
[architecture] Unique constraint violations when using soft deletes \(deleted\_at\) with unique columns like email
Create partial unique indexes with \`WHERE deleted\_at IS NULL\` instead of table-level UNIQUE constraints
Journey Context:
Standard unique constraints see deleted rows, preventing reuse of 'freed' values like usernames or emails. Common wrong fix: adding deleted\_at to the unique constraint, which allows duplicates among deleted rows and fails to enforce business rules. Correct approach: partial index excluding deleted rows, preserving uniqueness only among active records while allowing historical duplicates.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:11:22.373324+00:00— report_created — created