Fix: Make team_foreign_key nullable in pivot tables (#2888)
#2894
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.
Github Issue: #2888
The
team_foreign_keycolumn was nullable in therolestable but not inmodel_has_permissions&model_has_rolespivot tables. This caused errors when assigning global roles (withteam_foreign_key = null) to users, as the pivot tables rejected NULL values.Added test coverage to verify the fix and prevent regressions:
it_can_assign_global_role_with_null_team_foreign_key_to_user()- Core scenario from issueit_can_assign_global_role_to_multiple_users_across_different_teams()- Unique constraint with NULLit_can_query_global_roles_correctly_across_different_teams()- Query logic with NULLit_allows_direct_database_insertion_with_null_team_foreign_key()- Direct schema testit_handles_mixed_team_and_global_roles_correctly()- Edge casesit_allows_direct_database_insertion_with_null_team_foreign_key_for_permissions()- Permissions table