Migrations in an umbrella project

Hi,
I’m trying to figure out how to use a single database app in my umbrella project to take care of everything db related.

My app structure is like this:

umbrella project
|
– Database_app
|
– Phoenix_app
|
– App_1

Now, I define a schema “Banana” in “App_1” and I would like to use it with a repo from “database app”.
Everything else works ok but I can’t figure out how to deal with migrations? In my example case they should be in “App_1”, but when I try to create a migration with “mix ecto.gen.migration create_bananas” in “App_1” I either get an error “warning: could not find repositories for application …” without anything in my config file, or “(Mix) Could not load Database_App.Repo, error: :nofile. Please configure your app accordingly or pass a repo with the -r option” when I use the following config:

config :App_1, Database_App.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "mydatabase",
  username: "username",
  password: "password",
  hostname: "localhost"
config :app_1, ecto_repos: [Database_App.Repo]

So what am I doing wrong here, how could I config this app_1 so that it would have the schema and the migrations but use the repo from another app, is it even possible?

So what am I doing wrong here, how could I config this app_1 so that it would have the schema and the migrations but use the repo from another app, is it even possible?

While it’s possible to access Repo from another app, I’d advise against that in most cases - to me it looks like breaking boundaries between the apps. I don’t know the details about your particular project, but I’d probably start with just 2 apps: App1 & Phoenix_app, and App1 would “own” the data & storage and hide these implementation details (schemas, queries, access to Repo) behind a well defined interface. And in the future if you’d want to add App2 I’d actually create a separate App2.Repo (that can use a different or the same underlying DB). The idea would be that each app is independent and isolated from each other as much as possible an the implementation details (e.g. Repo) don’t leak out.

P.S. you might have a typo in configuration: config :App_1 vs config :app_1 so maybe this is the reason you can’t run the migrations.

Thanks for your help. I’ll take your advice and restructure my project in a way that every app talks directly to the db. And about the typo, those names were just something I pulled out of my hat, not from the real project where they are (should be…) correct, but thanks anyway.