Change postres primary key sequence

get current maximum id in database table

SELECT MAX(id) FROM tablename;

check what the next id would be (has to be higher than the first result)

SELECT nextval('tablename_id_seq');

reset the sequence to the current maximum id

SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename));

comments powered by Disqus