1
0
mirror of https://github.com/algora-io/tv.git synced 2025-01-25 01:32:39 +02:00
algora-tv/lib/algora/release.ex
2024-02-29 22:31:42 +03:00

29 lines
590 B
Elixir

defmodule Algora.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :algora
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