I was getting duplicate primary key error while inserting a row in a table, despite of the primary key being a serial and me not passing any predefined value for it. So I went down to see what was happening with
SELECT last_value FROM tablename_id_seq; and got: 1, despite of table already having several rows. Obviously I would get that duplicate error, but why did serial returned that for me. Any suggestions on what can be happening and how to troubleshoot this?
Tables are migrated up together with some rows, prior to me getting hold on them.