What is the best Practices for Handling Migrations in a Reusable Ash Library?
Hi sorry, Suppose you are building a library using Ash, and the main application that will use this library is also developed with Ash. This library needs to apply some migrations to the project's database (has resources).
I'm wondering what the best approach would be in this case. Should we add a migration to the main Phoenix project, similar to how Oban does it? Or is there a better way to handle this in Ash?
Also, keep in mind that this library is expected to have new resources (and thus new migrations) added in the future.
This library also provides some AshJson. Do we need a mix task to help users add them to the AshJsonApiRouter domains, or is there a better way?
We’d like to minimize manual setup since this library is meant for public use.
Thank you in advance ♥️🙏🏻5 Replies
I'd personally do what Oban does, generate the migrations into the main app. I'm presuming that you can make it automatic (with
ash codegen etc)If something exists to seperate migrations for the first one user runs ash.codegen, it would be very good
If they use the migration generator then they can put your domains/resources in their own config in some way
i.e config :my_app, ash_domains: [YourResources]
then the migration generator will generate migrations for them
Yes i did like this and very Delicious 😂
But if it's the first time he's adding my domains to his project, Ash will create all the tables in one migration. But if it were possible to create them in, say, 10 migrations, it would be great.
I could create for him history of migrations
Solution
Not possible right now