mohsen
I’m using an Umbrella project for a Phoenix application, and I want to have one Ecto Repo and one PostgreSQL database shared by all apps.
However, I want each app to keep its own migrations inside its own priv/repo/migrations directory.
For example:
apps/
├── accounts/
│ └── priv/repo/migrations/
├── billing/
│ └── priv/repo/migrations/
├── commerce/
│ └── priv/repo/migrations/
└── tenants/
└── priv/repo/migrations/
All of these apps would use the same Hasteh.Repo and the same database.
What I’m looking for is a proper, built-in way to generate and manage this structure, rather than manually creating or moving migration files or maintaining custom scripts/tasks.
I have looked through the Phoenix, Ecto, and Mix documentation and several Umbrella examples, but I haven’t found a clear answer.
For example, is there an official generator or command that can create an app in an Umbrella project with:
- no separate Repo
- no separate database
- the shared Repo from the umbrella
- migrations stored under that app’s own
priv/repo/migrations - migrations automatically discovered and managed across all apps
I ended up writing my own Mix task to handle this, but I’d prefer not to maintain a custom solution if there is already an official or recommended approach.
Is this architecture supported by the Phoenix/Ecto generators? If so, what is the recommended command/workflow to create these apps?
For reference, I’ll include some of the code I currently use below to show how I implemented this approach.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First Post!
LostKobrakai
You do not need to create mix tasks to adjust some flags. E.g. the gen.migration one could probably be an alias. Also generators are not necessarily meant to cover each and every usecase or permutations of setups. What you’re running is not a common setup. Needing some amount of explicit code is not unexpected.
Phoenix generators are also not really composable for historic reasons. If you’re looking for a better generator setup you can look at igniter.