Proper way of creating Phoenix umbrella app using mix phx.new?

Using Windows 10.

I started new phoenix umbrella app using

mix phx.new myapp --umbrella

then created new ftp app in apps folder using

cd ./myapp/apps/
mix phx.new ftp --module FTP

But every time Im trying to call mix test I get

** (RuntimeError) could not lookup Ecto repo FTP.Repo because it was not started or it does not exist

Tried mix test from both umbrella root folder and from apps\ftp, results are all the same.

Tried to google around - found nothing reasonable.

Output from mix phx

Phoenix v1.5.5
Productive. Reliable. Fast.
A productive web framework that does not compromise speed or maintainability.

Available tasks:

mix phx.digest       # Digests and compresses static files
mix phx.digest.clean # Removes old versions of static assets.
mix phx.gen.cert     # Generates a self-signed certificate for HTTPS testing
mix phx.gen.channel  # Generates a Phoenix channel
mix phx.gen.context  # Generates a context with functions around an Ecto schema
mix phx.gen.embedded # Generates an embedded Ecto schema file
mix phx.gen.html     # Generates controller, views, and context for an HTML resource
mix phx.gen.json     # Generates controller, views, and context for a JSON resource
mix phx.gen.live     # Generates LiveView, templates, and context for a resource
mix phx.gen.presence # Generates a Presence tracker
mix phx.gen.schema   # Generates an Ecto schema and migration file
mix phx.gen.secret   # Generates a secret
mix phx.new          # Creates a new Phoenix v1.5.5 application
mix phx.new.ecto     # Creates a new Ecto project within an umbrella project
mix phx.new.web      # Creates a new Phoenix web project within an umbrella project
mix phx.routes       # Prints all routes
mix phx.server       # Starts applications and their servers

Output from elixir -v

Erlang/OTP 21 [erts-10.3] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

Elixir 1.9.4 (compiled with Erlang/OTP 20)

Output from mix in umbrella root folder

...
[warn] no configuration found for otp_app :ftp and module FTPWeb.Endpoint
...

Output from mix ecto.reset from apps\ftp folder

mix ecto.reset
warning: could not find Ecto repos in any of the apps: [:ftp].

You can avoid this warning by passing the -r flag or by setting the
repositories managed by those applications in your config/config.exs:

    config :ftp, ecto_repos: [...]

warning: could not find Ecto repos in any of the apps: [:ftp].

You can avoid this warning by passing the -r flag or by setting the
repositories managed by those applications in your config/config.exs:

    config :ftp, ecto_repos: [...]

warning: could not find Ecto repos in any of the apps: [:ftp].

You can avoid this warning by passing the -r flag or by setting the
repositories managed by those applications in your config/config.exs:

    config :ftp, ecto_repos: [...]

Generated ftp app

mix test in Elixir umbrella app works as expected.

Does the FTP app need a repo? If not then there is a --no-ecto flag

mix phx.new ftp --no-ecto --module FTP

There will be other apps with ecto usage, so I need to resolve this issue anyway.

When extending an existing umbrella with a new Phoenix child app, you should use mix pix.new.web if there is no need for Ecto content. This includes when you’re relying upon an existing Ecto.Repo that’s already present in the umbrella. There’s also one for generating an Ecto child app, mix phx.new.ecto.

https://hexdocs.pm/phx_new/Mix.Tasks.Phx.New.Web.html

2 Likes

Oh, yeah, I missed a point of how phoenix project strucutre works.
So I need both ftp and ftp_web apps.

The first one, if it doesn’t use Ecto, can just be totally standard mix new ... [--sup] as appropriate.

1 Like