fix: complete removal of leftover role_level column (#1527)#1530
Open
ignacionelson wants to merge 1 commit into
Open
fix: complete removal of leftover role_level column (#1527)#1530ignacionelson wants to merge 1 commit into
ignacionelson wants to merge 1 commit into
Conversation
…ions Migration 2025092004 was supposed to drop role_level and re-key the table to (role_id, permission), but the ALTER TABLE was wrapped in a try/catch that silently swallowed failures. On upgrades from older versions (e.g. r14xx), the column and old unique key survive, causing: SQLSTATE[HY000]: General error: 1364 Field 'role_level' doesn't have a default value This adds an idempotent upgrade that checks for the column, deduplicates rows, drops old indexes, removes role_level, and ensures the correct unique key on (role_id, permission). Fixes projectsend#1527
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
2025101501that completes the removal of therole_levelcolumn fromtbl_role_permissions2025092004was supposed to drop this column, but theALTER TABLEwas wrapped in atry/catchthat silently swallowed failuresNOT NULLwithout a default, and the old unique key stays on(role_level, permission)instead of(role_id, permission)This causes:
when saving role permissions, since the application code only inserts
(role_id, permission, granted).What the upgrade does
role_levelcolumn still exists (idempotent — no-op if already removed)role_idcolumn exists and migrates data if neededrole_idis NULL(role_id, permission)rowsrole_levelrole_levelcolumn (re-throws on failure — this must succeed)(role_id, permission)Test plan
role_level: column is dropped, permissions workFixes #1527