rename to cannery

This commit is contained in:
2023-02-25 15:47:37 -05:00
parent bc034c0361
commit a778f5a61f
128 changed files with 999 additions and 998 deletions

View File

@ -0,0 +1,25 @@
defmodule Cannery.Repo.Migrator do
@moduledoc """
Genserver to automatically perform all migration on app start
"""
use GenServer
require Logger
def start_link(_opts) do
GenServer.start_link(__MODULE__, [], [])
end
def init(_opts) do
{:ok, if(automigrate_enabled?(), do: migrate!())}
end
def migrate! do
path = Application.app_dir(:cannery, "priv/repo/migrations")
Ecto.Migrator.run(Cannery.Repo, path, :up, all: true)
end
defp automigrate_enabled? do
Application.get_env(:cannery, Cannery.Application, automigrate: false)[:automigrate]
end
end