Postgress can exec Sync2 after migration only in own transactions (#544)

(postgress do not allow us to use sync2 twice in one transaction at all)
This commit is contained in:
6543 2021-11-27 12:02:52 +01:00 committed by GitHub
parent 88236d8d59
commit 34a17f8219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,11 +85,11 @@ func Migrate(e *xorm.Engine) error {
return err
}
if err := syncAll(sess); err != nil {
if err := sess.Commit(); err != nil {
return err
}
return sess.Commit()
return syncAll(e)
}
func runTasks(sess *xorm.Session, tasks []task) error {
@ -128,7 +128,11 @@ func runTasks(sess *xorm.Session, tasks []task) error {
return nil
}
func syncAll(sess *xorm.Session) error {
type syncEngine interface {
Sync2(beans ...interface{}) error
}
func syncAll(sess syncEngine) error {
for _, bean := range []interface{}{
new(model.Agent),
new(model.Build),