Leave a Comment
Postgres in docker: random «unique violation» errors
While running postgres in docker (for development, of course), from time to time I just run into errors like «Duplicate Key Value Violates Unique Constraint».
I found the solution (thanks to this answer, for sure — https://stackoverflow.com/a/47089825/801426):
if you have a table called «[table]», just do this
SELECT setval('[table]_id_seq', (SELECT MAX(id) FROM [table]));