Hey there, I have a question about umbrella structuring. The situation is as follows:
- I have a “core” domain, that is a shared kernel for other downstream domains
- I have several subdomains, where different teams might work independently later on
- I want to use a single postgresql database for the whole umbrella app
- Every team will need to manage some database models on their own, in addition to upstream models like the core domain’s
Basically it boils down to the situation that I have several phoenix frontend apps, several ecto backend apps and some pure-logic apps that might interact with external services but to not need a phoenix frontend or ecto persistance.
Deployment must be atomic, hence an umbrella project, what we call the “microlith”.
So far so good, everything worked out good, until I came to the point where more than one app needs distinct domain entities persisted in the same database. After a few days of googling, it seems there are these options:
-
have only one app within the umbrella hold the ecto
Repo
, migrations, schemas, and contexts. On the plus side, phoenix generators can be used easily, but it defeats the point of separating subdomains, since developers then constantly have to work in their own domain app AND the “db” app -
have only one app within the umbrella hold the ecto
Repo
, migrations, schemas, but not contexts. Here the phoenix generator can not be used to generate schema/migration/context at once, because the contexts live in the correct domain apps. Still the issue of app-switching for developers -
have only one app hold the ecto
Repo
, but nothing else, migrations/schemas/contexts live in their domain apps. I have no idea how to configure things to get this running. -
have every app using ecto on it’s own, configured to use the same database. In addition to being source of bugs (repeated database credential handling), this would spawn an ecto connection pool for every domain app to the very same database. Feels like something one would want to avoid entirely.
Does anyone have other ideas/experiences? If not, are there some examples how I could achieve 3) cleanly? The phoenix book demonstrates good how to split an app into a ecto/web umbrella, but not how to handle the more complex case of n-ecto/n-web umbrella projects.