Backport purgeUnusedDependencies
This commit is contained in:
parent
3187cb5df5
commit
d405da12be
@ -300,7 +300,10 @@ var migrations = []Migration{
|
||||
// minor revision and when the actual migration is executed again on the next major upgrade).
|
||||
// * The function must not rely on data structures that might not be present in the branch
|
||||
// it is backported to, unless its safe that it will add the column itself.
|
||||
var backports = []Migration{}
|
||||
var backports = []Migration{
|
||||
// v117 -> v117.1
|
||||
NewMigration("remove dependencies from deleted repositories", purgeUnusedDependencies),
|
||||
}
|
||||
|
||||
// Migrate database to current version
|
||||
func Migrate(x *xorm.Engine) error {
|
||||
|
18
models/migrations/v117.1.go
Normal file
18
models/migrations/v117.1.go
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func purgeUnusedDependencies(x *xorm.Engine) error {
|
||||
|
||||
if _, err := x.Exec("DELETE FROM issue_dependency WHERE issue_id NOT IN (SELECT id FROM issue)"); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := x.Exec("DELETE FROM issue_dependency WHERE dependency_id NOT IN (SELECT id FROM issue)")
|
||||
return err
|
||||
}
|
Loading…
Reference in New Issue
Block a user