summaryrefslogtreecommitdiffstats
path: root/modules/doctor/dbconsistency.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-03-19 20:01:24 +0100
committerGitHub <noreply@github.com>2021-03-19 21:01:24 +0200
commita3a65137ba89267b5145825b21bb90257ee9f2f0 (patch)
tree21ee8477706d9f7d7a0f35185e83aa86bfa6d61d /modules/doctor/dbconsistency.go
parentdace0ce1b191d060976bac08f181ca768fc027a0 (diff)
downloadgitea-a3a65137ba89267b5145825b21bb90257ee9f2f0.tar.gz
gitea-a3a65137ba89267b5145825b21bb90257ee9f2f0.zip
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?
Diffstat (limited to 'modules/doctor/dbconsistency.go')
-rw-r--r--modules/doctor/dbconsistency.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/doctor/dbconsistency.go b/modules/doctor/dbconsistency.go
index 83d3dc5fe2..8c960cb4a8 100644
--- a/modules/doctor/dbconsistency.go
+++ b/modules/doctor/dbconsistency.go
@@ -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 {