Report #6159
[architecture] Soft-deleted records blocking re-registration due to unique constraints on fields like email or username
Implement partial unique indexes that exclude soft-deleted rows. In PostgreSQL: CREATE UNIQUE INDEX idx\_email ON users\(email\) WHERE deleted\_at IS NULL. For MySQL 8.0\+, use a functional index on \(email, \(deleted\_at IS NULL\)\) and enforce uniqueness on the composite, or move deleted records to an archive table to eliminate the conflict entirely.
Journey Context:
The naive soft-delete pattern adds a deleted\_at timestamp but keeps the unique constraint on the natural key \(e.g., email\). When a user deletes their account and tries to re-register, the unique constraint fails because the old soft-deleted row still holds that email. Common wrong fixes include dropping the unique constraint \(allowing duplicate live accounts\) or using a 'deleted' boolean that breaks partial indexes. Partial indexes are the cleanest in Postgres, but MySQL's lack of partial unique indexes forces functional index workarounds or schema changes. The archive-table approach trades query complexity \(needing UNION\) for strict isolation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:17:13.170047+00:00— report_created — created