Skip to content

Add mssql migration tests (needs #6823) #6852

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

Merged
merged 4 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 7 additions & 7 deletions integrations/migration-test/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path"
"regexp"
"sort"
"strings"
"testing"

"code.gitea.io/gitea/integrations"
Expand Down Expand Up @@ -120,8 +121,7 @@ func readSQLFromFile(version string) (string, error) {
if err != nil {
return "", err
}

return string(bytes), nil
return string(base.RemoveBOMIfPresent(bytes)), nil
}

func restoreOldDB(t *testing.T, version string) bool {
Expand Down Expand Up @@ -199,11 +199,11 @@ func restoreOldDB(t *testing.T, version string) bool {
_, err = db.Exec("DROP DATABASE IF EXISTS gitea")
assert.NoError(t, err)

_, err = db.Exec("CREATE DATABASE gitea")
assert.NoError(t, err)

_, err = db.Exec(data)
assert.NoError(t, err)
statements := strings.Split(data, "\nGO\n")
for _, statement := range statements {
_, err = db.Exec(statement)
assert.NoError(t, err, "Failure whilst running: %s\nError: %v", statement, err)
}
db.Close()
}
return true
Expand Down
2 changes: 1 addition & 1 deletion models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to curr
return err
}
for i, m := range migrations[v-minDBVersion:] {
log.Info("Migration: %s", m.Description())
log.Info("Migration[%d]: %s", v+int64(i), m.Description())
if err = m.Migrate(x); err != nil {
return fmt.Errorf("do migrate: %v", err)
}
Expand Down