Replies: 35 comments 56 replies
-
|
Thanks for this nice improvement! Much like what GraphQL allows, e.g. |
Beta Was this translation helpful? Give feedback.
-
|
This new functionality allows you to create subdirectories within Won't this affect the .prisma files I create inside these subdirectories? |
Beta Was this translation helpful? Give feedback.
-
|
I'd suggest supporting As it is we will need to run a script that collects all of the Prisma schema files, and copies them over. This feature as it currently exists will at least make this compilation easier, which I certainly appreciate. |
Beta Was this translation helpful? Give feedback.
-
|
A big thanks again to all the developers that made this possible. The following works perfectly for prisma generate (with the schema path set to src/infrastructure) but the vscode extension has trouble resolving the files. By adding empty ".prisma" files (auth.prisma and infrastructure.prisma below) this seems to resolve the extensions problems |
Beta Was this translation helpful? Give feedback.
-
|
Works great - big thanks! 🙌 🙏 1,291 lines => 28 files within 8 folders ♻️ ✨ |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
When i run this command I want to include How can i do it ? |
Beta Was this translation helpful? Give feedback.
-
|
I am having problems with baselining: https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining. The command required pointing to the schema data model, and this was my command to try to do it. It just generated an empty migration file, and because of that, further npx prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema/main.prisma \
--script > prisma/migrations/0_init/migration.sql |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
|
Thanks for making this possible! I think it would be beneficial to support multiple developer-specified directories. My use case: I would like to use prisma in a monorepo that governs multiple applications. Many of the models will be shared across each application. Example of possible directory structure and configuration in app-specific schema file: // app1.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
schemaFolders = ["./domain1", "./domain2", "./specific-to-app1"] // directories to include for App 1
}// app2.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
schemaFolders = ["./domain1", "./domain2", "./specific-to-app2"] // directories to include for App 2
}Thank you! |
Beta Was this translation helpful? Give feedback.
-
|
Does BackgroundResearchI tried upgrading and running Use CaseI use DBeaver to visually generate my database structure. Then, I run I am working with aider (an LLM code generation tool), and I need smaller schema files to pass as context. My entire schema is too large for the GPT API, which is costly and could confuse the LLM. Ideally for me, each model, enum, etc., would be in separate files. A slightly less granular split could also work, but I'm unsure how easily this could be automated or where the lines would be drawn. P.S. Thanks for adding support for Multi-file Prisma Schema! Even if |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
|
Hi, I am having issue with foreign keys across multiple files. $ npx prisma validate
error: Type "my_type_here" is neither a built-in type, nor refers to another model, composite type, or enum. |
Beta Was this translation helpful? Give feedback.
-
|
Fun pattern I've found is that with using symlinks you can support multiple datasources using the same schemas (more easily) now:
Corresponding {
"name": "db",
"version": "1.0.0",
"exports": {
"./postgres": {
"import": "./src/postgres.ts",
"default": "./src/postgres.ts",
"types": "./src/postgres.ts"
},
"./sqlite": {
"import": "./src/sqlite.ts",
"default": "./src/sqlite.ts",
"types": "./src/sqlite.ts"
}
},
"scripts": {
"gen": "pnpm run /^generate:*/",
"generate:pg": "prisma generate",
"generate:sl": "prisma generate --schema prisma/schema/sqlite",
"mig": "pnpm run /^migrate:*/",
"migrate:pg": "prisma migrate dev",
"migrate:sl": "prisma db push --schema prisma/schema/sqlite",
"seed": "prisma db seed",
"postinstall": "pnpm generate"
},
"devDependencies": {
"prisma": "latest",
"tsx": "^4.11.0",
"zod-prisma-types": "^3.1.8"
},
"dependencies": {
"@prisma/client": "latest",
"@prisma/instrumentation": "latest",
"prisma-extension-caching": "^1.0.9",
"zod": "^3.23.8"
},
"prisma": {
"schema": "prisma/schema/postgres",
"seed": "tsx prisma/seed"
}
}This is probably unrelated to feedback on the new schema folder feature (but unsure where else to put it), but could this open up the way to allowing multiple data sources in the future? I initially tried this out by having 2 |
Beta Was this translation helpful? Give feedback.
-
|
The VSCode extension does not support adding missing fields automatically in other file's models.
I found 2 ways to make it work automatically:
I'd expect the extension to update any file automatically, so when I add a field in "File A" pointing to a model in "File B", it would add this opposite relation field automatically in "File B". |
Beta Was this translation helpful? Give feedback.
-
|
Just enabled this feature in a project in which we already had migrations under I originally had in root both In the Is there any way to configure in which folder to place the migrations? |
Beta Was this translation helpful? Give feedback.
-
|
I'm hitting an issue when moving to multi-file prisma schemas where when I try to run That is located in In debugging the issue I isolated it down to this function being passed the current working directory which in this case is I was able to reproduce this calling the binary directly while in The current working directory for this call was While the current working directory for this call was (successfully ran without returning an error) I wondered if it had to do with the fact that I'm specifying the output directory for the generated files, but when I removed that it still errored. I also tried removing the Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
|
moving prisma folder into src folder generates issues for the multi file schema. leaving it in the root saves me stress |
Beta Was this translation helpful? Give feedback.
-
|
A quick update, we plan to release this preview feature to GA between March - August 2025. Read more here: #26136 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
if possible Add import-export features it will make things much easier. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I am managing the backend with NestJS in a modular monolith architecture, and I would like to split and manage the Prisma schema in the following structure. .
└── src/modules/
├── base/
│ └── db/
│ └── base.prisma
├── module-a/
│ └── db/
│ └── module-a.prisma
├── module-b/
│ └── db/
│ └── module-b.prisma
├── module-c/
│ └── db/
│ └── module-c.prisma
└── ... As mentioned in #24413 (comment), it is true that placing an empty schema will fix the issue that occurs with LSP, but there are many modules under the src/modules directory, so this approach is not practical. Regarding this issue, is there a plan to resolve it without placing empty schema files? Also, if there is an opportunity for contribution regarding this behavior, I would appreciate it if you could let me know. |
Beta Was this translation helpful? Give feedback.
-
|
Can this feature be related to PostgreSQL's schemas? I hope those split schemas naturally correspond to PostgreSQL's schemas and namespaced on the Prisma client code accordingly. |
Beta Was this translation helpful? Give feedback.
-
|
when i save, schema relations dont get autogenerated by the prisma extension when using multiple files. how do we fix this |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I find the following example in the docs to be quite confusing... ❌ As far as I can see, this doesn't work In that example, what is the Maybe I'm doing something wrong, but that didn't work for me. It ended up with ❌ Likewise, this doesn't work (but maybe expected as per the docs as migrations is at a different level) I kind of wish it did though? I would prefer to keep my schema files contained together without migrations ✅ The only structure I can seem to get working is as follows: I'm using Prisma 6.6.0 and have specified the schema location in |
Beta Was this translation helpful? Give feedback.
-
|
My experience trying to use this feature in 6.6.0 has been poor. Some thoughts:
|
Beta Was this translation helpful? Give feedback.
-
|
Considering the possibility of handling multiple databases, it would be helpful if |
Beta Was this translation helpful? Give feedback.
-
|
Please add this link: https://www.prisma.io/docs/orm/prisma-schema/overview/location#multi-file-prisma-schema on this blog post, it is not up to date: https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support |
Beta Was this translation helpful? Give feedback.











Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Support for your having Prisma Schema in multiple files is in preview behind the
prismaSchemaFolderpreview feature since release 5.15.0 on June 4th:Please share your feedback about this new functionality in this discussion.
GA planned for March-August 2025
Beta Was this translation helpful? Give feedback.
All reactions