Delete Labels & IssueLabels on Repo Delete too (#15039)

* Doctor: find IssueLabels without existing label

* on Repo Delete: delete labels & issue_labels too

* performance nits

* Add Migration: Delete orphaned IssueLabels

* Migration v174: use Sync2

* USE sess !!!

* better func name

* code format & comment

* RAW SQL

* Update models/migrations/v176.go

* next try?
This commit is contained in:
6543 2021-03-19 20:01:24 +01:00 committed by GitHub
parent dace0ce1b1
commit a3a65137ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 9 deletions

View file

@ -5,6 +5,8 @@
package migrations
import (
"fmt"
"xorm.io/xorm"
)
@ -19,5 +21,15 @@ func addRepoTransfer(x *xorm.Engine) error {
UpdatedUnix int64 `xorm:"INDEX NOT NULL updated"`
}
return x.Sync(new(RepoTransfer))
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}
if err := sess.Sync2(new(RepoTransfer)); err != nil {
return fmt.Errorf("Sync2: %v", err)
}
return sess.Commit()
}