aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLunny Xiao2021-11-03 08:28:21 +0800
committerGitHub2021-11-03 08:28:21 +0800
commitcf217befb0c709f65d09756c913e5973b093309c (patch)
tree91c4998cfec97b81715bc00b8460ded1309f176b
parentf8503b5fbf2ad9b04db6a8bfa5d4922e55c28430 (diff)
Fix database keyword quote problem on migration v161 (#17524)release/v1.14
* Fix database keyword quote problem on migration v161 * support rerun migration v161
-rw-r--r--models/migrations/v161.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/migrations/v161.go b/models/migrations/v161.go
index 4ca9f0121..283c44464 100644
--- a/models/migrations/v161.go
+++ b/models/migrations/v161.go
@@ -5,6 +5,8 @@
package migrations
import (
+ "context"
+
"xorm.io/xorm"
)
@@ -40,8 +42,17 @@ func convertTaskTypeToString(x *xorm.Engine) error {
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 {
- 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
}
}