I’ve created a simple table with a compound (composite) primary key, which got generated fine by yarn rw prisma migrate dev
. This is how it looks like:
model InterviewParticipantInfo {
tokenId String
key String
value String
@@id([tokenId, key])
}
However running yarn rw g sdl InterviewParticipantInfo
(with and without --crud
) gives:
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ WARNING: Cannot generate CRUD SDL without an `@id` database column. │
│ │
│ If you are trying to generate for a many-to-many join table │
│ you'll need to update your schema definition to include │
│ an `@id` column. Read more here: │
│ https://redwoodjs.com/docs/schema-relations │
│ │
└─────────────────────────────────────────────────────────────────────────┘
← Reverted because: Failed: Could not generate SDL
◼ Generating types ...
I only found this post from @rob mentioning in 2020:
We don’t currently know what to do about composite keys, the
@@id([postId, categoryId])
bit.
But that post was all about many-to-many relationships. Also all of the docs mention the @@id
only twice on the very same topic. But as once can clearly see, the above model is not trying to generate a many-to-many relationship here. Just a good old composite primary key, which the docs unfortunately don’t mention anywhere afaik.