0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-23 18:44:46 +01:00

Fix database keyword quote problem on migration v161 (#17522)

* support rerun migration v161

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
Lunny Xiao 2021-11-05 06:47:01 +08:00 committed by GitHub
parent e5b48dcac4
commit fed8e01ca1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,8 @@
package migrations package migrations
import ( import (
"context"
"xorm.io/xorm" "xorm.io/xorm"
) )
@ -42,8 +44,17 @@ func convertTaskTypeToString(x *xorm.Engine) error {
return err return err
} }
// to keep the migration could be rerun
exist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "hook_task", "type")
if err != nil {
return err
}
if !exist {
return nil
}
for i, s := range hookTaskTypes { for i, s := range hookTaskTypes {
if _, err := x.Exec("UPDATE hook_task set typ = ? where type=?", s, i); err != nil { if _, err := x.Exec("UPDATE hook_task set typ = ? where `type`=?", s, i); err != nil {
return err return err
} }
} }