Skip to content

Instantly share code, notes, and snippets.

@Faolain
Forked from jerel/seed.ex
Created April 23, 2017 03:58
Show Gist options
  • Save Faolain/374930ef6bc75dcd61cb0ab3a9b9df32 to your computer and use it in GitHub Desktop.
Save Faolain/374930ef6bc75dcd61cb0ab3a9b9df32 to your computer and use it in GitHub Desktop.
Run seeds in an Elixir Distillery app
defmodule :release_tasks do
def seed do
:ok = Application.load(:myapp)
[:postgrex, :ecto, :logger]
|> Enum.each(&Application.ensure_all_started/1)
Myapp.Repo.start_link
path = Application.app_dir(:myapp, "priv/repo/seeds.exs")
if File.regular?(path) do
Code.require_file(path)
end
:init.stop()
end
end
# now at the command line run ./bin/myapp command release_tasks seed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment