Compare commits

..

2 Commits

Author SHA1 Message Date
Lunny Xiao
cf217befb0 Fix database keyword quote problem on migration v161 (#17524)
* Fix database keyword quote problem on migration v161

* support rerun migration v161
2021-11-03 08:28:21 +08:00
6543
f8503b5fbf Fix bug of migrated repository not index (#16991) (#16995)
Fix #16986, #16152

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-08 22:32:54 +01:00
2 changed files with 14 additions and 4 deletions

View File

@@ -5,6 +5,8 @@
package migrations package migrations
import ( import (
"context"
"xorm.io/xorm" "xorm.io/xorm"
) )
@@ -40,8 +42,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
} }
} }

View File

@@ -92,7 +92,6 @@ func runMigrateTask(t *models.Task) (err error) {
} }
opts.MigrateToRepoID = t.RepoID opts.MigrateToRepoID = t.RepoID
var repo *models.Repository
ctx, cancel := context.WithCancel(graceful.GetManager().ShutdownContext()) ctx, cancel := context.WithCancel(graceful.GetManager().ShutdownContext())
defer cancel() defer cancel()
@@ -106,9 +105,9 @@ func runMigrateTask(t *models.Task) (err error) {
return return
} }
repo, err = migrations.MigrateRepository(ctx, t.Doer, t.Owner.Name, *opts) t.Repo, err = migrations.MigrateRepository(ctx, t.Doer, t.Owner.Name, *opts)
if err == nil { if err == nil {
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, t.Owner.Name, repo.Name) log.Trace("Repository migrated [%d]: %s/%s", t.Repo.ID, t.Owner.Name, t.Repo.Name)
return return
} }