mix ash.codegen (ash v3.5.31)
View SourceRuns all codegen tasks for any extension on any resource/domain in your application.
Flags
- --dry-run- no files are created, instead the new generated code is printed to the console
- --check- no files are created, returns an exit(1) code if any code would need to be generated
- --dev- runs codegen tasks in dev mode. See the section on dev mode below
- Individual extensions may use additional flags.
Dev Mode
Some extensions that do codegen require providing a name. Those extensions (should) support a --dev
flag, which indicates that the codegen can have a temporary name chosen by the extension. Then, once you
are ready to commit the changes, you can run the codegen tasks again without the --dev flag and with a
name to generate the final code.
For example, using AshPostgres:
- First we add first_nametoMyApp.Accounts.User
- mix ash.codegen --dev, which generates a migration for adding- first_nameto the- "users"table, but the migration is suffixed with- _dev
- mix ash.migrateapply the migrations
- Then we add last_nametoMyApp.Accounts.User
- mix ash.codegen --devwhich generates a migration for adding- last_nameto the- "users"table, but the migration is suffixed with- _dev
- We review our changes, and are ready to save them as a unit
- mix ash.codegen add_name_to_user, which rolls back and deletes the dev migrations & snapshots, and creates new ones using the provided name