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:
parent
dace0ce1b1
commit
a3a65137ba
7 changed files with 116 additions and 9 deletions
|
@ -26,7 +26,6 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
|
|||
logger.Critical("Error: %v whilst counting orphaned labels")
|
||||
return err
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
if autofix {
|
||||
if err = models.DeleteOrphanedLabels(); err != nil {
|
||||
|
@ -39,6 +38,24 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
// find IssueLabels without existing label
|
||||
count, err = models.CountOrphanedIssueLabels()
|
||||
if err != nil {
|
||||
logger.Critical("Error: %v whilst counting orphaned issue_labels")
|
||||
return err
|
||||
}
|
||||
if count > 0 {
|
||||
if autofix {
|
||||
if err = models.DeleteOrphanedIssueLabels(); err != nil {
|
||||
logger.Critical("Error: %v whilst deleting orphaned issue_labels")
|
||||
return err
|
||||
}
|
||||
logger.Info("%d issue_labels without existing label deleted", count)
|
||||
} else {
|
||||
logger.Warn("%d issue_labels without existing label", count)
|
||||
}
|
||||
}
|
||||
|
||||
// find issues without existing repository
|
||||
count, err = models.CountOrphanedIssues()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue