From f1fdd782d57ddbd2a759dad2843ee619709a4609 Mon Sep 17 00:00:00 2001 From: guillep2k <18600385+guillep2k@users.noreply.github.com> Date: Sat, 12 Oct 2019 01:55:07 -0300 Subject: [PATCH] Add check for empty set when dropping indexes during migration (#8471) * Add check for empty set when dropping indexes during migration --- models/migrations/migrations.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 1f5b918de8..e14437a04b 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -404,9 +404,11 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin } for _, index := range res { indexName := index["column_name"] - _, err := sess.Exec(fmt.Sprintf("DROP INDEX `%s` ON `%s`", indexName, tableName)) - if err != nil { - return err + if len(indexName) > 0 { + _, err := sess.Exec(fmt.Sprintf("DROP INDEX `%s` ON `%s`", indexName, tableName)) + if err != nil { + return err + } } }