* Fix database keyword quote problem on migration v161
* support rerun migration v161
package migrations
import (
+ "context"
+
"xorm.io/xorm"
)
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
}
}