diff --git a/lib/action_requests_demo/release.ex b/lib/action_requests_demo/release.ex new file mode 100644 index 0000000..7a68a66 --- /dev/null +++ b/lib/action_requests_demo/release.ex @@ -0,0 +1,28 @@ +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. + + Ensures the main application and Faker are started, then evaluates + the standard `priv/repo/seeds.exs` file. + """ + def seed do + # Make sure the application (and its supervision tree) is running + {:ok, _} = Application.ensure_all_started(@app) + {:ok, _} = Application.ensure_all_started(:faker) + + seeds_path = Application.app_dir(@app, "priv/repo/seeds.exs") + Code.require_file(seeds_path) + end +end + +