fix(prisma): don't declare prisma as a global object and explicitly import it (#11839)
parent
47bb3000f6
commit
833fe7c7b7
|
@ -2,6 +2,7 @@ import { expect } from "@playwright/test";
|
|||
import { randomBytes } from "crypto";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { generateSecret } from "@calcom/trpc/server/routers/viewer/oAuth/addClient.handler";
|
||||
|
||||
import { test } from "./lib/fixtures";
|
||||
|
|
|
@ -7,6 +7,7 @@ import { getLocation } from "@calcom/lib/CalEventParser";
|
|||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import type {
|
||||
Calendar,
|
||||
CalendarEvent,
|
||||
|
|
|
@ -4,11 +4,6 @@ import { withAccelerate } from "@prisma/extension-accelerate";
|
|||
|
||||
import { bookingReferenceMiddleware } from "./middleware";
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var prisma: typeof prismaWithClientExtensions;
|
||||
}
|
||||
|
||||
const prismaOptions: Prisma.PrismaClientOptions = {};
|
||||
|
||||
if (!!process.env.NEXT_PUBLIC_DEBUG) prismaOptions.log = ["query", "error", "warn"];
|
||||
|
@ -57,10 +52,11 @@ const prismaWithClientExtensions = prismaWithoutClientExtensions
|
|||
|
||||
// const prismaWithClientExtensions = prismaWithoutClientExtensions;
|
||||
|
||||
export const prisma = (globalThis.prisma as typeof prismaWithClientExtensions) || prismaWithClientExtensions;
|
||||
export const prisma =
|
||||
((globalThis as any).prisma as typeof prismaWithClientExtensions) || prismaWithClientExtensions;
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
globalThis.prisma = prisma;
|
||||
(globalThis as any).prisma = prisma;
|
||||
}
|
||||
|
||||
export type PrismaClient = typeof prismaWithClientExtensions;
|
||||
|
|
Loading…
Reference in New Issue