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](https://cdn.answeroverflow.com/1242667529575338055/Screenshot_44.png)
![No description](https://cdn.answeroverflow.com/1242667529843904603/Screenshot_42.png)
5 Replies
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?yeah it does. prisma generates the model correctly but not the Anime model. also i moved the creation of above the model but still same issue
![No description](https://cdn.answeroverflow.com/1242975306881433610/Screenshot_45.png)
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
I think your bug is cause by primary key
what is primary key?