Skip to content

ConnectorError { user_facing_error: None, kind: ForeignKeyConstraintViolation } #1752

@nikolasburk

Description

@nikolasburk

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: "[email protected]",
    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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions