action-requests-demo.jamey..../lib/action_requests_demo/release.ex
James Greenwood 50e9a9de3f
All checks were successful
build / build (push) Successful in 27s
fix
2025-11-17 09:49:40 +00:00

31 lines
940 B
Elixir

defmodule ActionRequestsDemo.Release do
@moduledoc """
Helpers for running tasks in a release environment.
This module is intended for commands invoked via:
bin/action_requests_demo eval "ActionRequestsDemo.Release.seed()"
"""
@app :action_requests_demo
@doc """
Run the database seeds script inside a release.
This is designed to be run against a *running* release (e.g. via
`bin/action_requests_demo eval ...` inside your Docker container),
so it does **not** try to start the application or endpoint again.
It only ensures Faker is running, then evaluates the standard
`priv/repo/seeds.exs` file, which uses `ActionRequestsDemo.Repo`.
"""
def seed do
# Ensure Faker is started in this eval process so Faker.Person.name/0 works
{:ok, _} = Application.ensure_all_started(:faker)
seeds_path = Application.app_dir(@app, "priv/repo/seeds.exs")
Code.require_file(seeds_path)
end
end