Created
November 19, 2017 02:36
-
-
Save talentdeficit/d25a14eadd664916430eb4ee3c833b05 to your computer and use it in GitHub Desktop.
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 App.Repo.Migrator do | |
@moduledoc false | |
@doc false | |
use GenServer | |
def start_link() do | |
GenServer.start_link(__MODULE__, %{}, name: __MODULE__) | |
end | |
## this processes only purpose is to run migrations on init | |
def init(app, repo) do | |
migrations = Application.app_dir(app, "priv") <> "/db/migrations/" | |
_ = Ecto.Migrator.run(repo, migrations, :up, [ { :all, true } ]) | |
{ :stop, :normal, state } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment