Skip to content

Conversation

@imhayatunnabi
Copy link
Contributor

Github Issue: #2888
The team_foreign_key column was nullable in the roles table but not in model_has_permissions & model_has_roles pivot tables. This caused errors when assigning global roles (with team_foreign_key = null) to users, as the pivot tables rejected NULL values.

Verified that migration files already correctly set `team_foreign_key` as nullable in both pivot tables:
- `add_teams_fields.php.stub` (lines 43 & 64)
- `create_permission_tables.php.stub` (lines 65 & 92)

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 issue
  • it_can_assign_global_role_to_multiple_users_across_different_teams() - Unique constraint with NULL
  • it_can_query_global_roles_correctly_across_different_teams() - Query logic with NULL
  • it_allows_direct_database_insertion_with_null_team_foreign_key() - Direct schema test
  • it_handles_mixed_team_and_global_roles_correctly() - Edge cases
  • it_allows_direct_database_insertion_with_null_team_foreign_key_for_permissions() - Permissions table

…s_permissions and model_has_roles tables and relevent tests to proof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant