Getting Negative IDs in the DB


In the postgres DB, we are getting negative values for many of the IDs like, organisationunitid, datasetelementid, lastupdated etc… May I know why we are getting the negative values and what is the reason?

ocahisv2=# select organisationunitid,uid from organisationunit where uid=‘VZ2grIQMcr8’;
organisationunitid | uid
-1551213020 | VZ2grIQMcr8

Thank you!

I would say, it’s not supposed to happen. normally it’s a sequence.

How did you get the data in ? if you restored a db is there any errors that prevented the “reset” of the sequence to the latest available/used ?

Sadly pg_restore or sql restore generally don’t fail fast and continue “as far as they can”.
but I would have expect more problem like duplicated id error (uniqueness constraint error) when creating new records than negative id.

We are restoring the DB to get the data. But we haven’t seen any errors while doing DB restore.
May I know anything more that needs to be checked and any other possibilities for negative IDs?