Skip to content

Commit

Permalink
Drop is_bare IDX only when it exists for MySQL and MariaDB (#6736) (#…
Browse files Browse the repository at this point in the history
…6744)

* Drop is_bare IDX only when it exists

* show indexes only on mysql or mariadb
  • Loading branch information
adelowo authored and zeripath committed Apr 24, 2019
1 parent 5f6b118 commit 26c1550
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions models/migrations/v78.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 26c1550

Please sign in to comment.