Should I use WS or HTTP for seeding database?
When deploying our preview environments, I want to seed them and have a script file I call using:
The script uses Drizzle. I'm curious do I have to use the http (non-pooled) connection for this?
I tried using it but got:
7 Replies
national-gold•2y ago
hmm, do you mind sharing what your script looks like?
Are you able to import the connection string from an env variable?
unwilling-turquoiseOP•2y ago
Okay so I followed what the github page mentioned actually, I added the ws config to the drizzle instance like below:
My script looks like this:
Each one of those calls uses the db instance to create rows...
other-emerald•2y ago
What platform do you deploy your preview environments to?
unwilling-turquoiseOP•2y ago
Vercel, I am using their automatic preview builds and the Neon integration. I then modified the default build script inside vercel to first run my migrations > next build > run the seed script
extended-yellow•2y ago
Did you get this working? I believe it should be fine. The only time I have seen this issue before was when the websocket pool was used in Next.js middleware
unwilling-turquoiseOP•2y ago
Yeah it's all good now
extended-yellow•2y ago
Awesome!