summaryrefslogtreecommitdiffstats
path: root/models/migrations/v161.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-05 06:47:01 +0800
committerGitHub <noreply@github.com>2021-11-05 00:47:01 +0200
commitfed8e01ca118b75430bed48d4424a9b83879c5b1 (patch)
tree2526f78c7b9c844e904fc18839917e4b5fae5032 /models/migrations/v161.go
parente5b48dcac4cc195f64f642126b476df0b9e1c06e (diff)
downloadgitea-fed8e01ca118b75430bed48d4424a9b83879c5b1.tar.gz
gitea-fed8e01ca118b75430bed48d4424a9b83879c5b1.zip
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>
Diffstat (limited to 'models/migrations/v161.go')
-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 7ef06b4c26..af6bdf16aa 100644
--- a/models/migrations/v161.go
+++ b/models/migrations/v161.go
@@ -5,6 +5,8 @@
package migrations
import (
+ "context"
+
"xorm.io/xorm"
)
@@ -42,8 +44,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
}
}