diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-10-12 01:55:07 -0300 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-12 05:55:07 +0100 |
commit | f1fdd782d57ddbd2a759dad2843ee619709a4609 (patch) | |
tree | 25f312eb220095dc3364240804ee0377765a6ccd /models/migrations | |
parent | 5e759b60cca3cd8484a6235fcc9120d18e8cd455 (diff) | |
download | gitea-f1fdd782d57ddbd2a759dad2843ee619709a4609.tar.gz gitea-f1fdd782d57ddbd2a759dad2843ee619709a4609.zip |
Add check for empty set when dropping indexes during migration (#8471)
* Add check for empty set when dropping indexes during migration
Diffstat (limited to 'models/migrations')
-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 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 + } } } |