1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00

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),