You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a seed script for Prisma but I want to re-use it for testing, keeping some seed utilities for granular seeding per test groups.
Right now prisma/seed is assumed to be a script. This means as a user I need to configure my project to have two things: the module with my seed helpers and the script Prisma will execute.
I don't want to be forced to have two modules when one would be good enough.
Suggested solution
Only treat seed.ts as a script if there are no exports treat as a script
If there are ANY exports then do not treat as a script. Instead treat as a module interface. If user exports a run function call that. Maybe default too? Maybe other names? Also allow the module name/export name to be customized on cli like —seed foo:bar which would look for foo file and run bar function export.
Pass in useful info to the seed! For example an a schema AST so users can reflect on it to generate fake data more automatically. I’m sure lots of little nice things we could do there.
If the user does not export the correctly names function but it IS in the conventional disk place with the conventional file name probably we should warn because probably that is user error
This setup would allow best of both worlds: migrate run workflow integration + module API for use in other places like tests
Problem
I have a seed script for Prisma but I want to re-use it for testing, keeping some seed utilities for granular seeding per test groups.
Right now
prisma/seed
is assumed to be a script. This means as a user I need to configure my project to have two things: the module with my seed helpers and the script Prisma will execute.I don't want to be forced to have two modules when one would be good enough.
Suggested solution
Only treat
seed.ts
as a script if there are no exports treat as a scriptIf there are ANY exports then do not treat as a script. Instead treat as a module interface. If user exports a run function call that. Maybe default too? Maybe other names? Also allow the module name/export name to be customized on cli like
—seed foo:bar
which would look for foo file and run bar function export.Pass in useful info to the seed! For example an a schema AST so users can reflect on it to generate fake data more automatically. I’m sure lots of little nice things we could do there.
If the user does not export the correctly names function but it IS in the conventional disk place with the conventional file name probably we should warn because probably that is user error
This setup would allow best of both worlds: migrate run workflow integration + module API for use in other places like tests
Alternatives
Additional context
Internal Discussion
From another GH thread:
#5161
I don't consider this an alternative as I agree with Brandon about confusion etc. here.
The text was updated successfully, but these errors were encountered: