P
Prisma2w ago
Luigi

Cannot find any tables with multi-file-separated models in newest version

I've just updated to version 6.14.0, followed all the instructions to add a typescript config file and remove the package.json instructions and ended up with this setup where it is not finding any of my models and it just dropped all my tables when migrating. Here is my setup: This is my exact file structure:
yda-web/
├── prisma/
├── schema/
├── user.prisma
├── notification.prisma
├── schema.prisma
└── prisma.config.ts
yda-web/
├── prisma/
├── schema/
├── user.prisma
├── notification.prisma
├── schema.prisma
└── prisma.config.ts
prisma.config.ts
import path from "node:path";
import type { PrismaConfig } from "prisma";

export default {
schema: path.join("prisma", "schema"), // This points to the folder
} satisfies PrismaConfig;


schema.prisma
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
import path from "node:path";
import type { PrismaConfig } from "prisma";

export default {
schema: path.join("prisma", "schema"), // This points to the folder
} satisfies PrismaConfig;


schema.prisma
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Please help
4 Replies
Prisma AI Help
You selected the bot's instantaneous insights. Let me compile your answer right away! Your setup is almost correct, but there are a few critical details to ensure multi-file Prisma schemas work as expected in v6.14.0: 1. schema Directory: Your prisma.config.ts correctly points schema to prisma/schema, which is the folder containing your .prisma model files. 2. Main schema.prisma: You must have a single .prisma file (e.g., schema.prisma) in the prisma/schema directory that contains your datasource and generator blocks. Currently, your schema.prisma is in prisma/, not prisma/schema/. Move it so your structure is:
yda-web/
├── prisma/
│ ├── schema/
│ │ ├── user.prisma
│ │ ├── notification.prisma
│ │ └── schema.prisma <-- move here!
│ └── prisma.config.ts
yda-web/
├── prisma/
│ ├── schema/
│ │ ├── user.prisma
│ │ ├── notification.prisma
│ │ └── schema.prisma <-- move here!
│ └── prisma.config.ts
3. Migrations Directory: The migrations folder (if present) must be at the same level as the .prisma file with the datasource block (i.e., inside prisma/schema/ if that's where schema.prisma is) Multi-file Prisma schema. 4. No Duplicate datasource/generator: Only the main schema file should have datasource and generator blocks. The other .prisma files should only contain models/enums. 5. Prisma CLI: You do not need to specify --schema if you have prisma.config.ts set up correctly. Summary of Fixes: - Move schema.prisma into prisma/schema/. - Ensure only one datasource/generator block. - If using migrations, move the migrations folder into prisma/schema/. This should resolve the issue of models not being found and tables being dropped unexpectedly. If you still encounter issues, double-check that no .prisma files outside the prisma/schema/ directory define a datasource or generator block, as this can cause conflicts and schema merging errors Docs: Multi-file Prisma schema. ✅ Great, thanks for letting us know that this solved your question!
Hanzo malik
Hanzo malik2w ago
Thank to explain me
Nurul
Nurul2w ago
I am glad to see that the bot response was helpful 🙂
Luigi
LuigiOP2w ago
No I didn't mark it as solved, and in fact it is not working I couldn't try the solution until now @Prisma AI Help I still get the same result - all tables are dropped, the only thing that is different is that I now have to specify the path to the schema.prisma everytime. @Nurul please help, I now have the setup the bot reommended to me with everything in the ./prisma/schema folder other than ./prisma/seed and ./prisma/prisma.config.ts I will open a new post Continued here: https://discord.com/channels/937751382725886062/1408398913731301419

Did you find this page helpful?