add migration
All checks were successful
Build and Publish / build-release (push) Successful in 1m20s

This commit is contained in:
2026-04-15 17:01:06 -05:00
parent 8b54f20828
commit 9a0dc4942d
7 changed files with 62 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
defmodule CustomerService.Release do
@moduledoc """
Used for executing DB release tasks when run in production without Mix
installed.
"""
@app :customer_service
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
# Many platforms require SSL when connecting to the database
Application.ensure_all_started(:ssl)
Application.ensure_loaded(@app)
end
end