Go to file
Fabian @ Blax Software 190c500d86 fix: align schema with HasUuids design + add reusable MorphAliasRegistry
The package's models (Permission, PermissionMember, Role, RoleMember,
Access, RequiredAccess) all use HasUuids but the published create
migrations created bigint columns. Every insert blew up in production
with 'Incorrect integer value: <uuid> for column id'.

Migrations
- create_blax_role_tables: uuid PK + uuidMorphs throughout
- create_blax_access_table: uuid PK + uuidMorphs/nullableUuidMorphs
- create_required_accesses_table: uuid PK + uuidMorphs
- add_source_to_accesses_table: nullableUuidMorphs

Two upgrade migrations convert in-place for hosts with existing data:
- 2026_04_29_000001 fixes required_accesses (idempotent, drops empty
  table or leaves correct schema alone)
- 2026_04_29_000002 fixes the rest (permissions, permission_members,
  permission_usages, roles, role_members, accesses) by adding staging
  uuid columns, generating UUIDs per row, propagating into FK columns,
  swapping in place, and rebuilding FK constraints. MySQL-only;
  SQLite hosts get the correct schema directly from the create
  migration. Idempotent (no-op on already-uuid schemas).

Models / traits
- Permission/PermissionMember restored to HasUuids (the schema fix
  removes the conflict with the bigint id columns)
- RoleMember constructor was looking up the wrong config key
  (role_members instead of role_member) and falling through to a
  non-pluralised parent::getTable()
- HasRoles/HasPermissions now treat UUID strings as ids; previously
  they were misinterpreted as role/permission names, so passing
  $role->id to assignRole created a new role keyed by the UUID
- extendOrAddRoleByOrigin no longer json_encodes the context array;
  the RoleMember 'context' cast handles it (it was double-encoding)

Reusable infrastructure
- MorphAliasRegistry: central alias <-> FQCN map with custom
  per-class alias and name resolvers. Auto-bound as a singleton in
  RolesServiceProvider; hosts register their own (alias, FQCN) pairs
- HasRequiredAccess gained addRequiredAccessByAlias /
  removeRequiredAccessByAlias / requiredAccessAdminPayload helpers
- RequiredAccess::toAdminArray serializes a link via the registry

Test fixtures
- Manual DB::table()->insert() pivot rows now pass an explicit id
  since pivot inserts don't go through HasUuids
- All 162 package tests passing

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 11:48:51 +02:00
.vscode A traits, I fields 2025-06-16 09:49:36 +02:00
config feat: add HasRequiredAccess trait for OR-combined entity dependencies 2026-04-27 12:35:09 +02:00
database/migrations fix: align schema with HasUuids design + add reusable MorphAliasRegistry 2026-04-29 11:48:51 +02:00
src fix: align schema with HasUuids design + add reusable MorphAliasRegistry 2026-04-29 11:48:51 +02:00
tests/Unit fix: align schema with HasUuids design + add reusable MorphAliasRegistry 2026-04-29 11:48:51 +02:00
.dockerignore I has permissions trait 2025-07-10 10:29:53 +02:00
.gitattributes A traits, I fields 2025-06-16 09:49:36 +02:00
.gitignore I context logic & tests 2026-03-31 18:56:47 +02:00
composer.json feat: add Laravel 13 support 2026-04-16 07:49:51 +02:00
phpunit.xml A ccess 2026-02-24 12:07:32 +01:00
pint.json A more files & structure 2025-06-15 11:56:28 +02:00