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:
prisma.config.ts
Please help
4 Replies
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:
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!Thank to explain me
I am glad to see that the bot response was helpful 🙂
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