PrismaP
Prisma11mo ago
5 replies
Uncle

Null constraint violation on the fields: (`ownerId`)

With the following schema when I try and create a new Project I get then Null constraint violation for field ownerId which doesn't exist anymore
model Project {
  id      String @id @unique @default(cuid(2))
  name    String
  rows    Row[]
}

model Row {
  rowId     String   @id @default(cuid(2))
  number    Int
  projectId String
  stitches  Stitch[]
  project   Project  @relation(fields: [projectId], references: [id])
}

model Stitch {
  id        String     @id @default(cuid(2))
  number    Int
  rowId     String
  completed Boolean    @default(false)
  row       Row        @relation(fields: [rowId], references: [rowId])
  type      StitchType
}

enum StitchType {
  Single
  Increase
}

model User {
  id            String         @id @unique @default(cuid(2))
  createdAt     DateTime       @default(now()) @map("created_at")
  updatedAt     DateTime?      @updatedAt @map("updated_at")
  email         String?        @unique
  givenName     String?
  familyName    String?
  emailVerified Boolean?       @map("email_verified") @default(false)
  archive       Boolean        @default(false)
  googleId      String?
  yahooId       String?
  // projects      Project[]
  session       Session[]
  verification  Verification[]

  @@unique([id, email])
  @@unique([email, givenName, familyName])
  @@index([id, email])
  @@map("users")
}
Was this page helpful?