Hi all, rw newbie here.
I’m running through the tutorial and putting in some of my own entities instead of blog posts etc. along the way.
Making plenty of mistakes of course! But one thing that caught me out is that I thought I had run the prisma migrations (but hadn’t) – ran
rw g scaffold restaurants and when I went to the scaffolded pages, they had an error (can’t call
.findMany() or something)
My expected behaviour is that
rw g scaffold should fail if the entity doesn’t exist in prisma.
Am I totally off the mark here or is that possible to implement this as a safety catch?
Also I want to say thanks to the rw team for a cool product, and the free stickers that you sent all the way from SF to the UK
Hi @SteGriff - thanks for the question. I believe this is expected.
Are you getting errors when generating SDLs or scaffolds for your Prisma models? There’s a known limitation in Redwood’s GraphQL type generation that happens when generating SDL for, or scaffolding out, a Prisma model that has relations before the SDL for the related model exists.
from Troubleshooting Generators
If I am not mistaken something like a
yarn rw g sdl restaurants will fix the error you are seeing.
Welcome @SteGriff and glad you’re enjoying RedwoodJS.
This is an interesting question, I think that as long as the schema model type for Restaurant exists in the schema file, then it should scaffold.
But I can see how it can be easy to forget to run a migration and then the database doesn’t actually have the model.
Perhaps a scaffold could check for the actual model in the db after and remind to migrate?
Wonderful answers, thank you both.
This was the most elucidating for me… I realised that I had a partially-saved prisma schema with only two of my seven intended fields when I ran the scaffold (multi-tasking…)
So, ok, that makes sense. I thought it had accepted something that wasn’t even in my schema but that’s not the case.
I’ve got another little problem but I’m going to open a fresh thread for searchability…