Schema location
The default name for the Prisma Schema is a single file schema.prisma
in your prisma
folder. When your schema is named like this, the Prisma CLI will detect it automatically.
If you are using the
prismaSchemaFolder
preview feature any files in theprisma/schema
directory are detected automatically.
Prisma Schema location
The Prisma CLI looks for the Prisma Schema in the following locations, in the following order:
-
The location specified by the
--schema
flag, which is available when youintrospect
,generate
,migrate
, andstudio
:prisma generate --schema=./alternative/schema.prisma
-
The location specified in the
package.json
file (version 2.7.0 and later):"prisma": {
"schema": "db/schema.prisma"
} -
Default locations:
./prisma/schema.prisma
./schema.prisma
The Prisma CLI outputs the path of the schema that will be used. The following example shows the terminal output for prisma db pull
:
Environment variables loaded from .env
Prisma Schema loaded from prisma/schema.prisma
Introspecting based on datasource defined in prisma/schema.prisma …
✔ Introspected 4 models and wrote them into prisma/schema.prisma in 239ms
Run prisma generate to generate Prisma Client.
Multi-file Prisma Schema
Multi-file Prisma Schema is available via the prismaSchemaFolder
preview feature in Prisma versions 5.15.0 and later.
To use multiple Prisma Schema files, add a schema
folder inside of your current prisma
directory. With the prismaSchemaFolder
Preview feature enabled, you can add as many files as you want to the prisma/schema
directory.
my-app/
├─ ...
├─ prisma/