Skip to content

feat: add --use_fragments option to resource generator | Closes #437#709

Open
henryzhan013 wants to merge 1 commit intoash-project:mainfrom
henryzhan013:main
Open

feat: add --use_fragments option to resource generator | Closes #437#709
henryzhan013 wants to merge 1 commit intoash-project:mainfrom
henryzhan013:main

Conversation

@henryzhan013
Copy link

@henryzhan013 henryzhan013 commented Mar 5, 2026

Closes #437

Summary

Adds a new --use_fragments (-f) flag to mix ash_postgres.gen.resources
that generates attributes and relationships in a separate fragment file. This
allows the fragment to be regenerated without affecting user customizations in
the main resource file.

When enabled:

  • Creates fragment at {Resource}.Model (e.g., MyApp.Accounts.User.Model)
  • Fragment contains attributes, relationships, and identities
  • Main resource includes fragments: [FragmentModule] option
  • If resource already exists, only regenerates the fragment

Test plan

  • Added tests for basic fragment generation
  • Added tests for fragment with relationships
  • Added tests for regeneration (only fragment updated when resource exists)
  • All existing tests pass

Add a new `--use_fragments` (`-f`) flag to `mix ash_postgres.gen.resources`
that generates attributes and relationships in a separate fragment file.
This allows the fragment to be regenerated without affecting user
customizations in the main resource file.

When enabled:
- Creates fragment at `{Resource}.Model` (e.g., `MyApp.Accounts.User.Model`)
- Fragment contains attributes, relationships, and identities
- Main resource includes `fragments: [FragmentModule]` option
- If resource already exists, only regenerates the fragment
@henryzhan013 henryzhan013 changed the title feat: add --use_fragments option to resource generator feat: add --use_fragments option to resource generator | Closes #437 Mar 5, 2026
@zachdaniel
Copy link
Contributor

I would call the arg --fragments and also remove the alias, because -f typically means force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to generate resources from existing postgres as fragments

2 participants