"Property 'create' does not exist" in prisma client

Viewed 2472

I have an entity defined "Board" in prisma.schema like this:

model Board {
  id        String   @id @default(uuid())
  createdAt DateTime @default(now()) @ignore
  updatedAt DateTime @updatedAt @ignore
  title     String
  posts     Post[]
  Team      Team     @relation(fields: [teamId], references: [id])
  teamId    String
}

After using prisma for a while, now the prisma.board.create function is unavailable (I think it was at around the time I added updatedAt)

I do have access to the rest of the functions, but trying to use create gives no autocomplete and this error:

Property 'create' does not exist on type 'BoardDelegate'.ts(2339)

What am I doing wrong? What are the usual cases for create not existing when the rest of the methods are there?

4 Answers

can you try doing the same but removing the @ignore from the createdAt field? I had the same issue, prisma-client v2.25.0 and it fixed it. If that's the case I think it is a bug.

I added "?" sign to these field and it worked:

model Board {
...
  createdAt DateTime? @default(now()) @ignore
  updatedAt DateTime? @updatedAt @ignore
...
}

There's currently a bug where create is lost when adding @ignore to a not-null field.

As @Moshe mentions, you can make it optional first as a workaround.

In case you landed here looking for a way to safely delete columns with no downtime, here's what I do:

  1. Mark the column optional and @ignoreed and remove all uses of the column in code
  2. Drop the column
Related