Hello All,
How to create a schema using generator in an ecto project under umbrella project? This is what I tried:
I created an umbrella project, and within that project I created an ecto project using the following commands:
mix phx.new hello --umbrella
cd hello_umbrella
mix ecto.create
cd apps
mix phx.new.ecto hello_ecto
cd hello_ecto
mix ecto.create
Now, how do I create a schema in the hello_ecto repo using the generator phx.gen.schema?
The generator command is not available in the hello_ecto project directory. It is available in the hello_umbrella root directory and in the apps/hello_web directory. I tried issuing the schema generator command from the umbrella root directory but I get the error:
(Mix) mix phx.gen.schema can only be run inside an application directory
So I tried from the apps/hello_web directory, but the schema files are generated in the apps/hello/lib/hello and apps/hello/priv/repo/migrations directories.
How do I generate schema for the hello_ecto umbrella project under the hello_ecto directory?
Edit: I ran the following command under hello_web directory:
mix phx.gen.schema HelloSchema hello_schemas name:unique desc --context-app hello_ecto
Now I get the following error:
** (FunctionClauseError) no function clause matching in Mix.Phoenix.context_lib_path/2
The following arguments were given to Mix.Phoenix.context_lib_path/2:
1
"hello_ecto"
2
"hello_schema.ex"
Attempted function clauses (showing 1 out of 1):
def context_lib_path(ctx_app, rel_path) when is_atom(ctx_app)
lib/mix/phoenix.ex:224: Mix.Phoenix.context_lib_path/2
lib/mix/phoenix/schema.ex:53: Mix.Phoenix.Schema.new/4
lib/mix/tasks/phx.gen.schema.ex:93: Mix.Tasks.Phx.Gen.Schema.run/1
(mix) lib/mix/task.ex:301: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:75: Mix.CLI.run_task/2
Is this the right way to generate schema in the correct umbrella ecto project? Any help on how to resolve this?