From df5456adc07c680ac325cd268385bbcf98be5e8e Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Wed, 26 Apr 2023 22:37:27 +0200 Subject: [PATCH] Fix table_schema check for postgres (#4724) --- server/services/store/sqlstore/schema_table_migration.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/services/store/sqlstore/schema_table_migration.go b/server/services/store/sqlstore/schema_table_migration.go index 2ab075658..1347fd986 100644 --- a/server/services/store/sqlstore/schema_table_migration.go +++ b/server/services/store/sqlstore/schema_table_migration.go @@ -123,6 +123,13 @@ func (s *SQLStore) isSchemaMigrationNeeded() (bool, error) { "TABLE_NAME": s.tablePrefix + "schema_migrations", }) + switch s.dbType { + case model.MysqlDBType: + query = query.Where(sq.Eq{"TABLE_SCHEMA": s.schemaName}) + case model.PostgresDBType: + query = query.Where("table_schema = current_schema()") + } + rows, err := query.Query() if err != nil { s.logger.Error("failed to fetch columns in schema_migrations table", mlog.Err(err))