Skip to content

Commit 251fdaa

Browse files
authored
Fix database keyword quote problem on migration v161 (#17523)
* support rerun migration v161
1 parent f572fb9 commit 251fdaa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

models/migrations/v161.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package migrations
66

77
import (
8+
"context"
9+
810
"xorm.io/xorm"
911
)
1012

@@ -40,8 +42,17 @@ func convertTaskTypeToString(x *xorm.Engine) error {
4042
return err
4143
}
4244

45+
// to keep the migration could be rerun
46+
exist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "hook_task", "type")
47+
if err != nil {
48+
return err
49+
}
50+
if !exist {
51+
return nil
52+
}
53+
4354
for i, s := range hookTaskTypes {
44-
if _, err := x.Exec("UPDATE hook_task set typ = ? where type=?", s, i); err != nil {
55+
if _, err := x.Exec("UPDATE hook_task set typ = ? where `type`=?", s, i); err != nil {
4556
return err
4657
}
4758
}

0 commit comments

Comments
 (0)