Role assignment schema for PhoenixKit authorization system.
This schema represents the many-to-many relationship between users and roles, with additional metadata about when and by whom the role was assigned.
Fields
user_uuid: UUID reference to the user who has the rolerole_uuid: UUID reference to the role being assignedassigned_by_uuid: UUID reference to the user who assigned this role (can be nil for system assignments)assigned_at: Timestamp when the role was assigned
Features
- Tracks role assignment history
- Supports bulk role management
- Audit trail for security purposes
- Direct deletion for role removal
Summary
Functions
A role assignment changeset for creating role assignments.
Types
@type t() :: %PhoenixKit.Users.RoleAssignment{ __meta__: term(), assigned_at: DateTime.t(), assigned_by_user: term(), assigned_by_uuid: UUIDv7.t() | nil, inserted_at: DateTime.t(), role: term(), role_uuid: UUIDv7.t() | nil, user: term(), user_uuid: UUIDv7.t() | nil, uuid: UUIDv7.t() | nil }
Functions
A role assignment changeset for creating role assignments.
Parameters
role_assignment: The role assignment struct to modifyattrs: Attributes to update
Examples
iex> changeset(%RoleAssignment{}, %{user_uuid: "...", role_uuid: "..."})
%Ecto.Changeset{valid?: true}
iex> changeset(%RoleAssignment{}, %{})
%Ecto.Changeset{valid?: false}