refactor: 降级到 Prisma 6,移除 adapter 依赖
Prisma 6 内置 SQLite 引擎,无需 adapter、无需编译工具链, 与 no-whatever 项目保持一致的技术方案。
This commit is contained in:
+8
-11
@@ -1,14 +1,11 @@
|
||||
import { PrismaClient } from "@/generated/prisma/client";
|
||||
import { PrismaLibSql } from "@prisma/adapter-libsql";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
function createClient() {
|
||||
const url = process.env.DATABASE_URL ?? "file:./dev.db";
|
||||
const adapter = new PrismaLibSql({ url });
|
||||
return new PrismaClient({ adapter });
|
||||
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
export const prisma = globalForPrisma.prisma || createClient();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
|
||||
Reference in New Issue
Block a user