P
Prisma•5mo ago
JayPe

Multiple schema - node_modules - prisma client

Hello, I have one monorepository with the following structure : /src /service1 /prisma prisma.schema /service2 /prisma prisma.schema I'm using only one Dockerfile, and a docker compose to expose both services. In dev environment, I want to be able to debug both services, but it seems that npx --yes prisma generate --schema src/service1/prisma/schema.prisma npx --yes prisma generate --schema src/service2/prisma/schema.prisma the second command will erase the content of the first command in the .prisma folder in node_modules. Is there any way to be able to generate prisma data from 2 different schemas ? so according to the order of my generates command, one service is working and not the other one. Any idea ?
5 Replies
RaphaelEtim
RaphaelEtim•5mo ago
Hi @JayPe 👋 Are you generating both schemas into a custom output directory?
JayPe
JayPe•5mo ago
Well, I just found a solution !!! In each schema.prisma file, I added the following
output = "generated/client"
output = "generated/client"
generator client {
provider = "prisma-client-js"
output = "generated/client"
}
generator client {
provider = "prisma-client-js"
output = "generated/client"
}
So the generated code is now stored in each "service" folder, and just added a git ignore like this It works like a charm
JayPe
JayPe•5mo ago
Generating Prisma Client | Prisma Documentation
This page explains how to generate Prisma Client. It also provides additional context on the generated client, typical workflows and Node.js configuration.
David
David•5mo ago
Hey, we just do this in both of our schema.prisma files
output = "../../node_modules/@prisma/client-mysql"
output = "../../node_modules/@prisma/client-mysql"
JayPe
JayPe•5mo ago
@David , thanks, I prefer to have it in my service folder under prisma folder, to ease the readability for new dev coming in the project and who does not know how prisma works
Want results from more Discord servers?
Add your server