From a3a65137ba89267b5145825b21bb90257ee9f2f0 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 19 Mar 2021 20:01:24 +0100 Subject: 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? --- models/migrations/v174.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'models/migrations/v174.go') 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() } -- cgit v1.2.3