diff options
author | zeripath <art27@cantab.net> | 2020-08-06 19:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 19:16:49 +0100 |
commit | e17e3f71f4e7d2b5e0eac3a55f1b143f2d5a667e (patch) | |
tree | 4e2a31241f35b6a00c1e6dedc89eb39ad5476b79 /models/migrations/migrations.go | |
parent | 8cd7e93b9a48ff09bd88f1bdae82bd36bb431b1b (diff) | |
download | gitea-e17e3f71f4e7d2b5e0eac3a55f1b143f2d5a667e.tar.gz gitea-e17e3f71f4e7d2b5e0eac3a55f1b143f2d5a667e.zip |
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
Diffstat (limited to 'models/migrations/migrations.go')
-rw-r--r-- | models/migrations/migrations.go | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 119b508bfd..834ac3bd68 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -453,20 +453,16 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin tableName, strings.Replace(cols, "`", "'", -1)) constraints := make([]string, 0) if err := sess.SQL(sql).Find(&constraints); err != nil { - sess.Rollback() return fmt.Errorf("Find constraints: %v", err) } for _, constraint := range constraints { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP CONSTRAINT `%s`", tableName, constraint)); err != nil { - sess.Rollback() return fmt.Errorf("Drop table `%s` constraint `%s`: %v", tableName, constraint, err) } } if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP COLUMN %s", tableName, cols)); err != nil { - sess.Rollback() return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) } - return sess.Commit() default: log.Fatal("Unrecognized DB") } |