cat-bookmarker/deps/phoenix/priv/templates/phx.gen.release/release.ex

29 lines
612 B
Elixir
Raw Normal View History

2024-03-10 18:52:04 +00:00
defmodule <%= app_namespace %>.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :<%= otp_app %>
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