© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
34 replies
Tater Of Tots

violates foreign key constraint

First of all I'm very much front end so this question may be dumb and don't be afraid to talk to me like I'm 5.

Ok so here's whats happening: I have an old sql database from like the free databases you get with GoDaddy that I made forever ago and I'm trying to migrate it to Supabase. All of my PK are
Int8
Int8
. I have a table
students
students
and the students have these scan cards for attendance so theres another table of
cards
cards
with a FK of
student_id
student_id
.

The Problem: When I go to edit the FK
student_id
student_id
and add the foreign key relation in Supabase I get the error in the thumbnail.
Failed to run SQL Query: insert or update "cards" violates foreign key constraint "cards_student_id_fkey"
Failed to run SQL Query: insert or update "cards" violates foreign key constraint "cards_student_id_fkey"


Any ideas or thoughts are helpful. I'm kind of a DB noob so feel free to come in with any and all ideas. Thanks!
unknown.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

duplicate key value violates unique constraint Key (id)=(5)
SupabaseSSupabase / help-and-questions
3y ago
duplicate key value violates unique constraint "profiles_pkey"
SupabaseSSupabase / help-and-questions
3y ago
Composite key foreign key issue
SupabaseSSupabase / help-and-questions
6mo ago
supabase.auth.api.createUser duplicate key value violates unique constraint users_pkey
SupabaseSSupabase / help-and-questions
4y ago