prismaSchemaFolder Pattern?
Hi, do I need a
.prisma
file every time I encounter a folder structure of prismaSchemaFolder
?
Based on the example below, (a,b).prisma fails to read the model of c in (a,b).prisma.
The services folder does not have .prisma.
The services folder subtest folder has .prisma.
7 Replies
You selected the bot's instantaneous insights. Let me compile your answer right away!
The services folder does not have .prisma.
The services folder subtest folder has .prisma.
서비스 폴더에는 .prisma가 없는 상황입니다. 서비스 폴더 하위 테스트 폴더에는 .prisma가 있습니다.
With the multi-file Prisma schema feature (now generally available since v6.7.0), Prisma will recursively collect all
.prisma
files within the directory you specify as your schema location—either via the --schema
CLI flag, the prisma.schema
field in package.json
, or the schema
property in prisma.config.ts
.
Key points for your structure:
- You do not need a .prisma
file in every folder. Prisma will find all .prisma
files under the specified directory, including nested subfolders.
- All models defined in any .prisma
file within the schema directory (and its subdirectories) are available to each other, so you can reference models across files and folders.
- The only strict requirement is that the file containing your datasource
and generator
blocks (commonly schema.prisma
) must be at the root of the schema directory, and your migrations
folder must be at the same level as that file.
For your example:
If you set your schema location to prisma/schema
, Prisma should pick up c.prisma
, a.prisma
, and b.prisma
(and any other .prisma
files in subfolders). Models in a.prisma
and b.prisma
should be able to reference models in c.prisma
and vice versa, as long as you are using a supported Prisma version (v6.7.0+), and you have configured the schema location correctly (e.g., "prisma": { "schema": "./prisma/schema" }
in your package.json
) Multi-file Prisma schema docs.
If you are experiencing issues where models in a.prisma
or b.prisma
cannot see models in c.prisma
, double-check:
- You are using Prisma v6.7.0 or newer.
- Your schema location is set to the directory, not a single file.
- There are no duplicate model or datasource definitions.
You do not need a .prisma
file in every fo
lder—just ensure all relevant .prisma
files are somewhere under the schema directory you specify.My version of Prisma is not version 6.7.0.
I'm using version 6.1.0, and the models are all correctly identified, but the IDE doesn't seem to recognize them, even though they are there.
나의 프리즈마 버전은 6.7.0 버전이 아닙니다. 6.1.0 버전을 사용중이며, 모델은 모두 정확히 식별되지만, IDE에서는 모델이 있음에도 불구하고 서로를 알지못하는 경우가 발생합니다.
🤔 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.
Could you try using the latest prisma version (6.14.0) and check if you observe the same behaviour?
6.14.0 에서도 동일한 문제가 발생됩니다.