fix: run migrator on startup
This commit is contained in:
@@ -5,6 +5,7 @@ defmodule Localiser.Application do
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
Localiser.Repo,
|
||||
Localiser.Migrator,
|
||||
{Registry, keys: :unique, name: Localiser.Registry},
|
||||
{Phoenix.PubSub, name: Localiser.PubSub},
|
||||
Localiser.Web.Endpoint,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
defmodule Localiser.Migrator do
|
||||
use GenServer
|
||||
|
||||
def start_link(args) do
|
||||
GenServer.start_link(__MODULE__, args, name: __MODULE__)
|
||||
end
|
||||
|
||||
def init(_args) do
|
||||
path = Application.app_dir(:localiserd, "priv/repo/migrations")
|
||||
Ecto.Migrator.run(Localiser.Repo, path, :up, all: true)
|
||||
{:ok, %{}}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user