I'm building a ReactJS/Node.js World Cup score prediction web app, and I just stumbled upon an odd problem. Apparently, when I seed my db, one column is missing.
I have a "seed.js" file containing data from every World Cup game. Each game is an object like this:
{
"gameTime": "2022-11-30T15:00:00Z",
"homeTeam": "tun",
"awayTeam": "fra",
"groupLetter": "d",
},
(I put a single game just for reference - there's 47 more like this one).
And here's the Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model User {
id String @id @default(cuid())
name String
email String @unique
username String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
guesses Guess[]
}
model Game {
id String @id @default(cuid())
homeTeam String
awayTeam String
gameTime DateTime
groupLetter String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
guesses Guess[]
@@unique([homeTeam, awayTeam, gameTime, groupLetter])
}
model Guess {
id String @id @default(cuid())
userId String
gameId String
homeTeamScore Int
awayTeamScore Int
user User @relation (fields: [userId], references: [id])
game Game @relation (fields: [gameId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, gameId])
}
However, when I seed those games into my db, here's how each game object goes:
{
"id":"cladepd2o0011wh7ca47fo06f",
"homeTeam":"tun",
"awayTeam":"fra",
"gameTime":"2022-11-30T15:00:00.000Z",
"createdAt":"2022-11-12T04:07:07.632Z",
"updatedAt":"2022-11-12T04:07:07.632Z"
}
There's no "groupLetter" argument! And that's a crucial one because I use it as a filter, so my app shows the games one group at a time. And then, when it tries to fetch games by group letter, I get the following error:
[GET] /games?groupLetter=a
01:12:46:96
PrismaClientValidationError: Unknown arg `groupLetter` in where.groupLetter for type GameWhereInput.
at Document.validate (/var/task/node_modules/@prisma/client/runtime/index.js:29297:20)
at serializationFn (/var/task/node_modules/@prisma/client/runtime/index.js:31876:19)
at runInChildSpan (/var/task/node_modules/@prisma/client/runtime/index.js:25100:12)
at PrismaClient._executeRequest (/var/task/node_modules/@prisma/client/runtime/index.js:31883:31)
at async PrismaClient._request (/var/task/node_modules/@prisma/client/runtime/index.js:31812:16)
at async list (file:///var/task/api/games/index.js:14:23)
at async bodyParser (/var/task/node_modules/koa-bodyparser/index.js:95:5)
at async cors (/var/task/node_modules/@koa/cors/index.js:108:16) {
clientVersion: '4.4.0'
}
I already tried to drop the "Game" table via PlanetScale and push it again, to no avail. I just don't understand why "groupLetter" is missing from the prod database.
Oh, locally it's all working fine (the app shows the games sorted by group, exactly how it's supposed to be).
Hope I didn't make it even more confusing that it is. Can you guys please help me out?
Nevermind... I realized, after staying up all night in front of the screen researching and doing a lot of trial and error, that I didn't redo
npx prisma generate
procedures. Problem solved now.