Skip to content

Commit

Permalink
Add check for empty set when dropping indexes during migration (#8471)
Browse files Browse the repository at this point in the history
* Add check for empty set when dropping indexes during migration
  • Loading branch information
guillep2k authored and zeripath committed Oct 12, 2019
1 parent 5e759b6 commit f1fdd78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit f1fdd78

Please sign in to comment.