-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: add groupBySchema to group types and enums under a namespace #110
base: main
Are you sure you want to change the base?
Conversation
I've published this PR as |
Thank you for taking the time! I tried your implementation on a schema with a hundred tables and it works fine. ESLint complains about the use of namespaces. I want to note that they aren't strictly necessary as Prisma already forces the model names to be distinct even if they are in different schemas. Another interesting avenue of improvement might be to designate a schema as default, e.g. the |
I didn't need to fix any test after adding this feature, this means that everything kept running exactly as before when
groupBySchema
is nottrue
.We are using this plugin in a giant schema (100+ tables under 18 schemas) where some of them have the same or similar names, which is very hard to spot visually which schema an imported type comes from.
This plugin simply adds all enums and models under a
ts.ModuleDeclaration
respective to their schema and fixes types references to it. It makes it much easier to work with schemas, the same visually/architecturally as thinking about why schemas are written likeschema.model
inside SQL.EDIT: I also added
filterBySchema
, which just picks all models from defined schemas.Now generates:
Instead of putting everything globally as previously: