Prisma ORM · Schema

Composite keys and unique constraints

Use block attributes for keys and constraints that span several fields.

model Membership {
  userId  Int
  groupId Int

  @@id([userId, groupId])
  @@unique([groupId, userId])
}

Official Prisma ORM documentation

More schema commands

All schema commands · Prisma ORM cheatsheet

Was this page helpful?