Skip to content

Instantly share code, notes, and snippets.

@talentdeficit
Created November 19, 2017 02:36
Show Gist options
  • Save talentdeficit/d25a14eadd664916430eb4ee3c833b05 to your computer and use it in GitHub Desktop.
Save talentdeficit/d25a14eadd664916430eb4ee3c833b05 to your computer and use it in GitHub Desktop.
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