Active-only UNIQUE indexes on user.email + user.username (TIGER-274) - #323
Merged
Merged
Conversation
A plain UNIQUE spans soft-deleted rows, so soft-delete never freed an email/username — a re-signup with a deleted account's address collided on the index. Migration 0053 moves the unique index onto a generated `<col>_active = IF(deleted=0, col, NULL)`: deleted rows become NULL (multiple NULLs allowed) and free the value; live rows stay unique. Real columns + findByEmail/finders unchanged (they already filter deleted=0). The platform-wide convention for unique + soft-deletable columns (TIGER-274); proven on MariaDB 10.5 via the TigerHosting sibling migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migration
0053moves the UNIQUE indexes onuser.emailanduser.usernameonto a generatedactive-only column, so soft-delete frees the value:
Why
A plain
UNIQUE(email)spans soft-deleted (deleted=1) rows too (ARCHITECTURE §7a: "a deleted rowstill holds its unique value"), so soft-deleting a user never freed their email/username — a re-signup
with that address collided on the index (an ugly
core.api.error.general) instead of gracefullyreusing it. MySQL/MariaDB allow multiple NULLs in a unique index, so deleted rows become
NULLanddrop out, while live rows stay unique.
The real
email/usernamecolumns are untouched andTiger_Model_User::findByEmail+ the findersalready filter
deleted=0, so no application code changes.Convention (TIGER-274)
This is the platform-wide pattern for every unique + soft-deletable column. First instances shipped
alongside this:
user.email/user.username(here) and TigerHostinghosting_account.username+hosting_domain.name. TIGER-274 tracks auditing/converting the rest (org slug, CMS/registry slugs, …).Proof
Applied + verified on dev (MariaDB 10.5): a soft-deleted email/username is reusable by a new active
row; a second active duplicate is still refused.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ASauLLscjqdsNqBNsx2Typ