postgres reset sequence after import
Sometimes you get error after importing pg_dump data caused by constrain error
ERROR: duplicate key value violates unique constraint "transactions_pkey" (SQLSTATE 23505)
This can be caused by sequence that is not updated. Some symptoms include that if you retry multiple time, it works. That is due to every error increments the sequence.
To reset the value to the last id: (replace the
table_name
with your table)ERROR: duplicate key value violates unique constraint "transactions_pkey" (SQLSTATE 23505)
Last modified 5mo ago