cannery/lib/cannery/release.ex

27 lines
586 B
Elixir

defmodule Cannery.Release do
@moduledoc """
Contains tasks that will be included in the Mix release
Ex. `load_app/0` can be invoked with `mix load_app`.
"""
@app :cannery
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
defp load_app do
Application.load(@app)
end
def migrate do
load_app()
for repo <- Application.fetch_env!(@app, :ecto_repos) do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
end