exmr/lib/exmr/release.ex
Vladimir Rubin 8f3caa2e1a
Some checks failed
Checks / check (push) Failing after 3m1s
ci(docker): add docker files
2024-11-28 01:21:27 +02:00

28 lines
586 B
Elixir

defmodule Exmr.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :exmr
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
defp repos do
Application.fetch_env!(@app, :ecto_repos)
end
defp load_app do
Application.load(@app)
end
end