-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to use Prisma in monorepos #1288
Comments
I would like to add |
Vercel just bought Turborepo I think this is going to become very important very quickly! |
From what I've been testing, doesn't actually work when using ENV variables unless I place the So for instance, I have this monorepo with yarn workspaces
Seems like it needs to have the |
Related vercel/turborepo#979 (comment) |
Yes please, also declaring |
Yes! +1 to this 🙌🏽 EDIT: Relevant issue as well prisma/prisma#12535 |
Related example: https://github.com/vercel/turborepo/tree/main/examples/with-prisma |
I have an issue with monorepo using npm workspaces and prisma. The set up is there are two microservices that both use prisma (say packages/api1, packages/api2). If the same version of prisma is used in each, npm will create @prisma in the root node_modules. The generated .prisma files are installed as a sibling to @prisma, so api1 and api2 can clobber each other. One can specify where to generate the files, however, other dependencies (i.e. nestjs) uses @prisma/client to import, so the new location is ignored. |
@kokokenada Do you think this could be configurable in your NestJS app? If no, it might be worth opening an issue in the |
Thanks for the reply @nikolasburk, and yes, I also opened a ticket there: nestjs/nest#10150 and moved to notiz-dev/nestjs-prisma#31 |
I have the same issue as @kokoenada . I can't have a turborepo monorepo with two different Prisma schemas - Prisma gets confused about which schema to use. |
I came across this thread whilst looking for a solution to this: vercel/turborepo#5610 Wondering if anyone has experienced a similar issue? Edited: found the fix, see here in case it's of use to anyone: https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-monorepo |
For my case where the monorepo will have multiple packages with different schemas, I opted to generate separate prisma clients into separate directories. // packages/accounts/prisma.schema
generator client {
provider = "prisma-client-js"
output = "./node_modules/@prisma/accounts-client" // <-- note this
// output = "./node_modules/@prisma/dashboard-client" // <-- for other package "dashboard"
} // pacakges/accounts/src/...
import { PrismaClient } from '@prisma/accounts-client';
// ... Can anyone tell me if this is OK approach or I will have some unexpected issues along the way? |
e.g. using:
Note that there's a simple example with Yarn workspaces here: https://github.com/nikolasburk/monorepo-prisma
More context on the internal Slack:
screenshot
The text was updated successfully, but these errors were encountered: