Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to generate resources from existing postgres as fragments #437

Open
alykhanjetha opened this issue Dec 5, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alykhanjetha
Copy link

Is your feature request related to a problem? Please describe.
The current implementation of ash_postgres.gen.resources assumes that one porting an existing application to Ash. This is likely not the most common case, as it is rare that someone would abandon an existing app and a new one in a different language.

Instead, it is likely that migration from another environment is gradual and the management of the low level schema would remain in the original app for a while initially.

This means that the PG schema is really externally managed and likely to change -- which means I would have to manually edit my previously generated resources. This is error prone!

Describe the solution you'd like
Add an --use_fragments option to the generator.
This would generate the attributes and relationships in a separate fragment file.
If the resource does not exist (the first you run the generator), then the resource is created with a link to the fragment.

defmodule MyApp.Person do
  use Ash.Resource,
    domain: MyApp.Persons,
    fragments: [MyApp.Persons.Person.Model]

end

With this, person_model.ex can be regenerated at will. It would not alter or edit person.ex and all actions, calculations, changes etc... would be maintained.

Additional context

This argument is really about easing Elixir/Ash adoption.

@alykhanjetha alykhanjetha added enhancement New feature or request needs review labels Dec 5, 2024
@zachdaniel zachdaniel added good first issue Good for newcomers and removed needs review labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants