Prisma generated types not updating

Viewed 954

I use Prisma as an ORM and had to change remove some columns and add others. I've already updated the database with the new columns and recreated the prisma schema but the problem is that now every time I try to insert a new entry, I get this error:

Unknown arg "picture" in create.picture for type usersCreateInput. Did you mean "image"?

"picture" is one of the new columns and "image" is one of the deleted ones, it seems that the generated types are not being updated properly, cause one of the new columns is there (email_verified), but the other (picture) isn't.

type usersCreateInput {
  name?: String | Null
  email?: String | Null
  email_verified?: DateTime | Null
  image?: String | Null
  mentor?: Boolean | Null
  weekly_time?: Int | Null
  journey?: String | Null
  pronouns?: String | Null
  occupation?: String | Null
  description?: String | Null
  created_at?: DateTime
  updated_at?: DateTime
  skills?: usersCreateskillsInput | List<String>
  boards?: boardsCreateNestedOneWithoutUsersInput
}

These are exactly the steps I did:

  1. Changed the init.sql file used by Docker
  2. Recreated the DB based on the new init.sql
  3. Deleted the existent schema, then npx prisma init
  4. Run npx prisma db pull and npx prisma generate to recreate the schema based on the already existent database,and it's important to note that I checked the schema and it's correct:
model users {
  id             Int        @id @default(autoincrement())
  name           String?    @db.VarChar(255)
  email          String?    @unique(map: "email") @db.VarChar(255)
  email_verified Boolean?
  picture        String?
  mentor         Boolean?
  skills         String[]
  weekly_time    Int?
  journey        String?    @db.VarChar(255)
  pronouns       String?    @db.VarChar(255)
  occupation     String?
  description    String?    @db.VarChar(255)
  created_at     DateTime   @default(now()) @db.Timestamptz(6)
  updated_at     DateTime   @default(now()) @db.Timestamptz(6)
  boards         boards?
  sessions       sessions[]
}

Is there a way to completely reset prisma? I've also tried to remove node_modules and install everything again but it didn't solve.

2 Answers

If you ever run into a problem, where you think TypeScript is not working properly, you can always try to restart TypeScipt language server by pressing Ctrl+Shift+P and typing >Restart TS server. Make sure to navigate to a .ts file first!

This way you don't have to re-open VSCode.

I had the same problem. The solution was to run the command npm i to delete the current Prisma Client (no need to delete node_modules), and then run npx prisma generate to re-create a new Prisma Client.

Hereafter I still had an error when trying to query the new column, but then the solution was closing and re-opening the editor, in my case VS Code.

Related