redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.08k stars 980 forks source link

[Bug?]: Clarify impact on database file location with prisma multi file schema #11008

Closed Josh-Walker-GM closed 1 month ago

Josh-Walker-GM commented 1 month ago

What's not working?

This isn't strictly a bug in redwood but I am creating this issue to track what we want to do about the new behaviour (if we care to do anything at all).

In prisma v15.6.0 they made some breaking changes to the multi file schema preview feature:

  • When using relative paths in Prisma Schema files with the prismaSchemaFolder feature, a path is now relative to the file it is defined in rather than relative to the prisma/schema folder. This means that if you have a generator block in /project/prisma/schema/config/generator.prisma with an output of ./foo the output will be resolved to /project/prisma/schema/config/foo rather than /project/prisma/foo. The path to a SQLite file will be resolved in the same manner.
  • We realized that during migration many people would have prisma/schema as well as prisma/schema.prisma. Our initial implementation looked for a .prisma file first and would ignore the schema folder if it exists. This is now an error.

We added support for this in redwood recently. There was a slight difference in behaviour when I tested the multi file schema behaviour before and after the upgrade. The location that the database file resolves to is different.

If you setup the test project you'll get a sqlite database file in the standard spot. If you now enable prisma multi file schema and then perform some action like yarn rw prisma migrate reset you'll observe a new database file generated in a different location. This is mentioned in prisma's first point above.

The result of following the reproduction steps below. Observe multiple database files:

image

Maybe this is just something users should expect given prisma have changed their behaviour and we have nothing to do here? Perhaps we should add documentation to highlight this to our users?

I'll leave it up to @dthyresson to how to go forward but happy if you want to just close this as expected behaviour.

How do we reproduce the bug?

What's your environment? (If it applies)

No response

Are you interested in working on this?

dthyresson commented 1 month ago

@Josh-Walker-GM Yeah. It's broken now with Prisma's latest changes in. I'm chatting with them but kind of have to start from scratch and audit again to see where we look of the db and where we look for the schema models.

Josh-Walker-GM commented 1 month ago

This has been fixed now that redwood has updated to v5.18.0 of prisma.