网站搜索

typescript - Prisma 数据库种子在远程 Supabase 实例上不起作用


我正在做一个 Nextjs 项目,并希望在 Vercel 上建立一个预览环境,在那里我使用 supabase(远程 Postgres)作为数据库。

我也想在预览环境中运行 prisma db seed,但我收到以下错误:

An error occurred while running the seed command:
Error: Command was killed with SIGSEGV (Segmentation fault): ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts

在 Vercel 的预览环境中,执行部署迁移的构建命令(prisma migrate deploy)成功,数据库的架构与本地完全相同。

如 Prisma 文档中所指定,我在 package.json 中添加了以下属性

"prisma": {
    "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
}

然后我将 .env 中的 DATABASE_URL 改为 supabase 的,并运行了 prisma db seed,结果出现了错误。

所以我尝试直接运行 seed.ts,并通过以下命令分配更多内存:NODE_OPTIONS="--max-old-space-size=4096" yarn ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts,但我仍然遇到分段错误。

请注意,Prisma 版本是 4.10.1,Node 版本是 18.12.1