~ihabunek/triglav

ref: 1a8ba58407fc58b933347c9bec5bcb4358191cbb triglav/lib/triglav/release.ex -rw-r--r-- 955 bytes
1a8ba584Ivan Habunek Use derived data for route detail view 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
defmodule Triglav.Release do
  @app :triglav

  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

  def import_zet(opts \\ []) do
    load_app()
    Mix.Tasks.Triglav.ImportZet.run(opts)
  end

  def osmosis_init() do
    load_app()
    Mix.Tasks.Triglav.OsmosisInit.run([])
  end

  def osmosis_load(pbf_path) do
    load_app()
    Mix.Tasks.Triglav.OsmosisLoad.run([pbf_path])
  end

  def osmosis_update() do
    load_app()
    Mix.Tasks.Triglav.OsmosisUpdate.run([])
  end

  def validate_routes do
    load_app()
    Mix.Tasks.Triglav.ValidateRoutes.run([])
  end

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

  defp load_app do
    Application.load(@app)
  end
end