Hey all, currently migrating from TypeORM to Prism...
# orm-help
j
Hey all, currently migrating from TypeORM to Prisma and loving it so far! prisma rainbow Is there any way to have multiple different seeders? For example one that is ran always (such as to generate an admin user) and second that would be used only in development (generate random fake data)...
s
Not that I know of. You can of course use different seed scripts and run those scripts with npm or just node or something, when you want, but not with the prisma CLI as far as I know.
👍 1
j
Yeah, I assumed so as I wasn't able to find any resources for this. Thanks for the answer!
s
@Jiří Bartoš In your seed script ts file could you access process.env.NODE_ENV to determine if you are in the development environment or not? Then optionally run some seeding functions based on that?
👍 1
j
@Sabin Adams From top of your head, do you also know if the
prisma db seed
accepts any arguments that could be passed into the seeding function?
s
I don't know that it would accept arguments but the seed file should have access to process.env
👍 1
j
Absolutely. Thank you for your time!
s
You're welcome, let me know how it goes!
j
I think I will have the always ran seeds as the default
prisma db seed
and then add some optional development
npx ts-node <path/to/file>
seeds in the
package.json
scripts, as I am currently unsure whether they should be necessarily run always 🙂
👍 1
c
This is my seed script file structure. Different folders for different environments, plus a common folder for all environments and a shared folder for data that gets seeded into some environments but not others. Some data gets upserted, some gets added conditionally only once, etc. depending on the environment.
👍 2