question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prisma generate, typings not updating in VSCode unless IDE is restarted.

See original GitHub issue

Bug description

Changing the type of a field in a model, or adding a new field, then running the command npx prisma db push and npx prisma generate are not updating the typings in my IDE, unless I restart VSCode after making my schema changes and running those commands.

During prototyping where I am frequently updating my models, this disrupts my workflow significantly.

How to reproduce

  1. Add a new field to a model
  2. Run npx prisma db push and npx prisma generate
  3. The field created in step 1 will not be recognized when executing await prisma.model.create(data: {…}).
  4. Restart VSCode
  5. Step 3 error goes away.

Expected behavior

The IDE recognizes the updates to the model and does not require a restart.

Prisma information

<!-- Do not include your database credentials when sharing your Prisma schema! -->
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model YoutubeAccount {
  username        String          @unique
  password        String
  profile_path    String
  proxy           String
  video_templates VideoTemplate[]
}

model VideoTemplate {
  id                     Int             @id @default(autoincrement())
  inputDirs              String[]
  title                  String
  description            String
  tags                   String[]
  clipCount              Int
  duration               Int
  width                  Int
  height                 Int
  YoutubeAccount         YoutubeAccount? @relation(fields: [youtubeAccountUsername], references: [username])
  youtubeAccountUsername String?
}

Environment & setup

  • OS:
  • Windows
  • Database:
  • PostgreSQL
  • Node.js version:
  • Node 18.4.0

Prisma Version

npx prisma -v
Environment variables loaded from .env
prisma                  : 4.2.0
@prisma/client          : 4.2.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 2920a97877e12e055c1333079b8d19cee7f33826 (at 
node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 2920a97877e12e055c1333079b8d19cee7f33826
Studio                  : 0.469.0

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
younes-alouanicommented, Aug 10, 2022

This bug is easy to reproduce. Just add a new field to any model that has been already pushed to database. Push the new model to database. Now the VS CODE will show an error when you do any operation using PRISMA with the new field. It’s says that the field doesn’t belong to Prisma. The bug goes away if you close and reopen the project vs code files.

3reactions
ZiadJcommented, Aug 10, 2022

Opening up the definition file by pressing F12 over a referenced type will fix it so there’s not need to restart. Not the best solution I know but I thought I’d mention it until a real fix comes up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Editors often don't pick up a newly generated prisma client
I have heard repeatedly that sometimes editors don't pick up changes when you change the prisma schema and then re-generate.
Read more >
Prisma generated types not updating - Stack Overflow
If you ever run into a problem, where you think TypeScript is not working properly, you can always try to restart TypeScipt language...
Read more >
Prisma client not updating after npx prisma generate - Reddit
When you restarted VS Code, it reindexed node_modules and found the changes. There's really no fix. When you make huge changes, sometimes you ......
Read more >
Blog Tutorial (short) - Remix
We're using Prisma to interact with the database, so we'll update that schema and Prisma will take care of updating our database to...
Read more >
The Case For Prisma In The Jamstack - Smashing Magazine
Jamstack sites serve static pre-rendered content through a CDN and generate dynamic content through microservices, APIs & serverless functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found