diff --git a/integrations/migration-test/gitea-v1.5.3.mssql.sql.gz b/integrations/migration-test/gitea-v1.5.3.mssql.sql.gz new file mode 100644 index 000000000000..90c1674066e5 Binary files /dev/null and b/integrations/migration-test/gitea-v1.5.3.mssql.sql.gz differ diff --git a/integrations/migration-test/gitea-v1.6.4.mssql.sql.gz b/integrations/migration-test/gitea-v1.6.4.mssql.sql.gz new file mode 100644 index 000000000000..1f43e2e64302 Binary files /dev/null and b/integrations/migration-test/gitea-v1.6.4.mssql.sql.gz differ diff --git a/integrations/migration-test/gitea-v1.7.0.mssql.sql.gz b/integrations/migration-test/gitea-v1.7.0.mssql.sql.gz new file mode 100644 index 000000000000..87499d2ac800 Binary files /dev/null and b/integrations/migration-test/gitea-v1.7.0.mssql.sql.gz differ diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go index fafe0fe225af..f16842486520 100644 --- a/integrations/migration-test/migration_test.go +++ b/integrations/migration-test/migration_test.go @@ -13,6 +13,7 @@ import ( "path" "regexp" "sort" + "strings" "testing" "code.gitea.io/gitea/integrations" @@ -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 { @@ -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 diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index b86c20576f7e..f3a090e41c17 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -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) }