summaryrefslogtreecommitdiffstats
path: root/integrations/migration-test
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-07-26 05:10:20 +0100
committerGitHub <noreply@github.com>2019-07-26 05:10:20 +0100
commit78e531724223158839b8f82c1f414efee3f9dc9b (patch)
tree9dc59db82795983b2cdc09150d1207aa2703f80b /integrations/migration-test
parentbebc6a3c77de159c7293464baad5b8cb5aee7700 (diff)
downloadgitea-78e531724223158839b8f82c1f414efee3f9dc9b.tar.gz
gitea-78e531724223158839b8f82c1f414efee3f9dc9b.zip
Update to latest mssqldriver (#7613)
* New driver does not tolerate USE - handle this by closing db and reopening db in the new dbname
Diffstat (limited to 'integrations/migration-test')
-rw-r--r--integrations/migration-test/migration_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go
index 15b086c6e6..fd0d0b7c72 100644
--- a/integrations/migration-test/migration_test.go
+++ b/integrations/migration-test/migration_test.go
@@ -181,11 +181,19 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
defer db.Close()
- _, err = db.Exec("DROP DATABASE IF EXISTS gitea")
+ _, err = db.Exec("DROP DATABASE IF EXISTS [gitea]")
assert.NoError(t, err)
statements := strings.Split(data, "\nGO\n")
for _, statement := range statements {
+ if len(statement) > 5 && statement[:5] == "USE [" {
+ dbname := statement[5 : len(statement)-1]
+ db.Close()
+ db, err = sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
+ host, port, dbname, models.DbCfg.User, models.DbCfg.Passwd))
+ assert.NoError(t, err)
+ defer db.Close()
+ }
_, err = db.Exec(statement)
assert.NoError(t, err, "Failure whilst running: %s\nError: %v", statement, err)
}