superbunches
03/17/2022, 8:22 PMInvalid `prisma.book.findMany()` invocation:
{
include: {
moods: true,
~~~~~
? pairings?: true,
? _count?: true
}
}
Unknown field `moods` for include statement on model Book. Available options are listed in green. Did you mean `_count`?
This doesn’t make sense to me because npx prisma migrate dev
went fine, I’ve seeded my database using the new model name, and I’ve confirmed in postgres that the new table (Mood
) is there. Why would I get this error with the new field name and not the old field name?
Running prisma 3.11.0 & @prisma/client 3.11.0superbunches
03/17/2022, 8:28 PM// This model was already here, all I did was add the field "moods"
model Book {
title String
gbid String
createdAt DateTime
slug String @unique
authors String[]
categories String[]
publishedDate String?
smallThumbnail String?
thumbnail String?
description String?
id String @id
bookmarks Int @default(0)
pairings Pairing[]
moods Mood[]
}
// This model was already here, I left it untouched, will delete after the new model starts working
model Pairing {
createdAt DateTime
playlistType String
playlistId String
playlistName String
likes Int @default(0)
bookId String
id String @id @default(cuid())
playlistThumbnail String?
playlistCreators String[]
totalTracks Int @default(0)
book Book @relation(fields: [bookId], references: [id])
}
// Here is the new model, same fields as the Pairing model
model Mood {
createdAt DateTime
playlistType String
playlistId String
playlistName String
likes Int @default(0)
bookId String
id String @id @default(cuid())
playlistThumbnail String?
playlistCreators String[]
totalTracks Int @default(0)
book Book @relation(fields: [bookId], references: [id])
}
superbunches
03/17/2022, 8:31 PM-- CreateTable
CREATE TABLE "Mood" (
"createdAt" TIMESTAMP(3) NOT NULL,
"playlistType" TEXT NOT NULL,
"playlistId" TEXT NOT NULL,
"playlistName" TEXT NOT NULL,
"likes" INTEGER NOT NULL DEFAULT 0,
"bookId" TEXT NOT NULL,
"id" TEXT NOT NULL,
"playlistThumbnail" TEXT,
"playlistCreators" TEXT[],
"totalTracks" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "Mood_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Mood" ADD CONSTRAINT "Mood_bookId_fkey" FOREIGN KEY ("bookId") REFERENCES "Book"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Nurul
03/22/2022, 10:47 AMnpx prisma generate
would sync your PrismaClient with schema filesuperbunches
03/27/2022, 3:04 PMnpx prisma generate
both before and after npx prisma migrate dev
, still without success. I ended up just leaving my models named as they were.
Does npx prisma generate
always need to be run in conjunction with npx prisma migrate dev
?Nurul
03/29/2022, 12:13 PMnpx prisma migrate dev
it should ideally automatically run prisma generate
command so you shouldn’t have to execute it againsuperbunches
03/29/2022, 2:20 PMnpx prisma migrate dev
and npx prisma generate
, I was not aware that my project was still synced to an outdated PrismaClient.Nurul
03/29/2022, 2:48 PMsuperbunches
03/29/2022, 3:32 PM