I am currently working on a Nest.js
project with Prisma
as my ORM. However, I have encountered an issue that needs to be addressed:
My User
model is quite simple:
model User {
id String @id @default(uuid()) @db.Uuid
firstName String? @map("first_name") @db.Citext
lastName String? @map("last_name") @db.Citext
phoneNumber String? @map("phone_number") @unique
email String @unique
password String
twitter String?
linkedIn String? @map("linked_in")
personalWebsite String? @map("personal_website")
title String?
bio String?
tac Boolean
accountConfirm Boolean @map("account_confirm") @default(false)
verificationCode VerificationCodes[]
confirmHashes ConfirmationHashes[]
session Sessions?
updatedAt DateTime @default(now()) @map("updated_at") @updatedAt @db.Timestamptz(6)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
@@map("users")
}
The recent change I made was switching @@map("user")
to @@map("users")
. After performing the migration and generating interfaces, I noticed that although the table name in the database has been updated, the corresponding interfaces in the code remain unchanged. As a result, I am unable to use the following code snippet:
await this.prisma.users.create({...
An error message pops up stating -
TS2551: Property 'users' does not exist on type 'PrismaService'.
. It suggests using .user
instead, but considering I already modified it in schema.prisma
, this solution seems incorrect.
I have attempted various troubleshooting steps such as deleting the node_modules
folder, reinstalling packages, and rebuilding multiple times without any success. Could there be a cache issue causing this problem? How can I resolve it?