How to reset postgres' primary key sequence when it falls out of sync?
http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync
シーケンス番号 の整合性
SELECT setval('your_table_id_seq', (SELECT MAX(id) FROM your_table));
試してないけど、これでもOK
ALTER SEQUENCE sequence_name RESTART WITH (SELECT max(id) FROM table_name);