Error Next.JS Prisma client not picking up new models
I created a database table in my schema file as shown below
model Users {
address String @id @unique
paid Boolean @default(false)
}
model Vote {
token String @id @unique
count Int @default(1)
}
and a prisma.ts file with the content below
// lib/prisma.ts
import { PrismaClient } from '@prisma/client';
let prisma: PrismaClient;
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;
Everything was working fine and I could access my models using the exported prisma variable then I added a new model as shown below
model LaunchPad {
id Int @id @unique @default(autoincrement())
name String
symbol String
tokenId String
total_supply String
decimal String
}
The global prisma variable is not picking up the new model and when I try to use it to save into the database using prisma.launchPad.create() it outputs the error below
TypeError: Cannot read property 'create' of undefined
Admin
2023-04-14
This problems happens sometimes and it has a very simple fix. All you need to do is to close your text editor and open it again
Similar Content
- Error: Invalid src prop (https://lh3.googleusercontent.com) on next/image
- Error Cannot find module 'react-dom/client' or its corresponding type declarations
- React Native error: showing blank screen on setting up react-navigation
- Setting up dynamic content sitemap in next.js using typescript
- How to render data from a text editor in a next.js web page without template tags
Privacy Policy
By using our website,
you agree that devmaesters can store cookies on your device and disclose information in accordance with our privacy policy.