fix: migrate to Prisma 7 driver adapter (libsql) for SQLite
Prisma 7 removed support for `url` in schema.prisma datasources and the `engineType = "library"` native binary engine. All connections now go through a driver adapter. - Remove engineType and url from schema.prisma (no longer supported) - Configure prisma.config.ts with migrate.adapter using @libsql/client - Instantiate PrismaClient with PrismaLibSQL adapter in src/lib/prisma.ts - Add @libsql/client and @prisma/adapter-libsql dependencies - Remove PRISMA_CLIENT_ENGINE_TYPE from Dockerfile (obsolete) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
import { PrismaLibSQL } from '@prisma/adapter-libsql'
|
||||
import { createClient } from '@libsql/client'
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined
|
||||
@@ -6,7 +8,12 @@ const globalForPrisma = globalThis as unknown as {
|
||||
|
||||
function getPrismaClient(): PrismaClient {
|
||||
if (!globalForPrisma.prisma) {
|
||||
const libsql = createClient({
|
||||
url: process.env.DATABASE_URL ?? 'file:./dev.db',
|
||||
})
|
||||
const adapter = new PrismaLibSQL(libsql)
|
||||
globalForPrisma.prisma = new PrismaClient({
|
||||
adapter,
|
||||
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
||||
})
|
||||
}
|
||||
@@ -15,8 +22,6 @@ function getPrismaClient(): PrismaClient {
|
||||
|
||||
// Use a Proxy so `new PrismaClient()` is only called when a property
|
||||
// is first accessed (inside a request handler), NOT at module import time.
|
||||
// This prevents PrismaClientConstructorValidationError during Next.js
|
||||
// static analysis / "Collecting page data" phase.
|
||||
export const prisma = new Proxy({} as PrismaClient, {
|
||||
get(_target, prop) {
|
||||
return Reflect.get(getPrismaClient(), prop)
|
||||
|
||||
Reference in New Issue
Block a user