P
Prisma•4mo ago
TARS

npx prisma generate wont update the Product model.

Hey, I'm working on a simple e-commerce with next.js/prisma. And when I update the Product model the client doesn't update the types for Product. Here is the prisma.schema model Product:
model Product {
id String @id @default(uuid())
name String
description String
priceInCents Int
isActive Boolean @default(true)
isFeatured Boolean @default(false)
media Media[] @relation("ProductMedia")
orderItems OrderProduct[] @relation("ProductOrderProducts")
shippingCostInCents Int?

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Product {
id String @id @default(uuid())
name String
description String
priceInCents Int
isActive Boolean @default(true)
isFeatured Boolean @default(false)
media Media[] @relation("ProductMedia")
orderItems OrderProduct[] @relation("ProductOrderProducts")
shippingCostInCents Int?

createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Here is what I get from importing the Product type from @prisma/client
(alias) type Product = {
id: string;
name: string;
description: string;
priceInCents: number;
isActive: boolean;
isFeatured: boolean;
shippingCostInCents: number | null;
createdAt: Date;
updatedAt: Date;
}
import Product
(alias) type Product = {
id: string;
name: string;
description: string;
priceInCents: number;
isActive: boolean;
isFeatured: boolean;
shippingCostInCents: number | null;
createdAt: Date;
updatedAt: Date;
}
import Product
When I migrate the new schema to the db, it successfully reflects the changes I made to Product model, the media relation. I've deleted modules, reinstalled the client, rebooted the computer. What can I try more?
1 Reply
Nurul
Nurul•4mo ago
Hey 👋 Were you expecting to see the relations media and orderItems in the generated type? Can you share which fields you added to the product model that are not available in product type?
Want results from more Discord servers?
Add your server