From d021430d77e5e0ad876b1dec2ae05bced2bfe9af Mon Sep 17 00:00:00 2001 From: Peter Grlica Date: Tue, 14 Feb 2023 16:49:27 +0100 Subject: [PATCH] Fix id column migrate for views Change only id columns of tables, not views, as postgres does not allow changing those. --- server/store/adapters/rdbms/upgrade_fixes.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/store/adapters/rdbms/upgrade_fixes.go b/server/store/adapters/rdbms/upgrade_fixes.go index e75a32b55..542d24847 100644 --- a/server/store/adapters/rdbms/upgrade_fixes.go +++ b/server/store/adapters/rdbms/upgrade_fixes.go @@ -5,6 +5,10 @@ import ( "database/sql" "encoding/json" "fmt" + "os" + "strings" + "time" + "github.com/cortezaproject/corteza/server/compose/model" "github.com/cortezaproject/corteza/server/compose/types" discovery "github.com/cortezaproject/corteza/server/discovery/types" @@ -17,9 +21,6 @@ import ( "github.com/doug-martin/goqu/v9/exp" "github.com/spf13/cast" "go.uber.org/zap" - "os" - "strings" - "time" ) // RDBMS database fixes @@ -616,9 +617,12 @@ func fix_2022_09_07_changePostgresIdColumnsDatatype(ctx context.Context, s *Stor return } + log := s.log(ctx) + log.Info("changing postgres ID columns") + tnames := tableNames() tnamesQry := `SELECT table_name FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name = 'id' AND - table_name IN('` + strings.Join(tnames, "', '") + `') AND table_name NOT LIKE 'auth_sessions'` + table_name IN('` + strings.Join(tnames, "', '") + `') AND table_name NOT LIKE 'auth_sessions' AND is_updatable = 'YES'` rows, err := s.DB.QueryContext(ctx, tnamesQry) if err != nil {