Skip to content

[6.6.0] Schema Folder Docs Update #6774

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion content/200-orm/100-prisma-schema/10-overview/04-location.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading