π§ NestJS + Prisma Multi-Schema Setup Issue
Struggling to configure multi-schema support in Prisma with NestJS?
Separated models/ across multiple files in nestjs. Please help me.

3 Replies
You selected the bot's instantaneous insights. Let me compile your answer right away!
Certainly! Prisma now supports splitting your schema into multiple files (multi-file schema) as of v6.7.0. This is ideal for DDD or modular NestJS projects. Hereβs how you can set it up:
1. Organize your schema files
Structure your Prisma files like this: Place your
You must tell Prisma CLI where your schema folder is. You can do this by: - Using the CLI:
- Or in
If you want to use multiple database schemas (e.g., PostgreSQL schemas), enable the
- Multi-file schema is GA, but multi-database-schema is still in preview. - If you use NestJS, ensure you import the correct generated client if you have multiple clients or outputs. If you run into issues, double-check your CLI commands and file structure. If you need to merge schemas in older Prisma versions, community tools like
Structure your Prisma files like this: Place your
datasource and generator blocks in schema.prisma. Put your models in separate files under models/ for clarity and modularity.
2. Configure Prisma to use the folderYou must tell Prisma CLI where your schema folder is. You can do this by: - Using the CLI:
- Or in
package.json:
- Or in prisma.config.ts:
All migrations must be next to the file with the datasource block (usually schema.prisma) Multi-file Prisma schema.
3. Multi-schema (database schemas) supportIf you want to use multiple database schemas (e.g., PostgreSQL schemas), enable the
multiSchema preview feature and use the schemas field in your datasource block. Assign models to schemas with @@schema("schema_name") How to use Prisma ORM with multiple database schemas.
Note:- Multi-file schema is GA, but multi-database-schema is still in preview. - If you use NestJS, ensure you import the correct generated client if you have multiple clients or outputs. If you run into issues, double-check your CLI commands and file structure. If you need to merge schemas in older Prisma versions, community tools like
prisma-import or prisma-merge can help, but native support is now available Multi-file Prisma schema.
π€ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.Looks related to this other thread of yours which is resolved?
https://discord.com/channels/937751382725886062/1389941146779779123
This is solved but I need the schema module base and multi File base because in a single
schema.prisma write all schema and handle them not easy.
So anyone can't do this?