From c030401af46e056dc1e05ccb2ab167f4ff29dbe7 Mon Sep 17 00:00:00 2001 From: NirnayaSindhuSuthari Date: Thu, 25 Jul 2024 02:05:40 +0000 Subject: [PATCH 1/4] Warning for unsupported default values in Issues and Suggestions --- internal/reports/report_helpers.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/reports/report_helpers.go b/internal/reports/report_helpers.go index 5e20289b9..6c352a943 100644 --- a/internal/reports/report_helpers.go +++ b/internal/reports/report_helpers.go @@ -112,6 +112,17 @@ func buildTableReportBody(conv *internal.Conv, tableId string, issues map[string } if p.severity == warning { + for _, colName := range colNames { + colId, _ := internal.GetColIdFromSpName(conv.SpSchema[tableId].ColDefs, colName) + if !conv.SpSchema[tableId].ColDefs[colId].DefaultValue.IsPresent { + issue := internal.DefaultValue + toAppend := Issue{ + Category: IssueDB[issue].Category, + Description: fmt.Sprintf("%s for table '%s' e.g. column '%s'", IssueDB[issue].Brief, conv.SpSchema[tableId].Name, colName), + } + l = append(l, toAppend) + } + } flag := false for _, spFk := range conv.SpSchema[tableId].ForeignKeys { srcFk, err := internal.GetSrcFkFromId(conv.SrcSchema[tableId].ForeignKeys, spFk.Id) @@ -213,12 +224,6 @@ func buildTableReportBody(conv *internal.Conv, tableId string, issues map[string // on case of srcType. spColType = strings.ToLower(spColType) switch i { - case internal.DefaultValue: - toAppend := Issue{ - Category: IssueDB[i].Category, - Description: fmt.Sprintf("%s for table '%s' e.g. column '%s'", IssueDB[i].Brief, conv.SpSchema[tableId].Name, spColName), - } - l = append(l, toAppend) case internal.ForeignKey: toAppend := Issue{ Category: IssueDB[i].Category, @@ -514,7 +519,7 @@ var IssueDB = map[internal.SchemaIssue]struct { Category string // Standarized issue type CategoryDescription string }{ - internal.DefaultValue: {Brief: "Some columns have default values which Spanner migration tool does not migrate. Please add the default constraints manually after the migration is complete", Severity: note, batch: true, Category: "MISSING_DEFAULT_VALUE_CONSTRAINTS"}, + internal.DefaultValue: {Brief: "Some columns have default values which Spanner migration tool does not migrate. Please add the default constraints manually after the migration is complete", Severity: warning, batch: true, Category: "MISSING_DEFAULT_VALUE_CONSTRAINTS"}, internal.ForeignKey: {Brief: "Spanner does not support foreign keys", Severity: warning, Category: "FOREIGN_KEY_USES"}, internal.MultiDimensionalArray: {Brief: "Spanner doesn't support multi-dimensional arrays", Severity: warning, Category: "MULTI_DIMENSIONAL_ARRAY_USES"}, internal.NoGoodType: {Brief: "No appropriate Spanner type. The column will be made nullable in Spanner", Severity: warning, Category: "INAPPROPRIATE_TYPE", From abee5492bb07298b8ce3b50bf88b3bfc481b34b8 Mon Sep 17 00:00:00 2001 From: NirnayaSindhuSuthari Date: Thu, 25 Jul 2024 02:18:01 +0000 Subject: [PATCH 2/4] warning condition corrected --- internal/reports/report_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/reports/report_helpers.go b/internal/reports/report_helpers.go index 6c352a943..29ba713f1 100644 --- a/internal/reports/report_helpers.go +++ b/internal/reports/report_helpers.go @@ -114,7 +114,7 @@ func buildTableReportBody(conv *internal.Conv, tableId string, issues map[string if p.severity == warning { for _, colName := range colNames { colId, _ := internal.GetColIdFromSpName(conv.SpSchema[tableId].ColDefs, colName) - if !conv.SpSchema[tableId].ColDefs[colId].DefaultValue.IsPresent { + if !conv.SpSchema[tableId].ColDefs[colId].DefaultValue.IsPresent && conv.SpSchema[tableId].ColDefs[colId].DefaultValue.Value != "" { issue := internal.DefaultValue toAppend := Issue{ Category: IssueDB[issue].Category, From 72a9cf84b0e6fac69872f8a6706b17f3db671ac5 Mon Sep 17 00:00:00 2001 From: NirnayaSindhuSuthari Date: Thu, 25 Jul 2024 02:24:33 +0000 Subject: [PATCH 3/4] removed default values from ignored issues --- sources/common/toddl.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/sources/common/toddl.go b/sources/common/toddl.go index 1a6910006..c17f47074 100644 --- a/sources/common/toddl.go +++ b/sources/common/toddl.go @@ -110,9 +110,6 @@ func (ss *SchemaToSpannerImpl) SchemaToSpannerDDLHelper(conv *internal.Conv, tod if isChanged && (srcCol.Name != colName) { issues = append(issues, internal.IllegalName) } - if srcCol.Ignored.Default { - issues = append(issues, internal.DefaultValue) - } if srcCol.Ignored.AutoIncrement { //TODO(adibh) - check why this is not there in postgres issues = append(issues, internal.AutoIncrement) } From b2fa3e252eadf709fc427cede0885a65253f3bd4 Mon Sep 17 00:00:00 2001 From: NirnayaSindhuSuthari Date: Tue, 6 Aug 2024 14:22:05 +0000 Subject: [PATCH 4/4] warning for unsupported spanner default value --- internal/reports/report_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/reports/report_helpers.go b/internal/reports/report_helpers.go index 29ba713f1..06ce8b8c5 100644 --- a/internal/reports/report_helpers.go +++ b/internal/reports/report_helpers.go @@ -114,7 +114,7 @@ func buildTableReportBody(conv *internal.Conv, tableId string, issues map[string if p.severity == warning { for _, colName := range colNames { colId, _ := internal.GetColIdFromSpName(conv.SpSchema[tableId].ColDefs, colName) - if !conv.SpSchema[tableId].ColDefs[colId].DefaultValue.IsPresent && conv.SpSchema[tableId].ColDefs[colId].DefaultValue.Value != "" { + if srcSchema.ColDefs[colId].DefaultValue.IsPresent && !spSchema.ColDefs[colId].DefaultValue.IsPresent { issue := internal.DefaultValue toAppend := Issue{ Category: IssueDB[issue].Category,