🔹 How to Regenerate a Specific Resource Using `ash.codegen` Without Affecting Others?
Hi,
I've read the
ash.codegen
(https://hexdocs.pm/ash/Mix.Tasks.Ash.Codegen.html) documentation but couldn't find an option related to this. I'm still in the early stages of development and sometimes make mistakes while defining resources (e.g. when generating multiple tables). When that happens, I want to regenerate just a specific resource from scratch, not create a new migration to fix it.
However, ash.codegen
seems to regenerate all active resources at once. To avoid that, I have to manually remove the files of the resource I want to regenerate and then run the generator again.
Is there any way to tell ash.codegen
to generate just a single resource instead of all of them?
Thank you in advanceSolution:Jump to solution
I don't think so. migrations are for one version of your database to the next. your app won't run if your migrations are incomplete and your resources don't match your database
3 Replies
Solution
I don't think so. migrations are for one version of your database to the next. your app won't run if your migrations are incomplete and your resources don't match your database
I think I need to manually remove and re-add each resource file to the project so that it will regenerate everything from scratch in the exact order I want. 🥲
I mean that seems like a pain in the butt, instead of generating a new migration
you might be interested in using the
--dev
flag when generating migrations, so you can generate a bunch until you get your schema just right, then run codegen without --dev
to flatten them all https://hexdocs.pm/ash_postgres/migrations-and-tasks.html#basic-workflow