summaryrefslogtreecommitdiff
path: root/lib/chessh/release.ex
blob: 82f180764c85163c3541d723fcd50261d0265185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
defmodule Chessh.Release do
  @app :chessh

  def migrate do
    for repo <- repos() do
      {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
    end
  end

  def rollback(repo, version) do
    {:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
  end

  defp repos do
    Application.load(@app)
    Application.fetch_env!(@app, :ecto_repos)
  end
end