Add release-specific ecto logic
See https://hexdocs.pm/phoenix/releases.html for details
This commit is contained in:
parent
1a9fe301d0
commit
d71a1f1261
1 changed files with 24 additions and 0 deletions
24
lib/recycledcloud/release.ex
Normal file
24
lib/recycledcloud/release.ex
Normal file
|
@ -0,0 +1,24 @@
|
|||
defmodule RecycledCloud.Release do
|
||||
@app :recycledcloud
|
||||
|
||||
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
|
Loading…
Reference in a new issue