Multi-file prisma schema setup not working.

I currently have the following setup:
root/
prisma/
models/
users.prisma
schema.prisma
root/
prisma/
models/
users.prisma
schema.prisma
When I run bun prisma generate for some reason, it's not seeing ANY models within the users.prisma file, nor is it loading them. I have added:
"prisma": {
"schema": "./prisma"
},
"prisma": {
"schema": "./prisma"
},
to the package.json file but it just isn't seeing the other *.prisma files.
7 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away! A few things to check for multi-file schemas: 1) Point Prisma to the folder (not a file) - Your package.json is correct:
"prisma": { "schema": "./prisma" }
"prisma": { "schema": "./prisma" }
This tells Prisma to recursively load all .prisma files under prisma/. [Schema location] 2) Ensure datasource/generator live in a file inside that folder - You must have a .prisma file in prisma/ (e.g., prisma/schema.prisma) that defines your datasource (and usually generator). Prisma discovers other files from that anchor. [Schema location] 3) Migrations folder placement - If you use migrations, the migrations directory must be next to the .prisma file that defines the datasource (i.e., prisma/migrations alongside prisma/schema.prisma). [Config reference; Schema location] 4) Do not point to a single file - Avoid commands like --schema ./prisma/schema.prisma when using multi-file; that will ignore other files. Always pass the folder (./prisma) or rely on package.json. [Issue 26849; Issue 27495 cmt] 5) Keep generated artifacts outside the schema folder - If a generator outputs into a subfolder of prisma (e.g., prisma/generated), Prisma will also scan those .prisma copies and you may get duplicate datasource errors. Configure generator output outside prisma. [Issue 27495 cmt] 6) If using prisma.config.ts - Prefer placing prisma.config.ts at repo root, and set:
import path from "node:path";
import type { PrismaConfig } from "prisma";

export default {
schema: path.join("prisma"),
} sati
sfies PrismaConfig;
import path from "node:path";
import type { PrismaConfig } from "prisma";

export default {
schema: path.join("prisma"),
} sati
sfies PrismaConfig;
Don’t put prisma.config.ts inside prisma/. [Issue 27974; Config reference] Quick checklist for your structure: - prisma/schema.prisma contains datasource (and generator). - prisma/models/users.prisma contains only models/enums (no second datasource). - package.json has "prisma.schema": "./prisma". - Generator output not inside prisma/. - Run: npx prisma validate and npx prisma generate (or bun prisma generate) without --schema pointing to a file. If it still doesn’t work, please share: - schema.prisma (datasource/generator blocks) - users.prisma (ensure only models) - Your generator output path This will help pinpoint if Prisma is only seeing the anchor file or being confused by extra files. [Schema location; Issue 27495 cmt] 🤔 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.
DeathlyNocturnal
DeathlyNocturnalOP4w ago
This doesn't solve the issue at all schema.prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
output = "./client"
}

datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
output = "./client"
}

datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
./models/users.prisma
model Users {
id Int @id @default(autoincrement())
email String @unique
name String?
createdAt DateTime @default(now())
}
model Users {
id Int @id @default(autoincrement())
email String @unique
name String?
createdAt DateTime @default(now())
}
I am importing from the generated client, but no dice Ah funnily enough if I use, yet another, config file then it works....
Nurul
Nurul4w ago
Is this happening in latest prisma version 6.16.0? Could you share a minimal reproduction for me to look at?
jawad
jawad3w ago
this setup is not working for me either, please check the screen shots, however when i point prisma to exact schema.prisma file then it complains of no models in schema.prisma files, I have tried every solution propsoed so far, couldn't get it to work .
No description
No description
Gregersen
Gregersen3w ago
Hey both, have you created a prisma.config.ts file, that points to the folder instead of the single schema file? An example:
import * as path from "path";
import type { PrismaConfig } from "prisma";

export default {
/**
* The path to the Prisma schema file.
*/
schema: path.join("prisma", "schema"),
} satisfies PrismaConfig;
import * as path from "path";
import type { PrismaConfig } from "prisma";

export default {
/**
* The path to the Prisma schema file.
*/
schema: path.join("prisma", "schema"),
} satisfies PrismaConfig;
In my case, the path is db/prisma/schema/ where schema is a folder in which all my models live. Does this work for you?
No description
DeathlyNocturnal
DeathlyNocturnalOP3w ago
But I thought we could do this with the package.json? Why do we need another config file?
Gregersen
Gregersen3w ago
Because the configuration in package.json is being deprecated as of version 7. I have never managed to get the package.json config to work with multi schema, I wonder if its not supported from there, seeing its being deprecated. Just speculation in any case. I cant claim to know why 🙂

Did you find this page helpful?