fix(seeds): use :update_internal for system user admin-role
Some checks failed
continuous-integration/drone/push Build is failing

:update is blocked for system-actor user; use :update_internal in bootstrap.
This commit is contained in:
Moritz 2026-01-27 17:37:43 +01:00 committed by moritz
parent cbcb93418e
commit 92ee7fcc63

View file

@ -268,9 +268,9 @@ case Accounts.User
|> Ash.read_one(domain: Mv.Accounts, authorize?: false) do |> Ash.read_one(domain: Mv.Accounts, authorize?: false) do
{:ok, existing_system_user} when not is_nil(existing_system_user) -> {:ok, existing_system_user} when not is_nil(existing_system_user) ->
# System user already exists - ensure it has admin role # System user already exists - ensure it has admin role
# Use authorize?: false for bootstrap # Use authorize?: false for bootstrap; :update_internal bypasses system-user modification block
existing_system_user existing_system_user
|> Ash.Changeset.for_update(:update, %{}) |> Ash.Changeset.for_update(:update_internal, %{})
|> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove) |> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove)
|> Ash.update!(authorize?: false) |> Ash.update!(authorize?: false)
@ -287,7 +287,7 @@ case Accounts.User
upsert_identity: :unique_email, upsert_identity: :unique_email,
authorize?: false authorize?: false
) )
|> Ash.Changeset.for_update(:update, %{}) |> Ash.Changeset.for_update(:update_internal, %{})
|> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove) |> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove)
|> Ash.update!(authorize?: false) |> Ash.update!(authorize?: false)