diff options
author | 6543 <6543@obermui.de> | 2021-03-19 20:01:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 21:01:24 +0200 |
commit | a3a65137ba89267b5145825b21bb90257ee9f2f0 (patch) | |
tree | 21ee8477706d9f7d7a0f35185e83aa86bfa6d61d /models/issue_label.go | |
parent | dace0ce1b191d060976bac08f181ca768fc027a0 (diff) | |
download | gitea-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 'models/issue_label.go')
-rw-r--r-- | models/issue_label.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/models/issue_label.go b/models/issue_label.go index e377ebf4e7..4f082b8a6e 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -780,3 +780,15 @@ func DeleteIssueLabel(issue *Issue, label *Label, doer *User) (err error) { return sess.Commit() } + +func deleteLabelsByRepoID(sess Engine, repoID int64) error { + deleteCond := builder.Select("id").From("label").Where(builder.Eq{"label.repo_id": repoID}) + + if _, err := sess.In("label_id", deleteCond). + Delete(&IssueLabel{}); err != nil { + return err + } + + _, err := sess.Delete(&Label{RepoID: repoID}) + return err +} |