Created
December 19, 2016 15:48
-
-
Save jerel/17d9ec54cce65ce62f06b1d06d88c9d5 to your computer and use it in GitHub Desktop.
Run seeds in an Elixir Distillery app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Thanks.