I ahve a number of rails apps that use Postgres and every so often I need to delete all the tables and reimport the data directly into the database, doing this all works fine until a record tries to be added but because the sequences used for the id’s have been reset, I get errors due to the id already existing.
I assume MySQL works differently, but is there a way to avoid having to do multiple queries such as:
SELECT setval('authors_id_seq', (SELECT MAX(id)+1 FROM authors)); to update the sequences. IS there a way to make it work similarly to MySQL and just use the highest id that exists + 1 by default?
This really really bugs me and i’ve finally got around to asking here to see if anyone knows of a solution?