duplicate key value violates unique constraint Key (id)=(5)
Okay Im becoming crazy ahah, in multiple table, when I delete some row and after reupload data, im getting this error :
That doesnt make sense because the id should automatically set...
Im using Supabase self hosted btw
5 Replies
And if I run again and again my script the id value grow :
Key (id)=(7) already exists.
Key (id)=(8) already exists.
So I guess the problem is because Ive upload my data in csv. and maybe the unique id are broken
You need to set the corresponding sequence for your PK to start at the highest value you've already got in there. It doesn't look for the next available value, it just increments a sequence and uses the next value.
When I do :
SELECT PG_GET_SERIAL_SEQUENCE('tmdb_collection_translation', 'id');
Im getting this
But if is take the serial sequence another table its working
Okay its fixed Ive duplicate the table