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
- How to destructure objects with typescript in next js.
- How to clean text editor data on next.js
- DeprecationWarning: Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument error on React Native.
- Error: Invalid `prisma.model.findMany()` invocation. Query engine library for current platform "debian-openssl-1.1.x" could not be found.
- Error Cannot find module 'react-dom/client' or its corresponding type declarations
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.