diff options
Diffstat (limited to 'integrations/migration-test')
-rw-r--r-- | integrations/migration-test/gitea-v1.5.3.postgres.sql.gz | bin | 16612 -> 16783 bytes | |||
-rw-r--r-- | integrations/migration-test/gitea-v1.6.4.postgres.sql.gz | bin | 17346 -> 17517 bytes | |||
-rw-r--r-- | integrations/migration-test/gitea-v1.7.0.postgres.sql.gz | bin | 17659 -> 17831 bytes | |||
-rw-r--r-- | integrations/migration-test/migration_test.go | 26 |
4 files changed, 26 insertions, 0 deletions
diff --git a/integrations/migration-test/gitea-v1.5.3.postgres.sql.gz b/integrations/migration-test/gitea-v1.5.3.postgres.sql.gz Binary files differindex 2fcad82111..2380f8dd7f 100644 --- a/integrations/migration-test/gitea-v1.5.3.postgres.sql.gz +++ b/integrations/migration-test/gitea-v1.5.3.postgres.sql.gz diff --git a/integrations/migration-test/gitea-v1.6.4.postgres.sql.gz b/integrations/migration-test/gitea-v1.6.4.postgres.sql.gz Binary files differindex 8db9022d1c..bd66f6ba4f 100644 --- a/integrations/migration-test/gitea-v1.6.4.postgres.sql.gz +++ b/integrations/migration-test/gitea-v1.6.4.postgres.sql.gz diff --git a/integrations/migration-test/gitea-v1.7.0.postgres.sql.gz b/integrations/migration-test/gitea-v1.7.0.postgres.sql.gz Binary files differindex ed66d41b89..e4716c6b43 100644 --- a/integrations/migration-test/gitea-v1.7.0.postgres.sql.gz +++ b/integrations/migration-test/gitea-v1.7.0.postgres.sql.gz diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go index c274d482da..6cdfbf7d7d 100644 --- a/integrations/migration-test/migration_test.go +++ b/integrations/migration-test/migration_test.go @@ -168,6 +168,32 @@ func restoreOldDB(t *testing.T, version string) bool { assert.NoError(t, err) db.Close() + // Check if we need to setup a specific schema + if len(setting.Database.Schema) != 0 { + db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", + setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) + if !assert.NoError(t, err) { + return false + } + schrows, err := db.Query(fmt.Sprintf("SELECT 1 FROM information_schema.schemata WHERE schema_name = '%s'", setting.Database.Schema)) + if !assert.NoError(t, err) || !assert.NotEmpty(t, schrows) { + return false + } + + if !schrows.Next() { + // Create and setup a DB schema + _, err = db.Exec(fmt.Sprintf("CREATE SCHEMA %s", setting.Database.Schema)) + assert.NoError(t, err) + } + schrows.Close() + + // Make the user's default search path the created schema; this will affect new connections + _, err = db.Exec(fmt.Sprintf(`ALTER USER "%s" SET search_path = %s`, setting.Database.User, setting.Database.Schema)) + assert.NoError(t, err) + + db.Close() + } + db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode)) assert.NoError(t, err) |