cannery/lib/cannery/release.ex

30 lines
629 B
Elixir
Raw Normal View History

2021-09-04 16:14:51 -04:00
defmodule Cannery.Release do
2022-01-22 21:40:29 -05:00
@moduledoc """
Contains tasks that will be included in the Mix release
Ex. `load_app/0` can be invoked with `mix load_app`.
"""
2021-09-04 16:14:51 -04:00
@app :cannery
def rollback(repo, version) do
load_app()
2023-02-04 17:28:53 -05:00
{:ok, _fun_return, _apps} =
Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
2021-09-04 16:14:51 -04:00
end
defp load_app do
Application.load(@app)
end
def migrate do
load_app()
for repo <- Application.fetch_env!(@app, :ecto_repos) do
2023-02-04 17:28:53 -05:00
{:ok, _fun_return, _apps} =
Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
2021-09-04 16:14:51 -04:00
end
end
end