# Organize Your Prisma Schema into Multiple Files URL: https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support Published: 2024-06-04 Updated: 2026-07-06 Authors: Jon Harrell Tags: orm, education Description: Prisma ORM supports splitting your schema into multiple .prisma files, Generally Available since v6.7.0. Learn the Prisma 7 setup with prisma.config.ts, best practices, and common pitfalls. Prisma ORM lets you [organize your Prisma Schema into multiple files](https://www.prisma.io/docs/orm/v7/prisma-schema/overview/location#multi-file-prisma-schema). You split your models across as many `.prisma` files as you like, relations work across files without any imports, and Prisma combines everything when you run `prisma generate` or a migration command. The feature is Generally Available since v6.7.0, so no preview flag is needed. In Prisma ORM v7, you point the `schema` property in `prisma.config.ts` at the directory that holds your schema files. This post shows the setup, when to split, and the pitfalls to avoid. Multi-file schemas were [one of our most requested features](https://github.com/prisma/orm/issues/2377): they first shipped as the `prismaSchemaFolder` Preview feature in v5.15 and went GA in [v6.7.0](https://github.com/prisma/orm/releases/tag/6.7.0). ### How to split your Prisma Schema into multiple files [#how-to-split-your-prisma-schema-into-multiple-files] A multi-file schema keeps your main `schema.prisma`, containing the `generator` and `datasource` blocks, at the top of your `prisma` directory, with your models split into files alongside or below it. A common layout groups model files in a `models` subdirectory: ``` prisma/ ├── migrations ├── models │ ├── user.prisma │ └── post.prisma └── schema.prisma ``` In Prisma ORM v7, tell Prisma where your schema directory lives via the `schema` property in `prisma.config.ts`. Note that it points at the directory, not at a single file: ```ts // prisma.config.ts import "dotenv/config"; import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: "prisma/", migrations: { path: "prisma/migrations", }, datasource: { url: env("DATABASE_URL"), }, }); ``` The main `schema.prisma` only carries the `generator` and `datasource` blocks (in v7, the connection URL lives in `prisma.config.ts`, as shown above): ```prisma // prisma/schema.prisma generator client { provider = "prisma-client" output = "../src/generated/prisma" } datasource db { provider = "postgresql" } ``` If you need a PostgreSQL database for `DATABASE_URL`, the fastest way to get one is [Prisma Postgres](https://www.prisma.io/postgres): running `npm create db` provisions a database and gives you the connection string to put in your `.env` file. Now you can create model files in your schema directory. All models can be referenced in all files, so relations can cross files like so: ```prisma // prisma/models/user.prisma model User { id Int @id @default(autoincrement()) name String posts Post[] } ``` ```prisma // prisma/models/post.prisma model Post { id Int @id @default(autoincrement()) title String content String authorId Int author User @relation(fields: [authorId], references: [id]) } ``` When running `prisma generate`, all schema files are combined, so your workflow continues as normal. Other Prisma CLI commands, such as `validate` and `format`, work with multi-file schemas too, and the [Prisma VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) understands them as well, including "Go to Definition" across files. We verified this exact setup on Prisma ORM 7.8.0: `prisma generate`, `prisma db push`, and relation queries across the two files above all work without any flag. ### Common pitfalls [#common-pitfalls] A few things to watch out for, all of which we ran into while testing: * **Point `schema` at the directory, not the file.** If `prisma.config.ts` says `schema: "prisma/schema.prisma"`, Prisma only reads that one file: `prisma generate` still succeeds, but the generated client silently contains none of the models from your other files. If your models seem to have disappeared after splitting files, check this first. * **Keep `schema.prisma` directly in the configured directory.** The file with your `generator` block must sit at the top of the directory you configured (e.g. `prisma/schema.prisma`), not in a subdirectory like `prisma/models/`. * **Keep the `migrations` directory at the same level as `schema.prisma`.** * **Keep every `.prisma` file inside the configured directory.** Prisma only loads files from the directory you specify, so files outside it are ignored. ### When to use multi-file schemas [#when-to-use-multi-file-schemas] We've heard and seen that as a project grows, a single-file Prisma Schema eventually hits a point where it's simply too large to manage effectively. You'll see immediate benefits from this feature if you: * Have a complex schema: if your schema has large models or complex relations, putting related models into a separate file can help make your schema easier to understand and navigate. * Have a large team: when you have a single Prisma Schema file and have many developers committing, you could run into some pretty annoying merge conflicts during your day. Separating a large schema into several files can help reduce this pain. ### Tips for multi-file Prisma Schemas [#tips-for-multi-file-prisma-schemas] We've found a few patterns work well with this feature and will help you get the most out of it: * Organize your files by domain: group related models into the same file. For example, keep all user-related models in `user.prisma` while post-related models go in `post.prisma`. Try to avoid having "kitchen sink" schema files. * Use clear naming conventions: schema files should be named clearly and succinctly. Use names like `user.prisma` and `post.prisma` and not `myModels.prisma` or `CommentFeaturesSchema.prisma`. * Have an obvious "main" schema file: while you can have as many schema files as you want, you'll still need a place where you define the `generator` block. We recommend having a single schema file that's obviously the "main" file so that these blocks are easy to find. `main.prisma`, `schema.prisma`, and `base.prisma` are a few we've seen that work well. ### Sample Project [#sample-project] If you'd like to see how this feature looks in the real world, check out our [fork of dub](https://github.com/prisma/dub) from dub.co, one of our favorite OSS projects! ### Looking ahead: Prisma 8 [#looking-ahead-prisma-8] Schema organization is also central to [Prisma 8](https://www.prisma.io/blog/prisma-next-early-access-write-your-contract-prompt-your-agent-ship-your-app), the next generation of Prisma ORM and the version npm installs by default. In Prisma 8, your schema is a single centralised data contract that both you and your coding agent work against, and you can author it in Prisma Schema Language or in TypeScript, keeping your data model in the same language as your application. It's fast, too: in [our published benchmark](https://www.prisma.io/blog/prisma-next-performance-benchmark), a fork of the open-source drizzle-benchmarks suite, Prisma 8 reaches roughly 90% of the raw `pg` driver's speed and ships a client of about 148.5 KB gzipped. Like Prisma ORM, it pairs with [Prisma Postgres](https://www.prisma.io/postgres) out of the box. For new projects, especially ones built with AI coding agents, start with Prisma 8. ## Where to go next [#where-to-go-next] * [Read the multi-file Prisma schema docs](https://www.prisma.io/docs/orm/v7/prisma-schema/overview/location#multi-file-prisma-schema) for the current workflow and caveats. * [Explore Prisma ORM](https://www.prisma.io/orm) if you're evaluating the broader developer workflow around schema design and generated types. * [Pair it with Prisma Postgres](https://www.prisma.io/postgres) if you want a managed Postgres setup that works naturally with larger Prisma projects.