diff --git a/content/200-orm/100-prisma-schema/10-overview/04-location.mdx b/content/200-orm/100-prisma-schema/10-overview/04-location.mdx index ce40444b4f..b0eaaf71b2 100644 --- a/content/200-orm/100-prisma-schema/10-overview/04-location.mdx +++ b/content/200-orm/100-prisma-schema/10-overview/04-location.mdx @@ -65,9 +65,46 @@ my-app/ ├─ ... ``` +### Schema resolution order + +Prisma ORM resolves the schema file or folder in this order: + +1. `--schema` CLI flag (path relative to the current working directory) +2. `schema` field in `prisma.config.ts` (path relative to the config file) +3. `prisma.schema` field in `package.json` (path relative to the `package.json`) +4. Default locations: `./schema.prisma` and `./prisma/schema.prisma` (relative to the project root) + +#### Referenced paths + +Any paths referenced within a Prisma schema file (e.g. SQLite file paths) are resolved _relative_ to that file itself. + +#### Migrations, views, and TypedSQL + +The `migrations`, `views`, and `sql` directories are placed **next to the schema file that contains the `datasource` block**. + +``` +my-app/ +├─ ... +├─ prisma/ +│ ├─ migrations/ +│ ├─ views/ +│ ├─ sql/ +│ ├─ schema/ +│ │ ├─ post.prisma +│ │ ├─ user.prisma +│ ├─ schema.prisma # contains `datasource` +├─ ... +``` + +:::info + +In the future, file placements can be customized via `prisma.config.ts`, allowing you to define locations that best suit your project's structure. + +::: + ### How to enable multi-file Prisma schema support -Support for multiple Prisma Schema files is currently in preview. To enable the feature, add the `prismaSchemaFolder` feature flag to the `previewFeatures` field of the `generator` block in your Prisma Schema: +Support for [multiple Prisma Schema files](/orm/prisma-schema/overview/location#multi-file-prisma-schema) is currently in [preview](/orm/reference/preview-features/client-preview-features). To enable the feature, add the `prismaSchemaFolder` feature flag to the `previewFeatures` field of the `generator` block in your Prisma Schema: ```prisma file=schema.prisma showLineNumbers generator client {