ConnectorError { user_facing_error: None, kind: ForeignKeyConstraintViolation }
nikolasburk opened this issue · comments
I'm on the latest alpha
branch, this is my schema:
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
}
model Post {
title String @unique
content String?
published Boolean @default(false)
author User?
}
model User {
email String @unique
name String?
posts Post[]
}
I migrated it using prisma2 migrate
and now want to use Prisma Client like so:
const user = await prisma.user.create({
data: {
email: "asd@asd.com",
posts: {
create: {
title: "Hello"
}
}
}
})
When running this code, I'm getting this error:
$ yarn dev
yarn run v1.22.0
$ ts-node ./script.ts
(node:46967) UnhandledPromiseRejectionWarning: Error:
Invalid `prisma.users.create()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: ForeignKeyConstraintViolation { constraint: ForeignKey } })
at PrismaClientFetcher.request (/Users/nikolasburk/Desktop/prisma-examples/typescript/script/node_modules/@prisma/client/index.js:90:17)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:46967) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:46967) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Is this a bug or am I doing something wrong?
Actually this was my bad, I messed up the client generation somehow... after deleting and re-generating this worked 🎉
Thanks @nikolasburk !