Isaac Curtiss
09/12/2022, 7:53 PMmodel Item {
id String @id @default(cuid())
age String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
publishers Publisher[]
}
Model Publisher {
id String @id @default(cuid())
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
media Item[]
}
When I try to create/upsert an Item, I get the error that publisher name
is not unique (Unique constraint failed on the fields: ("name")
. However, I’m using connectOrCreate
within the upsert which means (in my understanding) if the current transaction has found that name
already exists it should connect
it (and not try to create it, which might be causing the error). Regardless, I’m trying to figure out where I’m wrong or what I can do to investigate more but so far I don’t understand how to solve this. I’d appreciate any help/thoughts from anyone 👍 (I have tried regenerating and that has not made a difference)Isaac Curtiss
09/12/2022, 7:59 PMconnectOrCreate
within the upsert for the Item
. I would assume that shouldn’t make a difference, but in case it does, I want to make it clear
Update: That _*could*_ be the issue 🤔Isaac Curtiss
09/12/2022, 8:16 PMVladi Stevanovic
Isaac Curtiss
09/15/2022, 4:43 PMVladi Stevanovic
Isaac Curtiss
09/15/2022, 10:17 PM