N
10/01/2022, 2:13 PMmodel User {
id Int @id @default(autoincrement())
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int @unique // relation scalar field (used in the `@relation` attribute above)
}
Vladi Stevanovic
The interpretation is that a User can optionally have a profile but a profile CANNOT be created without a user.
Is there a way to express the relationship: a User must have a Profile and a Profile CANNOT exist without a user?
A follow up question is why does Prisma have to enforce only one side of a relation can be mandatory.
And it also seems like you resolved your issue here: https://prisma.slack.com/archives/CA491RJH0/p1664635287817279Vladi Stevanovic
N
10/14/2022, 5:31 PM