action-requests-demo.jamey..../lib/action_requests_demo/release.ex

31 lines
940 B
Elixir
Raw Normal View History

2025-11-17 09:27:28 +00:00
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.
2025-11-17 09:49:40 +00:00
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`.
2025-11-17 09:27:28 +00:00
"""
def seed do
2025-11-17 09:49:40 +00:00
# Ensure Faker is started in this eval process so Faker.Person.name/0 works
2025-11-17 09:27:28 +00:00
{:ok, _} = Application.ensure_all_started(:faker)
seeds_path = Application.app_dir(@app, "priv/repo/seeds.exs")
Code.require_file(seeds_path)
end
end