mitgliederverwaltung/priv/repo/seeds.exs
Rafael Epplée 172d254e41
All checks were successful
continuous-integration/drone/push Build is passing
Add seed script for admin user
2025-08-04 15:12:38 +02:00

49 lines
1.2 KiB
Elixir

# Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
alias Mv.Membership
alias Mv.Accounts
for attrs <- [
%{
name: "String Field",
value_type: :string,
description: "Example for a field of type string",
immutable: true,
required: true
},
%{
name: "Date Field",
value_type: :date,
description: "Example for a field of type date",
immutable: true,
required: true
},
%{
name: "Boolean Field",
value_type: :boolean,
description: "Example for a field of type boolean",
immutable: true,
required: true
},
%{
name: "Email Field",
value_type: :email,
description: "Example for a field of type email",
immutable: true,
required: true
}
] do
Membership.create_property_type!(
attrs,
upsert?: true,
upsert_identity: :unique_name
)
end
# Create admin user for testing
Accounts.create_user!(%{email: "admin@mv.local"}, upsert?: true, upsert_identity: :unique_email)
|> Ash.Changeset.for_update(:admin_set_password, %{password: "testpassword"})
|> Ash.update!()