willbryant/kitchen_sync

Set nextval for postgresql sequences if necessary

willbryant opened this issue · 1 comments

With both the old SERIAL-style nextval() default and the new GENERATED .. AS IDENTITY implementations, postgresql uses a separate underlying sequence object and does not automatically increase that sequence's nextval if a higher ID is inserted into the table manually.

Therefore we need to do this explicitly or the next insert the user makes locally will generally fail on postgresql if there were any new (higher ID) rows in the 'from' database.

We can choose whether to set the nextval to the same value as the 'from' database has, or to only reset to the highest ID visible in the 'from' database. And we can choose whether to always reset or only reset if higher than the current value.

(mysql and mariadb both automatically increase the internal auto_increment value if a higher ID is inserted, so we don't have to do anything there, but we could reset there too if we wanted.)

False alarm, was already implemented in 0.40.