The id parameter of the model I designed is autoincrement, but when adding a new record, I get a unique constraint error.
Model
model InventoryItem {
id Int @id @default(autoincrement())
level Int @default(0)
position Int
window Int
character Character @relation(fields: [characterId], references: [id])
characterId Int
item Item @relation(fields: [itemId], references: [id])
itemId Int
}
Code
await prisma.inventoryItem.create({
data: {
characterId: myCharacter.id,
position: 0,
level: item.level,
itemId: item.id,
window: 1
}
})
prisma version: 5.2.0 @prisma/client version: 5.2.0