Hi all — is there a way to run a seed command on a...
# orm-help
j
Hi all — is there a way to run a seed command on a prisma/express app already running in heroku? I tried to just do a
npx prisma db seed --preview-feature
from the heroku console. The command seemed to run, and then process exited but there is still no data in the DB. I have run this locally and it has worked perfectly fine.
r
I do it locally because it is more consistent since if you make a mistake on production weird things could happen.
j
Thanks @Ruslan Gonzalez totally agree on that front, but I was hoping to run the seed at least once in production (to seed specific constants, like user types for example)
gonna try just running the node script I think, to see what happens.
r
so why don't you create a bootstrap script that does that for you?
j
Figured the seed might be able to handle that, but that is precisely the route I’m taking now after failing with the seed route
r
with Heroku you could use the Procfile, or just exec something from the main script using the postinstall script
j
good call
but I am looking to only run this once and then done
so I might just write out a sql script and call it a day
r
postinstall is a npm hook which is really nice and easy to use. But if you want to go even better, you could setup a Continuos Deployment pipeline for doing that automatically
j
thanks, I’ve got the heroku deployment pipeline set up automatically actually and it is running great.
r
SQL scripts are good but over Javascript/Typescript you have more control on validating the data, eg. if data already exists
j
but it seems that seeding should be one-time thing (like migrations) so cant really run a seed postinstall with every release.
r
I guess !! that on production environment seeding is being automatically
but not sure!
again I do it locally and manually or with a CD
j
🔥