VercelPostgresError - 'missing_connection_string': You did not supply a 'connectionString'
Hello everyone!
So I'm getting the following error while trying to use the
@vercel/postgres
package with drizzle ORM
Here is my db index.ts
As well as my drizzle.config.ts
Few notes:
1. The URL is provided in connectionString. I'm sure it's defined. I have even hardcoded it. I'm 99% sure that the case is that Vercel postgres doesn't really read it and is trying to look for POSTGRES_URL
in the env (which is not present because I want to use prefixes for each DB depending on the environment).
2. As you can probably already guess I'm trying to make it so depending on the environment I'm using a different DB. You got any advice on that?7 Replies
This might be an issue on how drizzle-kit sets the connection string on the pg driver
Have you tried this:
Hey @Angelelz and thanks for the response, this actually works!
I'm really surprised, do you mind sharing why this is working ? It looks like sorcery to me 😛
Yeah, you're just setting connectionString and process.env.POSTGRES_URL to the same value
Hmm, didn't really get that.
When I do
connectionString = process.env.PROD_POSTGRES_URL
I assign the env variable to connectionString.
Why is connectionString = process.env.POSTGRES_URL = process.env.PROD_POSTGRES_URL
any different ?
Like, shouldnt drizzle be taking the variable from "connectionString" anyway ?PROD_POSTGRES_URL gets assigned to POSTGRES_URL and that gets assigned to connectionString.
Yes, I think it's an issue with drizzle-kit
I'm just offering a workaround
oohh okay good good. Now that makes a bit more sense.
Thank you very much, you're a wizard! Literally spent 5 hours straight trying to debug this
Thank you very much, you're a wizard! Literally spent 5 hours straight trying to debug this
I mean, you did. I only gave the last push
@Andrew Sherman Seems like the kit is not passing along the
connectionString
from the DB credential?