fix: run migrator on startup

This commit is contained in:
2026-05-12 15:12:57 +02:00
parent 663a070ab9
commit 43f42f65d8
2 changed files with 14 additions and 0 deletions
+1
View File
@@ -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,
+13
View File
@@ -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