What does this error mean? > Foreign key constr...
# orm-help
b
What does this error mean?
Foreign key constraint failed on the field:
Print_userId_fkey (index)
I tried googling but I couldn't find any good explanation. Is it because some tables have Int as id while others have String?
Copy code
model User {
  id      String  @id
  email   String  @unique
  name    String
  picture String
  prints  Print[]
}

model Print {
  id     Int      @id @default(autoincrement())
  user   User     @relation(fields: [userId], references: [id])
  userId String
  output Json
  date   DateTime @default(now())
}
I get the error while doing prisma.print.create
r
Are you passing the user when doing
prisma.print.create
? User is required which is why it’s failing.
b
Oh wow, I reset the db and forgot to recreate the user 🤦
Cheers
💯 1