diff --git a/pkg/db/dump.go b/pkg/db/dump.go index 334b4d1ed70..fde6d473763 100644 --- a/pkg/db/dump.go +++ b/pkg/db/dump.go @@ -18,6 +18,9 @@ package db import ( "encoding/json" + "strconv" + + "code.vikunja.io/api/pkg/log" "xorm.io/xorm/schemas" ) @@ -57,6 +60,15 @@ func Restore(table string, contents []map[string]interface{}) (err error) { } } + if Type() == schemas.POSTGRES { + idSequence := table + "_id_seq" + _, err = x.Query("SELECT setval('" + idSequence + "', " + strconv.Itoa(len(contents)) + ", true);") + if err != nil { + log.Warningf("Could not reset id sequence for %s: %s", idSequence, err) + err = nil + } + } + return }