P
Prisma2mo ago
kngs

Foreign key constraint failed on the field: `anime_season_fkey (index)`

Getting this error when I try to create a new db entry in prisma, no clue why. Using Postgres rismaClientKnownRequestError: Invalid prisma.anime.create() invocation: Foreign key constraint failed on the field: anime_season_fkey (index)
No description
No description
5 Replies
jonfanz
jonfanz2mo ago
Generally that means that you are inserting a record (anime.create) that can’t find a related record (seasons). Is dataObject.season ever null or undefined? Does the seasons with that seasonYear always exist?
kngs
kngs2mo ago
yeah it does. prisma generates the
Seasons
Seasons
model correctly but not the Anime model. also i moved the creation of
seasons
seasons
above the
anime
anime
model but still same issue
No description
kngs
kngs2mo ago
im not sure if im approaching this correctly in the first place. After i create all my models (season/anime). I want to be able to query my season model with "find" and then access all the anime under that season model
$lucky$
$lucky$2mo ago
I think your bug is cause by primary key
kngs
kngs2mo ago
what is primary key?