Requires @@ for [partyId, partyName] even when [partyId] is already unique #19957
Replies: 2 comments 2 replies
|
Hello @sahnishant 👋 When you are defining a relation, and you specify the In your initial example: party party @relation(fields: [partyId], references: [id])
partyId IntIt's working because In your second example: party party @relation(fields: [partyId, partyName], references: [id, name])
partyId Int
partyName String @db.VarChar(255)You are trying to establish a relation using both the In your case, I can see why creating a unique index on a combination of |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community! |
Uh oh!
There was an error while loading. Please reload this page.
My model party has a field Id which is the index and primary key and unique.
So automatically [Id, Name] will be unique.
This part of the code works fine in another model named Invoce. (Which is generated for each party.
party party @relation(fields: [partyId], references: [id]) partyId IntBut I am trying to make a relation
party party @relation(fields: [partyId, partyName], references: [id, name]) partyId Int partyName String @db.VarChar(255)it shows the error as following
Forcing to make unique the pair [id, name] makes no sense to me!
Am i missing something very fundamental?
All reactions