Files
HaimKortovich 75d069b91d
All checks were successful
Build and Publish / build-release (push) Successful in 1m30s
just init database
2026-04-16 11:21:48 -05:00

38 lines
860 B
Elixir

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()
init_event_store()
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.ensure_all_started(:ssl)
Application.ensure_all_started(:postgrex)
Application.ensure_loaded(@app)
end
def init_event_store do
config = CustomerService.EventStore.config()
:ok = EventStore.Tasks.Init.exec(config, [])
end
end