VercelPostgresError - 'missing_connection_string'

Hello everyone, so I've been beating my head with this for a couple of hours I had managed to make it work initially but after changing some things up and setting up different DBs for staging, dev and prod it is no longer working When I run npm run dev the right env variables are loaded like ( DEV_POSTGRES_URL: 'postgres://defaul... but drizzle still gives me the error in the title. My config looks like this:
const connectionString =
process.env.VERCEL_ENV === "development"
? process.env.DEV_POSTGRES_URL
: process.env.VERCEL_ENV === "production"
? process.env.PROD_POSTGRES_URL
: process.env.VERCEL_ENV === "preview"
? process.env.STAGING_POSTGRES_URL
: "";

export default {
schema: "./src/schema.ts",
out: "./drizzle",
driver: "pg",
dbCredentials: {
connectionString: connectionString || ""
},
} satisfies Config;
const connectionString =
process.env.VERCEL_ENV === "development"
? process.env.DEV_POSTGRES_URL
: process.env.VERCEL_ENV === "production"
? process.env.PROD_POSTGRES_URL
: process.env.VERCEL_ENV === "preview"
? process.env.STAGING_POSTGRES_URL
: "";

export default {
schema: "./src/schema.ts",
out: "./drizzle",
driver: "pg",
dbCredentials: {
connectionString: connectionString || ""
},
} satisfies Config;
But I get the same error even when I just hardcore the string. Any ideas ?
1 Reply
Mr Volcano
Mr Volcano11mo ago
Okay so I'm pretty sure this is a bug. Drizzle doesn't even look at the connection string, even if you supply it.
Instead, what it does is look for "POSTGRES_URL" inside the .env That's why it previously worked fine. Because the db url was in the "POSTGRES_URL" variable and now that I renamed it to "DEV_POSTGRES_URL" it cant find it.
Want results from more Discord servers?
Add your server