Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop is_bare IDX only when it exists for MySQL and MariaDB #6736

Merged
merged 4 commits into from
Apr 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'`)
lafriks marked this conversation as resolved.
Show resolved Hide resolved
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