@Robert thanks for jumping in here! Super helpful as you know.
@crabasa I stepped things a bit forward for experimentation. It’s not a full Prisma Schema ↔ Redwood Generators solution. But it is helpful learning to understand what is and isn’t working.
Clarifying what I’m trying to do
From “preview” to “beta”, Prisma made a lot of changes to their schema file syntax, including a lot of new support for relations (and types/complexity) of relations. The Redwood “sdl” and “scaffold” generators we not built to handle these capabilities. (Note: scaffold is just a set of other generators, which includes sdl.) Aside from answering the question about “What types of relations and complexity should Redwood support?”, right now we’re just trying to do one thing → make sure the Redwood generators run correctly on Prisma-2.0.0-Beta.2 for the purpose of completing the Redwood Tutorial. And secondly, if possible, add generator support for simple relationships in the schema.prisma.
A very important point → regardless of what kinds of relations the generators currently do (and someday will) support, as long as you can run “yarn rw db …” on your schema, it works! The generators are not necessary. They’re just really helpful when able to be used. If a model in your schema is incompatible with Redwood generators, just build the SDL and component files directly.
Note: @crabasa is also experiencing a known Prisma bug in Redwood v0.4.0 using Prisma-2.0.0-preview025. We believe this is solved in Prisma Beta.2, which is in ‘master’ and will be included in the next Redwood release (hopefully on Monday). This is a separate issue not related to the schema and generator questions.
I wanted to see if the updated Redwood generators in ‘master’ (using Prisma Beta.2), could support the models in @crabasa’s schema. When I ran the generators in with the CategoriesOnPosts model, everything failed. However, I did get them to work for Post and Category when I removed CategoriesOnPosts. And then I was interested to see how Prisma was handling tables and relations in the DB.
@crabasa I realize this doesn’t solve your actual DB table requirements. But, it did confirm for us that simple relation support is working (hat tip to @rob for a hellofa lotta work last week )
A new test: re-adding the “CategoriesOnPost” model
I have updated the repo https://github.com/thedavidprice/crabasa-schema
- re-added the model “CategoriesOnPost” (note: intentionally kept singular; see @rob’s original comment in this thread)
- re-ran
yarn rw db save
and yarn rw db up
successfully
- confirmed
yarn rw dev
is working and the individual CRUD for “/posts” and “/categories” are still working correctly
Important Take-aways (for now)
@crabasa Your schema works just fine! But, unfortunately, the Redwood CRUD generators do not support your model “CategoriesOnPost”
However, for simple relations the generators do work.
It’s a hack of a workaround, but by going through each model individually, I could get the specific model CRUD generators to work. And then add the additional models needed.
Lastly, here’s what is now happening in the local sqlite dev.db: