diff options
author | guillep2k | 2019-10-12 02:31:12 -0300 |
---|---|---|
committer | zeripath | 2019-10-12 06:31:12 +0100 |
commit | 80b50afe1ff7dffba2d305c37f4ee86c041e16ea (patch) | |
tree | de2c6ee82b61f63c17c351134f6de18a86f203cb | |
parent | 20a28b785a3752980348cda1c88d99afa4b7dac3 (diff) |
Add check for empty set when dropping indexes during migration (#8475)
-rw-r--r-- | models/migrations/migrations.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 00356ffac..24aa7c571 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -384,9 +384,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 + } } } |