Skip to content

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

Merged
zachdaniel merged 2 commits intoash-project:mainfrom
henryzhan013:main
Mar 9, 2026
Merged

feat: add --use_fragments option to resource generator | Closes #437#709
zachdaniel merged 2 commits intoash-project:mainfrom
henryzhan013:main

Conversation

@henryzhan013
Copy link
Contributor

@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

@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

@henryzhan013
Copy link
Contributor Author

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

Got it, I will do it that way.

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
@zachdaniel zachdaniel merged commit becb870 into ash-project:main Mar 9, 2026
15 of 18 checks passed
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