From e1d3fd5df6b1698a2ccb46833c39df710e81524c Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 20:07:02 +0700 Subject: [PATCH 1/7] hotfix: Fix import from loaded state --- pkg/resource/tables/compare.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/resource/tables/compare.go b/pkg/resource/tables/compare.go index 95aa9b4a..6f39707f 100644 --- a/pkg/resource/tables/compare.go +++ b/pkg/resource/tables/compare.go @@ -103,6 +103,9 @@ func CompareItem(source, target objects.Table) (diffResult CompareDiffResult) { if len(updateItem.ChangeItems) == 0 && len(updateItem.ChangeColumnItems) == 0 && len(updateItem.ChangeRelationItems) == 0 { diffResult.IsConflict = false } else { + Logger.Debug("changeItems", "conflict-check", updateItem.ChangeItems) + Logger.Debug("changeColumnItems", "conflict-check", updateItem.ChangeColumnItems) + Logger.Debug("changeRelationItems", "conflict-check", updateItem.ChangeRelationItems) diffResult.IsConflict = true } From ed965129a5d5e1d846b72add5f05e85b536c1d61 Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 20:36:15 +0700 Subject: [PATCH 2/7] fix: always set search path with equal sign --- rpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc.go b/rpc.go index ae5e13e8..5aa7f137 100644 --- a/rpc.go +++ b/rpc.go @@ -492,7 +492,7 @@ func (r *RpcBase) SetCompleteStmt(stmt string) { } func (r *RpcBase) GetCompleteStmt() string { - return r.CompleteStatement + return strings.replace(r.CompleteStatement, "search_path to ", "search_path = ") } // ----- Rpc Param Functionality ----- From 518e2fe1c660ba3dfca8bb5c4dbb0b10ea75d93a Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 20:37:52 +0700 Subject: [PATCH 3/7] fix: always set search path with equal sign --- rpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc.go b/rpc.go index 5aa7f137..cb5aa7ce 100644 --- a/rpc.go +++ b/rpc.go @@ -492,7 +492,7 @@ func (r *RpcBase) SetCompleteStmt(stmt string) { } func (r *RpcBase) GetCompleteStmt() string { - return strings.replace(r.CompleteStatement, "search_path to ", "search_path = ") + return strings.ReplaceAll(r.CompleteStatement, "search_path to ", "search_path = ") } // ----- Rpc Param Functionality ----- From 4071a3b6ce9a8a4bc3aa4c9b9c1f577646cef7f2 Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 20:48:35 +0700 Subject: [PATCH 4/7] feat: add debug point --- pkg/resource/common.go | 1 + pkg/resource/rpc/compare.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/resource/common.go b/pkg/resource/common.go index c9fc134b..0e4db44f 100644 --- a/pkg/resource/common.go +++ b/pkg/resource/common.go @@ -122,6 +122,7 @@ func filterFunctionBySchema(input []objects.Function, allowedSchema ...string) ( t := input[i] if _, exist := mapSchema[t.Schema]; exist { + ImportLogger.Debug("spFunction", "append", t) output = append(output, t) } } diff --git a/pkg/resource/rpc/compare.go b/pkg/resource/rpc/compare.go index 9f0cc919..dc0452d9 100644 --- a/pkg/resource/rpc/compare.go +++ b/pkg/resource/rpc/compare.go @@ -27,10 +27,12 @@ func CompareList(sourceFn []objects.Function, targetFn []objects.Function) (diff for i := range targetFn { f := targetFn[i] mapTargetFn[f.Name] = f + Logger.Debug("TargetFn", "target-name", f) } for i := range sourceFn { s := sourceFn[i] + Logger.Debug("SourceFn", "source-name", s) t, isExist := mapTargetFn[s.Name] if !isExist { From 0298579a4d5babae36d1bfe4b3145436e0af4ac6 Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 21:01:32 +0700 Subject: [PATCH 5/7] fix: always set search path with equal sign --- pkg/resource/rpc/compare.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/resource/rpc/compare.go b/pkg/resource/rpc/compare.go index dc0452d9..642d2f3d 100644 --- a/pkg/resource/rpc/compare.go +++ b/pkg/resource/rpc/compare.go @@ -32,6 +32,7 @@ func CompareList(sourceFn []objects.Function, targetFn []objects.Function) (diff for i := range sourceFn { s := sourceFn[i] + s.CompleteStatement = strings.ReplaceAll(s.CompleteStatement, "search_path TO", "SET search_path =") Logger.Debug("SourceFn", "source-name", s) t, isExist := mapTargetFn[s.Name] From ca9ae728269d9181382c2fe27fdd888a4c05abf6 Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 21:03:01 +0700 Subject: [PATCH 6/7] fix: always set search path with equal sign --- pkg/resource/rpc/compare.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/resource/rpc/compare.go b/pkg/resource/rpc/compare.go index 642d2f3d..e6896f3e 100644 --- a/pkg/resource/rpc/compare.go +++ b/pkg/resource/rpc/compare.go @@ -32,7 +32,7 @@ func CompareList(sourceFn []objects.Function, targetFn []objects.Function) (diff for i := range sourceFn { s := sourceFn[i] - s.CompleteStatement = strings.ReplaceAll(s.CompleteStatement, "search_path TO", "SET search_path =") + s.CompleteStatement = strings.ReplaceAll(s.CompleteStatement, "search_path TO", "search_path =") Logger.Debug("SourceFn", "source-name", s) t, isExist := mapTargetFn[s.Name] From 1acb72f60dd85f82f8dee5c7e6ecd0919f647f70 Mon Sep 17 00:00:00 2001 From: Taufan Adhitya Date: Fri, 13 Sep 2024 21:07:14 +0700 Subject: [PATCH 7/7] feat: de-escalate constraint name update event to debug --- pkg/resource/tables/compare.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/resource/tables/compare.go b/pkg/resource/tables/compare.go index 6f39707f..6a864875 100644 --- a/pkg/resource/tables/compare.go +++ b/pkg/resource/tables/compare.go @@ -225,7 +225,7 @@ func compareRelations(table *objects.Table, source, target []objects.TablesRelat } if !strings.HasPrefix(sc.ConstraintName, fmt.Sprintf("%s_", sc.SourceSchema)) { - Logger.Info("constrain name update", "from", sc.ConstraintName, "to", fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName)) + Logger.Debug("constrain name update", "from", sc.ConstraintName, "to", fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName)) sc.ConstraintName = fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName) }