P
Prisma5mo ago
Ted

How can I simultaneously use Accelerate with directUrl for some uses cases?

I keep getting Error validating datasource db: the URL must start with the protocol prisma://. I want to use my directUrl to bypass Prisma's 5MB limit in one use case. This works on localhost, but not on Vercel preview/production. I specify a Prisma accelerate URL in DATABASE_URL, and a direct url in DIRECT_DATABASE_URL. I'm instantiating prismaDirect this way:
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({
log: ['error'], // log: ['query', 'info', 'warn', 'error'],
}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient(
{datasourceUrl: process.env.DIRECT_DATABASE_URL || ''}
)
import {PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"

export const prisma = new PrismaClient({
log: ['error'], // log: ['query', 'info', 'warn', 'error'],
}).$extends(withAccelerate())

export const prismaDirect = new PrismaClient(
{datasourceUrl: process.env.DIRECT_DATABASE_URL || ''}
)
and my schema:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server