39 lines
977 B
Elixir
39 lines
977 B
Elixir
# Script for populating the database. You can run it as:
|
|
#
|
|
# mix run priv/repo/seeds.exs
|
|
#
|
|
# Inside the script, you can read and write to any of your
|
|
# repositories directly:
|
|
#
|
|
# Mv.Repo.insert!(%Mv.SomeSchema{})
|
|
#
|
|
# We recommend using the bang functions (`insert!`, `update!`
|
|
# and so on) as they will fail if something goes wrong.
|
|
|
|
alias Mv.Membership
|
|
|
|
for attrs <- [
|
|
%{
|
|
name: "Vorname",
|
|
type: "string",
|
|
description: "Vorname des Mitglieds",
|
|
immutable: true,
|
|
required: true
|
|
},
|
|
%{
|
|
name: "Email",
|
|
type: "string",
|
|
description: "Email-Adresse des Mitglieds",
|
|
immutable: true,
|
|
required: true
|
|
}
|
|
] do
|
|
# upsert?: true sorgt dafür, dass bei bestehendem Namen kein Fehler,
|
|
# sondern ein Update (hier effektiv No-Op) ausgeführt wird
|
|
{:ok, _} =
|
|
Membership.create_property_type(
|
|
attrs,
|
|
upsert?: true,
|
|
upsert_identity: :unique_name
|
|
)
|
|
end
|