Skip to content

Instantly share code, notes, and snippets.

@MicrexIT
Created July 14, 2021 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MicrexIT/4925f01ac715c11bffc5bbf4f83ca848 to your computer and use it in GitHub Desktop.
Save MicrexIT/4925f01ac715c11bffc5bbf4f83ca848 to your computer and use it in GitHub Desktop.
Elixir Phoenix release Deployment
defmodule MyApp.Release do
@app :my_app
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment