Skip to content

Commit 0470b16

Browse files
guillep2klafriks
authored andcommitted
Add migration step to remove old repo_indexer_status orphaned records (#7746)
* Add migration step to remove old repo_indexer_status orphaned records * Include RepoIndexerStatus struct definition in the migrate function * Change .Delete(o) into ID(o.ID).Delete(new(RepoIndexerStatus)) * Simplification of the delete procedure * Rename v91.go to v92.go
1 parent 4328d8e commit 0470b16

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ var migrations = []Migration{
238238
NewMigration("change length of some repository columns", changeSomeColumnsLengthOfRepo),
239239
// v91 -> v92
240240
NewMigration("add index on owner_id of repository and type, review_id of comment", addIndexOnRepositoryAndComment),
241+
// v92 -> v93
242+
NewMigration("remove orphaned repository index statuses", removeLingeringIndexStatus),
241243
}
242244

243245
// Migrate database to current version

models/migrations/v92.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"github.com/go-xorm/xorm"
9+
"xorm.io/builder"
10+
)
11+
12+
func removeLingeringIndexStatus(x *xorm.Engine) error {
13+
14+
_, err := x.Exec(builder.Delete(builder.NotIn("`repo_id`", builder.Select("`id`").From("`repository`"))).From("`repo_indexer_status`"))
15+
return err
16+
}

0 commit comments

Comments
 (0)