summaryrefslogtreecommitdiffstats
path: root/models/migrations/v174.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 /models/migrations/v174.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 'models/migrations/v174.go')
-rw-r--r--models/migrations/v174.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/models/migrations/v174.go b/models/migrations/v174.go
index ce337df2b3..5915d3626b 100644
--- a/models/migrations/v174.go
+++ b/models/migrations/v174.go
@@ -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()
}