Hello, I get an error like this `Unique constraint...
# orm-help
o
Hello, I get an error like this `Unique constraint failed on the constraint: `PersonalData_userId_key`` but I don’t know why. It is the current relationship.
_model_ User {
personalData _PersonalData_?
}
model PersonalData {
user   _User_ @relation(_fields_: [userId], _references_: [id], _onDelete_: Cascade, _onUpdate_: Cascade)
userId _Int_  @unique
}
1
👀 1
n
Hi Okan 👋 From the snippet the model
User
doesn’t have
id
column which is being referenced in user relation column in
PersonalData
model. Could you try this schema:
Copy code
model User {
  id           Int           @id @default(autoincrement())
  personalData PersonalData?
}

model PersonalData {
  user   User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
  userId Int   @unique
}
o
@Nurul it actually has, I just removed the useless fields
n
Oh Okay, when do you get this error? Could you share the query which you are invoking?