P
Prisma•5d ago
-_---_-

Issue installing latest Prisma in Next.js

Hey currently I have duplicates of schema.prisma in all of my APIs I want to create a shared/prisma/schema.prisma in the root of the repo. I'm installing Prisma in my Next.js project just to use the types. I do all of my database querying on a dedicated website_api on different service provider to be decoupled from Next.js and for security. I'm running into issues generating the types with Next.js. All of my web apis use an older version of Primsa I'm going to update. Right now, I'm installing the lates version of Prisma, again, just for schema model types. I keep hitting an error. I use PlanetScale. Does this look correct for the config file? Next.js uses an .env.local file. Not sure if that matters
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "../shared/prisma/schema.prisma",
datasource: {
url: env("DATABASE_URL"),
},
});
import "dotenv/config";
import { defineConfig, env } from "prisma/config";
export default defineConfig({
schema: "../shared/prisma/schema.prisma",
datasource: {
url: env("DATABASE_URL"),
},
});
This ^^^ is in the root of my next/ folder - same level as package.json. This is my script for this.
"prisma:generate": "prisma generate --config ./prisma.config.mjs"
"prisma:generate": "prisma generate --config ./prisma.config.mjs"
Does this look correct?
4 Replies
Prisma AI Help
Prisma AI Help•5d ago
You selected to wait for the human sages. They'll share their wisdom soon. Grab some tea while you wait, or check out #ask-ai if you'd like a quick chat with the bot anyway!
-_---_-
-_---_-OP•5d ago
ok it was the env.local, I had to do something special with donenv Actually, can you even have a shared schema in a monorepo? #ask-ai can I have a shared schema-prisma in a monorepo all of my APIs access?
Gregersen
Gregersen•4d ago
In a monorepo you'd likely want all your database schemas, definitions etc. in one package, and then expose the package to the rest of the monorepo. And that is entirely possible 🙂
Nurul
Nurul•4d ago
Agreed. Also if you want to interact with the AI bot you can tag @kapa.ai in the #ask-ai channel and ask your question.

Did you find this page helpful?