refactor(setup): extract DB user collision handling and normalize PostgreSQL suffixing#59094
Open
joshtrichards wants to merge 7 commits intomasterfrom
Open
refactor(setup): extract DB user collision handling and normalize PostgreSQL suffixing#59094joshtrichards wants to merge 7 commits intomasterfrom
joshtrichards wants to merge 7 commits intomasterfrom
Conversation
…() helpers Signed-off-by: Josh <josh.t.richards@gmail.com>
…ame() helper Signed-off-by: Josh <josh.t.richards@gmail.com>
PostgreSQL role collision handling now uses base, base1, base2, ... instead of base, base2, base3, ... . This aligns the suffixing scheme with the MySQL helper. Signed-off-by: Josh <josh.t.richards@gmail.com>
Right now PostgreSQL appends suffixes without enforcing a maximum identifier length. This makes enforcement explicit for robustness and symmetry with the MySQL implementation. Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Match MySQL implementation Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
8 tasks
MichaIng
reviewed
Apr 24, 2026
| $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i; | ||
| $i++; | ||
| } | ||
| $this->dbUser = $this->findAvailableUsername($connection, 'oc_' . $username); |
Member
There was a problem hiding this comment.
Shall we fix #59514 right here?
Suggested change
| $this->dbUser = $this->findAvailableUsername($connection, 'oc_' . $username); | |
| $this->dbUser = $this->findAvailableUsername($connection, $username); |
setupDatabase calls this with hardcoded oc_admin, so the prefix is doubled, resulting in a oc_oc_admin database user. Compare with PostgreSQL, where no additional oc_ is prepended.
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.
Summary
This refactor extracts the database user/role collision handling into dedicated helpers in the MySQL and PostgreSQL setup classes, reduces hidden mutation, and makes DB-specific naming constraints explicit.
What changed
userExists()helpers so existence checks no longer rely on implicit reads from$this->dbUserfindAvailableUsername()helpers to isolate collision-avoidance logic$this->dbUserassignment out of collision loops for better readability and less mutationbase,base1,base2, ... when collisions occurWhy
This makes the setup flow easier to follow, reduces duplicated loop logic, and makes future refactors in the database setup classes safer and easier to reason about.
Notes
1instead of skipping to2Related: #59092
Checklist
3. to review, feature component)stable32)AI (if applicable)