Ok, @crabasa, take a look at this:
https://github.com/thedavidprice/crabasa-schema
Note: to be clear about @rob’s comment above re: Prisma complaining about CategoriesOnPosts → I could run
yarn rw db save
andyarn rw db up
just fine. It wasyarn rw g post
that failed if the model CategoriesOnPosts was present.
I used a local setup (so packages from RWJS ‘master’ branch). Started with our template from repo ‘create-redwood-app’. Then ‘yarn linked’ built packages. In the App for local dev I had to yarn add -W
Prisma packages @prisma/cli, @prisma/client, @prisma/sdk
I was able to scaffold both Post and Category models, but only after I removed CategoriesOnPost.
Note: I git committed each migration and generator step separately
@rob mentioned he thought this was already handled automatically by Prisma for relations. And, when I looked at the dev.db tables, here’s what I saw:
Doesn’t look exactly like the table you were trying to build. But something is happening behind the scenes here.
Here’s the schema.prisma I used:
datasource DS {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = env("BINARY_TARGET")
}
model Post {
id Int @default(autoincrement()) @id
title String
categories Category[] @relation(references: [id])
}
model Category {
id Int @default(autoincrement()) @id
name String
posts Post[] @relation(references: [id])
}