I have created a table A having a id (serial) field. I have created a seeding sql file, where I specify explicitly the id values, because I have also to populate related tables having foreign key that refers to this id field.
All the seeding sql script run fine. But when it comes to perform a new insert in my table A (without specifying the id, serial, because I want it to be auto incremented) I get back a duplicate key error. Looks like that after the first seeding script. Postgres doesn't auto increment the index.
In fact, if I had inserted, let's say 3 records in the seeding phase, I'll get back three times the error from the subsequent inserts with id NULL, and then it starts inserting everything as expected. I.e. even if it report duplicate key error, it's incrementing the auto increment value each query sent.
How do you usually manage this? Thanks