mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
Use DATABASE_URL env in web prisma.ts
This commit is contained in:
parent
484c9fc6b1
commit
75bbd9af0a
1 changed files with 11 additions and 1 deletions
|
|
@ -13,7 +13,17 @@ const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }
|
|||
// @todo: we can mark this as `__unsafePrisma` in the future once we've migrated
|
||||
// all of the actions & queries to use the userScopedPrismaClientExtension to avoid
|
||||
// accidental misuse.
|
||||
export const prisma = globalForPrisma.prisma || new PrismaClient()
|
||||
export const prisma = globalForPrisma.prisma || new PrismaClient({
|
||||
// @note: even though DATABASE_URL is of type string, we need to check if it's defined
|
||||
// because this code will be executed at build time, and env.DATABASE_URL will be undefined.
|
||||
...(env.DATABASE_URL ? {
|
||||
datasources: {
|
||||
db: {
|
||||
url: env.DATABASE_URL,
|
||||
},
|
||||
}
|
||||
} : {})
|
||||
})
|
||||
if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue