Repository navigation
Replies: 2 comments 1 reply
|
Hello @Paulo2703 👋 The
I would recommend changing your schema file a bit like this: model Company {
company_id String @id
products Product[]
productAttributes ProductAttribute[]
}
model Product {
sku String
company_id String
company Company @relation(fields: [company_id], references: [company_id])
attribute_id String?
productAttribute ProductAttribute? @relation(fields: [attribute_id], references: [attribute_id], onDelete: SetNull)
@@id([sku, company_id])
}
model ProductAttribute {
attribute_id String @id
company_id String
company Company @relation(fields: [company_id], references: [company_id])
products Product[]
@@unique([attribute_id, company_id])
}Now, the Hope this helps! Please let us know in case you have any further queries. If not, please consider marking the discussion as answered/closed. |
|
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.
Lets say we have 3 models:
Now when I want to delete a ProductAttribute, it will ALWAYS FAIL, as it will try to set the company_id on Product also Null due to the onDelete: SetNull parameter. How can I overcome this? How can i make sure only attribute_id will be set null?
All reactions