-
Notifications
You must be signed in to change notification settings - Fork 155
Many-To-Many example in Redwoods documentation produces errors #673
Comments
Thanks @NickSchmitt It seems like Prisma might have changed up the syntax on us. @cannikin I reproduced the issue on Redwood v0.30.1 (using the latest Prisma v2.21.2). Here's my modification to resolve the Prisma errors — could this now be correct?
|
Hmmmm yeah in their docs it shows that you reference the join table itself, not the tables you're actually linking to (which is the opposite in an implicit relationship): https://www.prisma.io/docs/concepts/components/prisma-schema/relations#explicit-many-to-many-relations I wonder if that changed or we just wrote it into the docs assuming it worked that way but never tested? 😬 |
I just went and looked in our schema.prisma file
We haven't touched those parts of that file since October last year, so if Prisma changed it, they did so a long time ago 🙂 |
@NickSchmitt would you have a chance to take my schema example (earlier comment) for a test drive? If it's working, we'll need to update the docs. Just let me know either way and no pressure. |
@thedavidprice Just booted up a new rw proj with your schema. It migrates successfully and the product scaffold does generate, but the site crashes when run. Here's what I get in the terminal on
Interestingly the schema generates 5 SQL tables... is this expected?
|
@NickSchmitt ok, that might actually be a good sign that the Scaffold is working. The trick with trying to do generator CRUD with many-to-many is that you need SDLs for the other models as well. So it becomes a multi-step process. I'm thinking off the top of my head as I don't have time to try this out first, but effectively you'll need to step through the process something like this. First
Then update your schema, run
Again, it's been a while so I might have things backwards, etc. The Scaffold generator is really powerful and great to learn how things work, but when it comes to many-to-many, devs normally customize their implementation. |
Hello, thanks for all your hard work on Redwood.
I'm trying create a Many-to-Many schema that works with the Redwood Scaffold generator, but the example on the Redwood schema docs emits errors.
Steps to recreate:
schema.prisma code copied from Redwood documentation:
Initial errors in VSCode
Errors from running
yarn rw prisma format
:The text was updated successfully, but these errors were encountered: