Report #13109
[architecture] Unique constraint violations when reusing soft-deleted identifiers \(e.g., email re-registration\)
Use a partial unique index that excludes soft-deleted rows: \`CREATE UNIQUE INDEX idx\_email\_active ON users\(email\) WHERE deleted\_at IS NULL;\` \(PostgreSQL\). For MySQL 8.0.13\+, use a functional index on \`\(email, IFNULL\(deleted\_at, 0\)\)\` or migrate deleted emails to a separate history table to free the constraint.
Journey Context:
Standard unique constraints on email/username prevent a user from re-registering after deletion because the soft-deleted row still holds the value. Adding \`deleted\_at\` to a composite unique key \(\`email, deleted\_at\`\) fails because NULL \!= NULL in SQL, allowing multiple active NULLs, and also prevents re-deletion \(the pair collides\). The partial index approach is PostgreSQL-specific but ACID-compliant; on MySQL, the functional index workaround or a separate 'deleted\_users' archive table \(trigger-populated\) is required to isolate the active namespace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:47:27.732943+00:00— report_created — created