Difference between table ids and sequences

After migrating to 2.5 we're encountering duplicate key errors when clicking the new/edit buttons in a datagrid. We've discovered a difference between the count of rows in some tables and the current value in the table sequences in pgadmin. After changing the current value to the correct count of rows, the error disappears for a particular table. Doing this manually for each table is very annoying. How can this happen?
2 answers

Not sure how it happend here, but in more "primitive" database environments this would be caused by deleted records....

Your "autonum" or any form of "last ID given out"- table would reflect the actual numbers given out. Count of records will "miss" the rocords deleted (and depending on your coding work: those numbers given out, but for any reason not committed)


I've used a early backup of my db instead of the current 'corrupted' one and it seems that the duplicate key errors are solved. I will monitor the results. But it seems definitely that these errors are made by synchronizing the database during development and migration.

We're still developing the 2.5 version of our app and we're not sure about the consequences of this problem for the real migration.