PhoenixでDBにseed
これが正解みたいな方法は無いのでは。多分。
# priv/repo/seeds.ex alias MyApp.User alias MyApp.Repo Faker.start Enum.each 1..99, fn i -> params = %{name: Faker.Name.name, email: Faker.Internet.email} User.changeset(%User{}, params) |> Repo.insert! end
モジュールで包むかはお好みで。
$ mix run priv/repo/seeds.ex
テスト用にやりたいときはMIX_ENV=test
つける。