From bac60f049f4aa04aafe6a61b3418644bc485b699 Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Tue, 2 May 2023 20:00:34 +0200 Subject: [PATCH] restrict migrate function to the right schema, and not the entire database --- storage/postgresql.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/postgresql.go b/storage/postgresql.go index 77e8042..968be12 100644 --- a/storage/postgresql.go +++ b/storage/postgresql.go @@ -18,6 +18,7 @@ import ( type PostgresqlStorage struct { DbConnection *sql.DB + Schema string Tables map[string]string } @@ -47,6 +48,7 @@ func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error) { } return PostgresqlStorage{ DbConnection: db, + Schema: pg_schema, Tables: map[string]string{ "accounts": fmt.Sprintf("%s.%s", pg_schema, pgtables_accounts), "accounts_auth_local": fmt.Sprintf("%s.%s", pg_schema, pgtables_accounts_auth_local), @@ -426,7 +428,7 @@ func (psql PostgresqlStorage) Migrate() error { return err } - existing, err := driver.InspectRealm(ctx, nil) + existing, err := driver.InspectRealm(ctx, &schema.InspectRealmOption{Schemas: []string{psql.Schema}}) if err != nil { return err }