我在尝试访问在 next.js 应用程序上加载数据的页面时收到 504 内部服务器错误。错误指出:
Error retrieving users: PrismaClientInitializationError:
Invalid `prisma.job.findMany()` invocation:
Error querying the database: unable to open database file:
据我了解,它没有打开数据库,我不确定它是否是路径。在本地,该路径工作正常并且运行良好。我正在使用 prisma 连接数据库。
我该如何解决这个问题?
这是 vercel 日志上的完整错误:
Error retrieving users: PrismaClientInitializationError:
Invalid `prisma.job.findMany()` invocation:
Error querying the database: unable to open database file: /var/task/node_modules/.prisma/client/../database/invensisdb.db
at An.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:174:7205)
at An.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:174:6358)
at /var/task/node_modules/@prisma/client/runtime/library.js:177:2908
at async /var/task/node_modules/@prisma/client/runtime/library.js:177:3123
at async t._executeRequest (/var/task/node_modules/@prisma/client/runtime/library.js:177:10621)
at async Careers (/var/task/.next/server/pages/api/careers/post_get.js:64:25) {
clientVersion: '4.15.0',
errorCode: undefined
}
我的本地架构
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:../database/invensisdb.db"
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
createdAt DateTime @default(now())
}
model Job {
id Int @id @default(autoincrement())
location String
title String
description String
createdAt DateTime @default(now())
}
model JobApplication {
id Int @id @default(autoincrement())
email String
location String
startDate String
primarySkills String
createdAt DateTime @default(now())
}
model Projects {
id Int @id @default(autoincrement())
name String
location String
description String
duration String
createdAt DateTime @default(now())
}
基于此链接:SQLite 对 Vercel 的支持
Vercel 似乎不支持 SQLite,他们建议使用 Vercel Postgres 作为替代方案。