reset the value generator for SERIAL columns after import

This commit is contained in:
finn 2022-03-01 16:00:37 -08:00
parent 9a371b8f91
commit 17f823064f

View file

@ -230,6 +230,12 @@ func moveRecipients(source *sql.DB, dest *sql.DB) error {
return err
}
}
// start new rowids one above the current max value
_, err = dest.Exec("SELECT setval(pg_get_serial_sequence('signald_recipients', 'rowid', (SELECT MAX(rowid) FROM signald_recipients)+1);")
if err != nil {
return err
}
return nil
}
@ -494,6 +500,12 @@ func moveGroups(source *sql.DB, dest *sql.DB) error {
return err
}
}
// start new rowids one above the current max value
_, err = dest.Exec("SELECT setval(pg_get_serial_sequence('signald_groups', 'rowid', (SELECT MAX(rowid) FROM signald_groups)+1);")
if err != nil {
return err
}
return nil
}