diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2019-04-24 18:43:38 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-04-24 20:43:38 +0300 |
commit | 821184c20357f32cc8eea6a02443f66f02461da1 (patch) | |
tree | ea0906f5d3242276a7eed1afd2d9e9d477bcbe77 | |
parent | 1d8b521ae1fc22a114c1aa0ad5ef4d5d26011c7c (diff) | |
download | gitea-821184c20357f32cc8eea6a02443f66f02461da1.tar.gz gitea-821184c20357f32cc8eea6a02443f66f02461da1.zip |
Drop is_bare IDX only when it exists for MySQL and MariaDB (#6736)
* Drop is_bare IDX only when it exists
* show indexes only on mysql or mariadb
-rw-r--r-- | models/migrations/v78.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/models/migrations/v78.go b/models/migrations/v78.go index 382fd9e795..b0c7bfb6e3 100644 --- a/models/migrations/v78.go +++ b/models/migrations/v78.go @@ -33,9 +33,19 @@ func renameRepoIsBareToIsEmpty(x *xorm.Engine) error { _, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare") } else if models.DbCfg.Type == core.MSSQL { _, err = sess.Exec("DROP INDEX IF EXISTS IDX_repository_is_bare ON repository") + } else if models.DbCfg.Type == core.MYSQL { + indexes, err := sess.QueryString(`SHOW INDEX FROM repository WHERE KEY_NAME = 'IDX_repository_is_bare'`) + if err != nil { + return err + } + + if len(indexes) >= 1 { + _, err = sess.Exec("DROP INDEX IDX_repository_is_bare ON repository") + } } else { _, err = sess.Exec("DROP INDEX IDX_repository_is_bare ON repository") } + if err != nil { return fmt.Errorf("Drop index failed: %v", err) } |