From e17e3f71f4e7d2b5e0eac3a55f1b143f2d5a667e Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 6 Aug 2020 19:16:49 +0100 Subject: Use transaction in V102 migration (#12395) The code for dropTableColumns has a slightly confusing portion whereby the session is committed for MSSQL but not for other variants. The v102 migration doesn't actually start a transaction so this weirdness does not affect it. However it probably should attempt to run this in a transaction. Signed-off-by: Andrew Thornton art27@cantab.net --- models/migrations/v102.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'models/migrations/v102.go') diff --git a/models/migrations/v102.go b/models/migrations/v102.go index 74e8574ec3..03079d0bb4 100644 --- a/models/migrations/v102.go +++ b/models/migrations/v102.go @@ -11,5 +11,11 @@ import ( func dropColumnHeadUserNameOnPullRequest(x *xorm.Engine) error { sess := x.NewSession() defer sess.Close() - return dropTableColumns(sess, "pull_request", "head_user_name") + if err := sess.Begin(); err != nil { + return err + } + if err := dropTableColumns(sess, "pull_request", "head_user_name"); err != nil { + return err + } + return sess.Commit() } -- cgit v1.2.3