diff --git a/yb-voyager/cmd/analyzeSchema.go b/yb-voyager/cmd/analyzeSchema.go index a4dda2b03..d0dc86e9a 100644 --- a/yb-voyager/cmd/analyzeSchema.go +++ b/yb-voyager/cmd/analyzeSchema.go @@ -194,43 +194,34 @@ var ( ) const ( - CONVERSION_ISSUE_REASON = "CREATE CONVERSION is not supported yet" - GIN_INDEX_MULTI_COLUMN_ISSUE_REASON = "Schema contains gin index on multi column which is not supported." - ADDING_PK_TO_PARTITIONED_TABLE_ISSUE_REASON = "Adding primary key to a partitioned table is not supported yet." - INHERITANCE_ISSUE_REASON = "TABLE INHERITANCE not supported in YugabyteDB" - CONSTRAINT_TRIGGER_ISSUE_REASON = "CONSTRAINT TRIGGER not supported yet." - REFERENCING_CLAUSE_FOR_TRIGGERS = "REFERENCING clause (transition tables) not supported yet." - BEFORE_FOR_EACH_ROW_TRIGGERS_ON_PARTITIONED_TABLE = "Partitioned tables cannot have BEFORE / FOR EACH ROW triggers." - COMPOUND_TRIGGER_ISSUE_REASON = "COMPOUND TRIGGER not supported in YugabyteDB." - - STORED_GENERATED_COLUMN_ISSUE_REASON = "Stored generated columns are not supported." - UNSUPPORTED_EXTENSION_ISSUE = "This extension is not supported in YugabyteDB by default." - EXCLUSION_CONSTRAINT_ISSUE = "Exclusion constraint is not supported yet" - ALTER_TABLE_DISABLE_RULE_ISSUE = "ALTER TABLE name DISABLE RULE not supported yet" - STORAGE_PARAMETERS_DDL_STMT_ISSUE = "Storage parameters are not supported yet." - ALTER_TABLE_SET_ATTRIBUTE_ISSUE = "ALTER TABLE .. ALTER COLUMN .. SET ( attribute = value ) not supported yet" - FOREIGN_TABLE_ISSUE_REASON = "Foreign tables require manual intervention." - ALTER_TABLE_CLUSTER_ON_ISSUE = "ALTER TABLE CLUSTER not supported yet." - DEFERRABLE_CONSTRAINT_ISSUE = "DEFERRABLE constraints not supported yet" - POLICY_ROLE_ISSUE = "Policy require roles to be created." - VIEW_CHECK_OPTION_ISSUE = "Schema containing VIEW WITH CHECK OPTION is not supported yet." - ISSUE_INDEX_WITH_COMPLEX_DATATYPES = `INDEX on column '%s' not yet supported` - ISSUE_PK_UK_CONSTRAINT_WITH_COMPLEX_DATATYPES = `Primary key and Unique constraint on column '%s' not yet supported` - ISSUE_UNLOGGED_TABLE = "UNLOGGED tables are not supported yet." + // Issues detected using regexp, reported in assessment and analyze both + CONVERSION_ISSUE_REASON = "CREATE CONVERSION is not supported yet" + UNSUPPORTED_EXTENSION_ISSUE = "This extension is not supported in YugabyteDB by default." + VIEW_CHECK_OPTION_ISSUE = "Schema containing VIEW WITH CHECK OPTION is not supported yet." + + // Refactor: constants below used in some comparisions (use Issue Type there and remove these) + INHERITANCE_ISSUE_REASON = "TABLE INHERITANCE not supported in YugabyteDB" + ADDING_PK_TO_PARTITIONED_TABLE_ISSUE_REASON = "Adding primary key to a partitioned table is not supported yet." + COMPOUND_TRIGGER_ISSUE_REASON = "COMPOUND TRIGGER not supported in YugabyteDB." + STORED_GENERATED_COLUMN_ISSUE_REASON = "Stored generated columns are not supported." + FOREIGN_TABLE_ISSUE_REASON = "Foreign tables require manual intervention." + DEFERRABLE_CONSTRAINT_ISSUE = "DEFERRABLE constraints not supported yet" + POLICY_ROLE_ISSUE = "Policy require roles to be created." + ISSUE_INDEX_WITH_COMPLEX_DATATYPES = `INDEX on column '%s' not yet supported` + INDEX_METHOD_ISSUE_REASON = "Schema contains %s index which is not supported." + UNSUPPORTED_DATATYPE = "Unsupported datatype" UNSUPPORTED_DATATYPE_LIVE_MIGRATION = "Unsupported datatype for Live migration" UNSUPPORTED_DATATYPE_LIVE_MIGRATION_WITH_FF_FB = "Unsupported datatype for Live migration with fall-forward/fallback" UNSUPPORTED_PG_SYNTAX = "Unsupported PG syntax" - INDEX_METHOD_ISSUE_REASON = "Schema contains %s index which is not supported." INSUFFICIENT_COLUMNS_IN_PK_FOR_PARTITION = "insufficient columns in the PRIMARY KEY constraint definition in CREATE TABLE" GIN_INDEX_DETAILS = "There are some GIN indexes present in the schema, but GIN indexes are partially supported in YugabyteDB as mentioned in (https://github.com/yugabyte/yugabyte-db/issues/7850) so take a look and modify them if not supported." - SECURITY_INVOKER_VIEWS_ISSUE = "Security Invoker Views not supported yet" ) // Reports one case in JSON func reportCase(filePath string, reason string, ghIssue string, suggestion string, objType string, objName string, sqlStmt string, issueType string, docsLink string) { - var issue utils.Issue + var issue utils.AnalyzeSchemaIssue issue.FilePath = filePath issue.Reason = reason issue.GH = ghIssue @@ -354,13 +345,6 @@ func checkStmtsUsingParser(sqlInfoArr []sqlInfo, fpath string, objType string) { // Checks compatibility of views func checkViews(sqlInfoArr []sqlInfo, fpath string) { for _, sqlInfo := range sqlInfoArr { - /*if dropMatViewRegex.MatchString(sqlInfo.stmt) { - reportCase(fpath, "DROP MATERIALIZED VIEW not supported yet.",a - "https://github.com/YugaByte/yugabyte-db/issues/10102", "") - } else if view := matViewRegex.FindStringSubmatch(sqlInfo.stmt); view != nil { - reportCase(fpath, "Schema contains materialized view which is not supported. The view is: "+view[1], - "https://github.com/yugabyte/yugabyte-db/issues/10102", "") - } else */ if view := viewWithCheckRegex.FindStringSubmatch(sqlInfo.stmt); view != nil { summaryMap["VIEW"].invalidCount[sqlInfo.objName] = true reportCase(fpath, VIEW_CHECK_OPTION_ISSUE, "https://github.com/yugabyte/yugabyte-db/issues/22716", @@ -635,7 +619,7 @@ var MigrationCaveatsIssues = []string{ UNSUPPORTED_DATATYPE_LIVE_MIGRATION_WITH_FF_FB, } -func convertIssueInstanceToAnalyzeIssue(issueInstance queryissue.QueryIssue, fileName string, isPlPgSQLIssue bool) utils.Issue { +func convertIssueInstanceToAnalyzeIssue(issueInstance queryissue.QueryIssue, fileName string, isPlPgSQLIssue bool) utils.AnalyzeSchemaIssue { issueType := UNSUPPORTED_FEATURES switch true { case isPlPgSQLIssue: @@ -685,7 +669,8 @@ func convertIssueInstanceToAnalyzeIssue(issueInstance queryissue.QueryIssue, fil summaryMap[issueInstance.ObjectType].invalidCount[issueInstance.ObjectName] = true - return utils.Issue{ + return utils.AnalyzeSchemaIssue{ + IssueType: issueType, ObjectType: issueInstance.ObjectType, ObjectName: displayObjectName, Reason: issueInstance.TypeName, @@ -693,7 +678,6 @@ func convertIssueInstanceToAnalyzeIssue(issueInstance queryissue.QueryIssue, fil SqlStatement: issueInstance.SqlStatement, DocsLink: issueInstance.DocsLink, FilePath: fileName, - IssueType: issueType, Suggestion: issueInstance.Suggestion, GH: issueInstance.GH, MinimumVersionsFixedIn: issueInstance.MinimumVersionsFixedIn, @@ -1090,7 +1074,7 @@ func analyzeSchemaInternal(sourceDBConf *srcdb.Source, detectIssues bool) utils. // Ideally all filtering of issues should happen in queryissue pkg layer, // but until we move all issue detection logic to queryissue pkg, we will filter issues here as well. - schemaAnalysisReport.Issues = lo.Filter(schemaAnalysisReport.Issues, func(i utils.Issue, index int) bool { + schemaAnalysisReport.Issues = lo.Filter(schemaAnalysisReport.Issues, func(i utils.AnalyzeSchemaIssue, index int) bool { fixed, err := i.IsFixedIn(targetDbVersion) if err != nil { utils.ErrExit("checking if issue %v is supported: %v", i, err) @@ -1254,7 +1238,7 @@ func packAndSendAnalyzeSchemaPayload(status string) { payload := createCallhomePayload() payload.MigrationPhase = ANALYZE_PHASE - var callhomeIssues []utils.Issue + var callhomeIssues []utils.AnalyzeSchemaIssue for _, issue := range schemaAnalysisReport.Issues { issue.SqlStatement = "" // Obfuscate sensitive information before sending to callhome cluster if !lo.ContainsBy(reasonsToSendObjectNameToCallhome, func(r string) bool { diff --git a/yb-voyager/cmd/assessMigrationCommand.go b/yb-voyager/cmd/assessMigrationCommand.go index c54e998f5..0493fb3f5 100644 --- a/yb-voyager/cmd/assessMigrationCommand.go +++ b/yb-voyager/cmd/assessMigrationCommand.go @@ -514,8 +514,8 @@ func createMigrationAssessmentCompletedEvent() *cp.MigrationAssessmentCompletedE } // flatten UnsupportedDataTypes, UnsupportedFeatures, MigrationCaveats -func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []AssessmentIssuePayload { - var issues []AssessmentIssuePayload +func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []AssessmentIssueYugabyteD { + var issues []AssessmentIssueYugabyteD var dataTypesDocsLink string switch source.DBType { @@ -525,7 +525,7 @@ func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []Assessment dataTypesDocsLink = UNSUPPORTED_DATATYPES_DOC_LINK_ORACLE } for _, unsupportedDataType := range ar.UnsupportedDataTypes { - issues = append(issues, AssessmentIssuePayload{ + issues = append(issues, AssessmentIssueYugabyteD{ Type: DATATYPE, TypeDescription: DATATYPE_ISSUE_TYPE_DESCRIPTION, Subtype: unsupportedDataType.DataType, @@ -537,7 +537,7 @@ func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []Assessment for _, unsupportedFeature := range ar.UnsupportedFeatures { for _, object := range unsupportedFeature.Objects { - issues = append(issues, AssessmentIssuePayload{ + issues = append(issues, AssessmentIssueYugabyteD{ Type: FEATURE, TypeDescription: FEATURE_ISSUE_TYPE_DESCRIPTION, Subtype: unsupportedFeature.FeatureName, @@ -552,7 +552,7 @@ func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []Assessment for _, migrationCaveat := range ar.MigrationCaveats { for _, object := range migrationCaveat.Objects { - issues = append(issues, AssessmentIssuePayload{ + issues = append(issues, AssessmentIssueYugabyteD{ Type: MIGRATION_CAVEATS, TypeDescription: MIGRATION_CAVEATS_TYPE_DESCRIPTION, Subtype: migrationCaveat.FeatureName, @@ -566,7 +566,7 @@ func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []Assessment } for _, uqc := range ar.UnsupportedQueryConstructs { - issues = append(issues, AssessmentIssuePayload{ + issues = append(issues, AssessmentIssueYugabyteD{ Type: QUERY_CONSTRUCT, TypeDescription: UNSUPPORTED_QUERY_CONSTRUTS_DESCRIPTION, Subtype: uqc.ConstructTypeName, @@ -578,7 +578,7 @@ func flattenAssessmentReportToAssessmentIssues(ar AssessmentReport) []Assessment for _, plpgsqlObjects := range ar.UnsupportedPlPgSqlObjects { for _, object := range plpgsqlObjects.Objects { - issues = append(issues, AssessmentIssuePayload{ + issues = append(issues, AssessmentIssueYugabyteD{ Type: PLPGSQL_OBJECT, TypeDescription: UNSUPPPORTED_PLPGSQL_OBJECT_DESCRIPTION, Subtype: plpgsqlObjects.FeatureName, @@ -902,6 +902,12 @@ func generateAssessmentReport() (err error) { } func getAssessmentReportContentFromAnalyzeSchema() error { + /* + Here we are generating analyze schema report which converts issue instance to analyze schema issue + Then in assessment codepath we extract the required information from analyze schema issue which could have been done directly from issue instance(TODO) + + But current Limitation is analyze schema currently uses regexp etc to detect some issues(not using parser). + */ schemaAnalysisReport := analyzeSchemaInternal(&source, true) assessmentReport.MigrationComplexity = schemaAnalysisReport.MigrationComplexity assessmentReport.SchemaSummary = schemaAnalysisReport.SchemaSummary @@ -997,31 +1003,28 @@ func fetchUnsupportedPGFeaturesFromSchemaReport(schemaAnalysisReport utils.Schem reason := fmt.Sprintf(INDEX_METHOD_ISSUE_REASON, displayIndexMethod) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(featureName, reason, "", schemaAnalysisReport, false, "")) } - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(CONSTRAINT_TRIGGERS_FEATURE, CONSTRAINT_TRIGGER_ISSUE_REASON, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(INHERITED_TABLES_FEATURE, INHERITANCE_ISSUE_REASON, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(GENERATED_COLUMNS_FEATURE, STORED_GENERATED_COLUMN_ISSUE_REASON, "", schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(CONSTRAINT_TRIGGERS_FEATURE, "", queryissue.CONSTRAINT_TRIGGER, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(INHERITED_TABLES_FEATURE, "", queryissue.INHERITANCE, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(GENERATED_COLUMNS_FEATURE, "", queryissue.STORED_GENERATED_COLUMNS, schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(CONVERSIONS_OBJECTS_FEATURE, CONVERSION_ISSUE_REASON, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(MULTI_COLUMN_GIN_INDEX_FEATURE, GIN_INDEX_MULTI_COLUMN_ISSUE_REASON, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(ALTER_SETTING_ATTRIBUTE_FEATURE, ALTER_TABLE_SET_ATTRIBUTE_ISSUE, "", schemaAnalysisReport, true, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(DISABLING_TABLE_RULE_FEATURE, ALTER_TABLE_DISABLE_RULE_ISSUE, "", schemaAnalysisReport, true, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(CLUSTER_ON_FEATURE, ALTER_TABLE_CLUSTER_ON_ISSUE, "", schemaAnalysisReport, true, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(STORAGE_PARAMETERS_FEATURE, STORAGE_PARAMETERS_DDL_STMT_ISSUE, "", schemaAnalysisReport, true, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(MULTI_COLUMN_GIN_INDEX_FEATURE, "", queryissue.MULTI_COLUMN_GIN_INDEX, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(ALTER_SETTING_ATTRIBUTE_FEATURE, "", queryissue.ALTER_TABLE_SET_COLUMN_ATTRIBUTE, schemaAnalysisReport, true, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(DISABLING_TABLE_RULE_FEATURE, "", queryissue.ALTER_TABLE_DISABLE_RULE, schemaAnalysisReport, true, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(CLUSTER_ON_FEATURE, "", queryissue.ALTER_TABLE_CLUSTER_ON, schemaAnalysisReport, true, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(STORAGE_PARAMETERS_FEATURE, "", queryissue.STORAGE_PARAMETER, schemaAnalysisReport, true, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(EXTENSION_FEATURE, UNSUPPORTED_EXTENSION_ISSUE, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(EXCLUSION_CONSTRAINT_FEATURE, EXCLUSION_CONSTRAINT_ISSUE, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(DEFERRABLE_CONSTRAINT_FEATURE, DEFERRABLE_CONSTRAINT_ISSUE, "", schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(EXCLUSION_CONSTRAINT_FEATURE, "", queryissue.EXCLUSION_CONSTRAINTS, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(DEFERRABLE_CONSTRAINT_FEATURE, "", queryissue.DEFERRABLE_CONSTRAINTS, schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(VIEW_CHECK_FEATURE, VIEW_CHECK_OPTION_ISSUE, "", schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getIndexesOnComplexTypeUnsupportedFeature(schemaAnalysisReport, queryissue.UnsupportedIndexDatatypes)) - - pkOrUkConstraintIssuePrefix := strings.Split(ISSUE_PK_UK_CONSTRAINT_WITH_COMPLEX_DATATYPES, "%s")[0] - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(PK_UK_CONSTRAINT_ON_COMPLEX_DATATYPES_FEATURE, pkOrUkConstraintIssuePrefix, "", schemaAnalysisReport, false, "")) - - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(UNLOGGED_TABLE_FEATURE, ISSUE_UNLOGGED_TABLE, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(REFERENCING_TRIGGER_FEATURE, REFERENCING_CLAUSE_FOR_TRIGGERS, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(BEFORE_FOR_EACH_ROW_TRIGGERS_ON_PARTITIONED_TABLE_FEATURE, BEFORE_FOR_EACH_ROW_TRIGGERS_ON_PARTITIONED_TABLE, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.ADVISORY_LOCKS_NAME, queryissue.ADVISORY_LOCKS_NAME, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.XML_FUNCTIONS_NAME, queryissue.XML_FUNCTIONS_NAME, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.SYSTEM_COLUMNS_NAME, queryissue.SYSTEM_COLUMNS_NAME, "", schemaAnalysisReport, false, "")) - unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.LARGE_OBJECT_FUNCTIONS_NAME, queryissue.LARGE_OBJECT_FUNCTIONS_NAME, "", schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(PK_UK_CONSTRAINT_ON_COMPLEX_DATATYPES_FEATURE, "", queryissue.PK_UK_ON_COMPLEX_DATATYPE, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(UNLOGGED_TABLE_FEATURE, "", queryissue.UNLOGGED_TABLE, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(REFERENCING_TRIGGER_FEATURE, "", queryissue.REFERENCING_CLAUSE_IN_TRIGGER, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(BEFORE_FOR_EACH_ROW_TRIGGERS_ON_PARTITIONED_TABLE_FEATURE, "", queryissue.BEFORE_ROW_TRIGGER_ON_PARTITIONED_TABLE, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.ADVISORY_LOCKS_NAME, "", queryissue.ADVISORY_LOCKS, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.XML_FUNCTIONS_NAME, "", queryissue.XML_FUNCTIONS, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.SYSTEM_COLUMNS_NAME, "", queryissue.SYSTEM_COLUMNS, schemaAnalysisReport, false, "")) + unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.LARGE_OBJECT_FUNCTIONS_NAME, "", queryissue.LARGE_OBJECT_FUNCTIONS, schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(REGEX_FUNCTIONS_FEATURE, "", queryissue.REGEX_FUNCTIONS, schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(FETCH_WITH_TIES_FEATURE, "", queryissue.FETCH_WITH_TIES, schemaAnalysisReport, false, "")) unsupportedFeatures = append(unsupportedFeatures, getUnsupportedFeaturesFromSchemaAnalysisReport(queryissue.JSON_QUERY_FUNCTIONS_NAME, "", queryissue.JSON_QUERY_FUNCTION, schemaAnalysisReport, false, "")) @@ -1034,7 +1037,7 @@ func fetchUnsupportedPGFeaturesFromSchemaReport(schemaAnalysisReport utils.Schem }), nil } -func getIndexesOnComplexTypeUnsupportedFeature(schemaAnalysisiReport utils.SchemaReport, unsupportedIndexDatatypes []string) UnsupportedFeature { +func getIndexesOnComplexTypeUnsupportedFeature(schemaAnalysisReport utils.SchemaReport, unsupportedIndexDatatypes []string) UnsupportedFeature { // TODO: include MinimumVersionsFixedIn indexesOnComplexTypesFeature := UnsupportedFeature{ FeatureName: "Index on complex datatypes", @@ -1122,10 +1125,10 @@ func fetchUnsupportedPlPgSQLObjects(schemaAnalysisReport utils.SchemaReport) []U return nil } analyzeIssues := schemaAnalysisReport.Issues - plpgsqlIssues := lo.Filter(analyzeIssues, func(issue utils.Issue, _ int) bool { + plpgsqlIssues := lo.Filter(analyzeIssues, func(issue utils.AnalyzeSchemaIssue, _ int) bool { return issue.IssueType == UNSUPPORTED_PLPGSQL_OBEJCTS }) - groupPlpgsqlIssuesByReason := lo.GroupBy(plpgsqlIssues, func(issue utils.Issue) string { + groupPlpgsqlIssuesByReason := lo.GroupBy(plpgsqlIssues, func(issue utils.AnalyzeSchemaIssue) string { return issue.Reason }) var unsupportedPlpgSqlObjects []UnsupportedFeature @@ -1158,8 +1161,8 @@ func fetchUnsupportedPlPgSQLObjects(schemaAnalysisReport utils.SchemaReport) []U } unsupportedPlpgSqlObjects = append(unsupportedPlpgSqlObjects, feature) } - return unsupportedPlpgSqlObjects + return unsupportedPlpgSqlObjects } func fetchUnsupportedQueryConstructs() ([]utils.UnsupportedQueryConstruct, error) { @@ -1404,11 +1407,11 @@ func addMigrationCaveatsToAssessmentReport(unsupportedDataTypesForLiveMigration case POSTGRESQL: log.Infof("add migration caveats to assessment report") migrationCaveats := make([]UnsupportedFeature, 0) - migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(ALTER_PARTITION_ADD_PK_CAVEAT_FEATURE, ADDING_PK_TO_PARTITIONED_TABLE_ISSUE_REASON, "", + migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(ALTER_PARTITION_ADD_PK_CAVEAT_FEATURE, "", queryissue.ALTER_TABLE_ADD_PK_ON_PARTITIONED_TABLE, schemaAnalysisReport, true, DESCRIPTION_ADD_PK_TO_PARTITION_TABLE)) - migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(FOREIGN_TABLE_CAVEAT_FEATURE, FOREIGN_TABLE_ISSUE_REASON, "", + migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(FOREIGN_TABLE_CAVEAT_FEATURE, "", queryissue.FOREIGN_TABLE, schemaAnalysisReport, false, DESCRIPTION_FOREIGN_TABLES)) - migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(POLICIES_CAVEAT_FEATURE, POLICY_ROLE_ISSUE, "", + migrationCaveats = append(migrationCaveats, getUnsupportedFeaturesFromSchemaAnalysisReport(POLICIES_CAVEAT_FEATURE, "", queryissue.POLICY_WITH_ROLES, schemaAnalysisReport, false, DESCRIPTION_POLICY_ROLE_ISSUE)) if len(unsupportedDataTypesForLiveMigration) > 0 { diff --git a/yb-voyager/cmd/common.go b/yb-voyager/cmd/common.go index 468debe2d..47c5a7c49 100644 --- a/yb-voyager/cmd/common.go +++ b/yb-voyager/cmd/common.go @@ -1176,20 +1176,36 @@ func getMigrationComplexityForOracle(schemaDirectory string) (string, error) { // TODO: consider merging all unsupported field with single AssessmentReport struct member as AssessmentIssue type AssessmentReport struct { - VoyagerVersion string `json:"VoyagerVersion"` - TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"` - MigrationComplexity string `json:"MigrationComplexity"` - SchemaSummary utils.SchemaSummary `json:"SchemaSummary"` - Sizing *migassessment.SizingAssessmentReport `json:"Sizing"` - UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"` - UnsupportedDataTypesDesc string `json:"UnsupportedDataTypesDesc"` - UnsupportedFeatures []UnsupportedFeature `json:"UnsupportedFeatures"` - UnsupportedFeaturesDesc string `json:"UnsupportedFeaturesDesc"` - UnsupportedQueryConstructs []utils.UnsupportedQueryConstruct `json:"UnsupportedQueryConstructs"` - UnsupportedPlPgSqlObjects []UnsupportedFeature `json:"UnsupportedPlPgSqlObjects"` - MigrationCaveats []UnsupportedFeature `json:"MigrationCaveats"` - TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"` - Notes []string `json:"Notes"` + VoyagerVersion string `json:"VoyagerVersion"` + TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"` + MigrationComplexity string `json:"MigrationComplexity"` + SchemaSummary utils.SchemaSummary `json:"SchemaSummary"` + Sizing *migassessment.SizingAssessmentReport `json:"Sizing"` + Issues []AssessmentIssue `json:"-"` // disabled in reports till corresponding UI changes are done(json and html reports) + TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"` + Notes []string `json:"Notes"` + + // fields going to be deprecated + UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"` + UnsupportedDataTypesDesc string `json:"UnsupportedDataTypesDesc"` + UnsupportedFeatures []UnsupportedFeature `json:"UnsupportedFeatures"` + UnsupportedFeaturesDesc string `json:"UnsupportedFeaturesDesc"` + UnsupportedQueryConstructs []utils.UnsupportedQueryConstruct `json:"UnsupportedQueryConstructs"` + UnsupportedPlPgSqlObjects []UnsupportedFeature `json:"UnsupportedPlPgSqlObjects"` + MigrationCaveats []UnsupportedFeature `json:"MigrationCaveats"` +} + +type AssessmentIssue struct { + Category string + CategoryDescription string + TypeName string + TypeDescription string + Impact string + ObjectType string + ObjectName string + SqlStatement string + DocsLink string + MinimumVersionFixedIn map[string]*ybversion.YBVersion } type UnsupportedFeature struct { @@ -1240,15 +1256,15 @@ type AssessMigrationPayload struct { TargetDBVersion *ybversion.YBVersion MigrationComplexity string SchemaSummary utils.SchemaSummary - AssessmentIssues []AssessmentIssuePayload + AssessmentIssues []AssessmentIssueYugabyteD SourceSizeDetails SourceDBSizeDetails TargetRecommendations TargetSizingRecommendations - ConversionIssues []utils.Issue + ConversionIssues []utils.AnalyzeSchemaIssue // Depreacted: AssessmentJsonReport is depricated; use the fields directly inside struct AssessmentJsonReport AssessmentReport } -type AssessmentIssuePayload struct { +type AssessmentIssueYugabyteD struct { Type string `json:"Type"` // Feature, DataType, MigrationCaveat, UQC TypeDescription string `json:"TypeDescription"` // Based on AssessmentIssue type Subtype string `json:"Subtype"` // GIN Indexes, Advisory Locks etc diff --git a/yb-voyager/cmd/common_test.go b/yb-voyager/cmd/common_test.go index 49eee13b0..6dd45e666 100644 --- a/yb-voyager/cmd/common_test.go +++ b/yb-voyager/cmd/common_test.go @@ -134,6 +134,9 @@ func TestAssessmentReportStructs(t *testing.T) { MigrationComplexity string `json:"MigrationComplexity"` SchemaSummary utils.SchemaSummary `json:"SchemaSummary"` Sizing *migassessment.SizingAssessmentReport `json:"Sizing"` + Issues []AssessmentIssue `json:"-"` + TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"` + Notes []string `json:"Notes"` UnsupportedDataTypes []utils.TableColumnsDataTypes `json:"UnsupportedDataTypes"` UnsupportedDataTypesDesc string `json:"UnsupportedDataTypesDesc"` UnsupportedFeatures []UnsupportedFeature `json:"UnsupportedFeatures"` @@ -141,8 +144,6 @@ func TestAssessmentReportStructs(t *testing.T) { UnsupportedQueryConstructs []utils.UnsupportedQueryConstruct `json:"UnsupportedQueryConstructs"` UnsupportedPlPgSqlObjects []UnsupportedFeature `json:"UnsupportedPlPgSqlObjects"` MigrationCaveats []UnsupportedFeature `json:"MigrationCaveats"` - TableIndexStats *[]migassessment.TableIndexStats `json:"TableIndexStats"` - Notes []string `json:"Notes"` }{}, }, } @@ -196,6 +197,24 @@ func TestAssessmentReportJson(t *testing.T) { }, FailureReasoning: "Test failure reasoning", }, + Issues: nil, + TableIndexStats: &[]migassessment.TableIndexStats{ + { + SchemaName: "public", + ObjectName: "test_table", + RowCount: Int64Ptr(100), + ColumnCount: Int64Ptr(10), + Reads: Int64Ptr(100), + Writes: Int64Ptr(100), + ReadsPerSecond: Int64Ptr(10), + WritesPerSecond: Int64Ptr(10), + IsIndex: true, + ObjectType: "Table", + ParentTableName: StringPtr("parent_table"), + SizeInBytes: Int64Ptr(1024), + }, + }, + Notes: []string{"Test note"}, UnsupportedDataTypes: []utils.TableColumnsDataTypes{ { SchemaName: "public", @@ -262,23 +281,6 @@ func TestAssessmentReportJson(t *testing.T) { MinimumVersionsFixedIn: map[string]*ybversion.YBVersion{"2024.1.1": newYbVersion}, }, }, - TableIndexStats: &[]migassessment.TableIndexStats{ - { - SchemaName: "public", - ObjectName: "test_table", - RowCount: Int64Ptr(100), - ColumnCount: Int64Ptr(10), - Reads: Int64Ptr(100), - Writes: Int64Ptr(100), - ReadsPerSecond: Int64Ptr(10), - WritesPerSecond: Int64Ptr(10), - IsIndex: true, - ObjectType: "Table", - ParentTableName: StringPtr("parent_table"), - SizeInBytes: Int64Ptr(1024), - }, - }, - Notes: []string{"Test note"}, } // Make the report directory @@ -341,6 +343,25 @@ func TestAssessmentReportJson(t *testing.T) { }, "FailureReasoning": "Test failure reasoning" }, + "TableIndexStats": [ + { + "SchemaName": "public", + "ObjectName": "test_table", + "RowCount": 100, + "ColumnCount": 10, + "Reads": 100, + "Writes": 100, + "ReadsPerSecond": 10, + "WritesPerSecond": 10, + "IsIndex": true, + "ObjectType": "Table", + "ParentTableName": "parent_table", + "SizeInBytes": 1024 + } + ], + "Notes": [ + "Test note" + ], "UnsupportedDataTypes": [ { "SchemaName": "public", @@ -411,25 +432,6 @@ func TestAssessmentReportJson(t *testing.T) { "2024.1.1": "2024.1.1.1" } } - ], - "TableIndexStats": [ - { - "SchemaName": "public", - "ObjectName": "test_table", - "RowCount": 100, - "ColumnCount": 10, - "Reads": 100, - "Writes": 100, - "ReadsPerSecond": 10, - "WritesPerSecond": 10, - "IsIndex": true, - "ObjectType": "Table", - "ParentTableName": "parent_table", - "SizeInBytes": 1024 - } - ], - "Notes": [ - "Test note" ] }` diff --git a/yb-voyager/cmd/constants.go b/yb-voyager/cmd/constants.go index a56ec1097..f4d9cc4fc 100644 --- a/yb-voyager/cmd/constants.go +++ b/yb-voyager/cmd/constants.go @@ -173,7 +173,7 @@ const ( List of all the features we are reporting as part of Unsupported features and Migration caveats */ const ( - // Types for AssessmentIssue + // AssessmentIssue types used in YugabyteD payload FEATURE = "feature" DATATYPE = "datatype" QUERY_CONSTRUCT = "query_construct" // confused: in json for some values we are using space separated and for some snake_case @@ -227,11 +227,11 @@ const ( POLICIES_CAVEAT_FEATURE = "Policies" UNSUPPORTED_DATATYPES_LIVE_CAVEAT_FEATURE = "Unsupported Data Types for Live Migration" UNSUPPORTED_DATATYPES_LIVE_WITH_FF_FB_CAVEAT_FEATURE = "Unsupported Data Types for Live Migration with Fall-forward/Fallback" + UNSUPPORTED_DATATYPES_FOR_LIVE_MIGRATION_ISSUE = "There are some data types in the schema that are not supported by live migration of data. These columns will be excluded when exporting and importing data in live migration workflows." + UNSUPPORTED_DATATYPES_FOR_LIVE_MIGRATION_WITH_FF_FB_ISSUE = "There are some data types in the schema that are not supported by live migration with fall-forward/fall-back. These columns will be excluded when exporting and importing data in live migration workflows." DESCRIPTION_ADD_PK_TO_PARTITION_TABLE = `After export schema, the ALTER table should be merged with CREATE table for partitioned tables as alter of partitioned tables to add primary key is not supported.` DESCRIPTION_FOREIGN_TABLES = `During the export schema phase, SERVER and USER MAPPING objects are not exported. These should be manually created to make the foreign tables work.` DESCRIPTION_POLICY_ROLE_ISSUE = `There are some policies that are created for certain users/roles. During the export schema phase, USERs and GRANTs are not exported. Therefore, they will have to be manually created before running import schema.` - UNSUPPORTED_DATATYPES_FOR_LIVE_MIGRATION_ISSUE = "There are some data types in the schema that are not supported by live migration of data. These columns will be excluded when exporting and importing data in live migration workflows." - UNSUPPORTED_DATATYPES_FOR_LIVE_MIGRATION_WITH_FF_FB_ISSUE = "There are some data types in the schema that are not supported by live migration with fall-forward/fall-back. These columns will be excluded when exporting and importing data in live migration workflows." ) var supportedSourceDBTypes = []string{ORACLE, MYSQL, POSTGRESQL, YUGABYTEDB} diff --git a/yb-voyager/src/query/queryissue/constants.go b/yb-voyager/src/query/queryissue/constants.go index 586957bf9..117e6dbdf 100644 --- a/yb-voyager/src/query/queryissue/constants.go +++ b/yb-voyager/src/query/queryissue/constants.go @@ -23,16 +23,16 @@ const ( UNLOGGED_TABLE = "UNLOGGED_TABLE" UNSUPPORTED_INDEX_METHOD = "UNSUPPORTED_INDEX_METHOD" STORAGE_PARAMETER = "STORAGE_PARAMETER" - SET_ATTRIBUTES = "SET_ATTRIBUTES" - CLUSTER_ON = "CLUSTER_ON" - DISABLE_RULE = "DISABLE_RULE" + ALTER_TABLE_SET_COLUMN_ATTRIBUTE = "ALTER_TABLE_SET_COLUMN_ATTRIBUTE" + ALTER_TABLE_CLUSTER_ON = "ALTER_TABLE_CLUSTER_ON" + ALTER_TABLE_DISABLE_RULE = "ALTER_TABLE_DISABLE_RULE" EXCLUSION_CONSTRAINTS = "EXCLUSION_CONSTRAINTS" DEFERRABLE_CONSTRAINTS = "DEFERRABLE_CONSTRAINTS" MULTI_COLUMN_GIN_INDEX = "MULTI_COLUMN_GIN_INDEX" ORDERED_GIN_INDEX = "ORDERED_GIN_INDEX" POLICY_WITH_ROLES = "POLICY_WITH_ROLES" CONSTRAINT_TRIGGER = "CONSTRAINT_TRIGGER" - REFERENCING_CLAUSE_FOR_TRIGGERS = "REFERENCING_CLAUSE_FOR_TRIGGERS" + REFERENCING_CLAUSE_IN_TRIGGER = "REFERENCING_CLAUSE_IN_TRIGGER" BEFORE_ROW_TRIGGER_ON_PARTITIONED_TABLE = "BEFORE_ROW_TRIGGER_ON_PARTITIONED_TABLE" ALTER_TABLE_ADD_PK_ON_PARTITIONED_TABLE = "ALTER_TABLE_ADD_PK_ON_PARTITIONED_TABLE" EXPRESSION_PARTITION_WITH_PK_UK = "EXPRESSION_PARTITION_WITH_PK_UK" diff --git a/yb-voyager/src/query/queryissue/detectors_ddl.go b/yb-voyager/src/query/queryissue/detectors_ddl.go index 595680f9a..c63a1e979 100644 --- a/yb-voyager/src/query/queryissue/detectors_ddl.go +++ b/yb-voyager/src/query/queryissue/detectors_ddl.go @@ -413,7 +413,7 @@ func (aid *AlterTableIssueDetector) DetectIssues(obj queryparser.DDLObject) ([]Q switch alter.AlterType { case queryparser.SET_OPTIONS: if alter.NumSetAttributes > 0 { - issues = append(issues, NewSetAttributeIssue( + issues = append(issues, NewSetColumnAttributeIssue( obj.GetObjectType(), alter.GetObjectName(), "", // query string @@ -475,7 +475,7 @@ func (aid *AlterTableIssueDetector) DetectIssues(obj queryparser.DDLObject) ([]Q } case queryparser.DISABLE_RULE: - issues = append(issues, NewDisableRuleIssue( + issues = append(issues, NewAlterTableDisableRuleIssue( obj.GetObjectType(), alter.GetObjectName(), "", // query string diff --git a/yb-voyager/src/query/queryissue/issues_ddl.go b/yb-voyager/src/query/queryissue/issues_ddl.go index ba1d4cdae..d005a1ef3 100644 --- a/yb-voyager/src/query/queryissue/issues_ddl.go +++ b/yb-voyager/src/query/queryissue/issues_ddl.go @@ -80,21 +80,21 @@ func NewStorageParameterIssue(objectType string, objectName string, sqlStatement return newQueryIssue(storageParameterIssue, objectType, objectName, sqlStatement, details) } -var setAttributeIssue = issue.Issue{ - Type: SET_ATTRIBUTES, +var setColumnAttributeIssue = issue.Issue{ + Type: ALTER_TABLE_SET_COLUMN_ATTRIBUTE, TypeName: "ALTER TABLE .. ALTER COLUMN .. SET ( attribute = value ) not supported yet", GH: "https://github.com/yugabyte/yugabyte-db/issues/1124", Suggestion: "Remove it from the exported schema", DocsLink: "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#unsupported-alter-table-ddl-variants-in-source-schema", } -func NewSetAttributeIssue(objectType string, objectName string, sqlStatement string) QueryIssue { +func NewSetColumnAttributeIssue(objectType string, objectName string, sqlStatement string) QueryIssue { details := map[string]interface{}{} - return newQueryIssue(setAttributeIssue, objectType, objectName, sqlStatement, details) + return newQueryIssue(setColumnAttributeIssue, objectType, objectName, sqlStatement, details) } -var clusterOnIssue = issue.Issue{ - Type: CLUSTER_ON, +var alterTableClusterOnIssue = issue.Issue{ + Type: ALTER_TABLE_CLUSTER_ON, TypeName: "ALTER TABLE CLUSTER not supported yet.", GH: "https://github.com/YugaByte/yugabyte-db/issues/1124", Suggestion: "Remove it from the exported schema.", @@ -103,20 +103,20 @@ var clusterOnIssue = issue.Issue{ func NewClusterONIssue(objectType string, objectName string, sqlStatement string) QueryIssue { details := map[string]interface{}{} - return newQueryIssue(clusterOnIssue, objectType, objectName, sqlStatement, details) + return newQueryIssue(alterTableClusterOnIssue, objectType, objectName, sqlStatement, details) } -var disableRuleIssue = issue.Issue{ - Type: DISABLE_RULE, +var alterTableDisableRuleIssue = issue.Issue{ + Type: ALTER_TABLE_DISABLE_RULE, TypeName: "ALTER TABLE name DISABLE RULE not supported yet", GH: "https://github.com/yugabyte/yugabyte-db/issues/1124", Suggestion: "Remove this and the rule '%s' from the exported schema to be not enabled on the table.", DocsLink: "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#unsupported-alter-table-ddl-variants-in-source-schema", } -func NewDisableRuleIssue(objectType string, objectName string, sqlStatement string, ruleName string) QueryIssue { +func NewAlterTableDisableRuleIssue(objectType string, objectName string, sqlStatement string, ruleName string) QueryIssue { details := map[string]interface{}{} - issue := disableRuleIssue + issue := alterTableDisableRuleIssue issue.Suggestion = fmt.Sprintf(issue.Suggestion, ruleName) return newQueryIssue(issue, objectType, objectName, sqlStatement, details) } @@ -200,7 +200,7 @@ func NewConstraintTriggerIssue(objectType string, objectName string, sqlStatemen } var referencingClauseInTriggerIssue = issue.Issue{ - Type: REFERENCING_CLAUSE_FOR_TRIGGERS, + Type: REFERENCING_CLAUSE_IN_TRIGGER, TypeName: "REFERENCING clause (transition tables) not supported yet.", GH: "https://github.com/YugaByte/yugabyte-db/issues/1668", DocsLink: "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#referencing-clause-for-triggers", diff --git a/yb-voyager/src/query/queryissue/issues_ddl_test.go b/yb-voyager/src/query/queryissue/issues_ddl_test.go index d53896781..709dd369d 100644 --- a/yb-voyager/src/query/queryissue/issues_ddl_test.go +++ b/yb-voyager/src/query/queryissue/issues_ddl_test.go @@ -141,7 +141,7 @@ func testSetAttributeIssue(t *testing.T) { ); ALTER TABLE ONLY public.event_search ALTER COLUMN room_id SET (n_distinct=-0.01)`) - assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE ALTER column not supported yet", setAttributeIssue) + assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE ALTER column not supported yet", setColumnAttributeIssue) } func testClusterOnIssue(t *testing.T) { @@ -161,7 +161,7 @@ func testClusterOnIssue(t *testing.T) { ALTER TABLE public.test CLUSTER ON test_age_salary`) - assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE CLUSTER not supported yet", clusterOnIssue) + assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE CLUSTER not supported yet", alterTableClusterOnIssue) } func testDisableRuleIssue(t *testing.T) { @@ -177,7 +177,7 @@ func testDisableRuleIssue(t *testing.T) { ALTER TABLE trule DISABLE RULE trule_rule`) - assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE DISABLE RULE not supported yet", disableRuleIssue) + assertErrorCorrectlyThrownForIssueForYBVersion(t, err, "ALTER TABLE DISABLE RULE not supported yet", alterTableDisableRuleIssue) } func testStorageParameterIssue(t *testing.T) { diff --git a/yb-voyager/src/query/queryissue/parser_issue_detector_test.go b/yb-voyager/src/query/queryissue/parser_issue_detector_test.go index e5b6315b0..c09c4e59d 100644 --- a/yb-voyager/src/query/queryissue/parser_issue_detector_test.go +++ b/yb-voyager/src/query/queryissue/parser_issue_detector_test.go @@ -197,7 +197,7 @@ func TestAllIssues(t *testing.T) { NewStorageParameterIssue("INDEX", "abc ON public.example", stmt3), }, stmt4: []QueryIssue{ - NewDisableRuleIssue("TABLE", "public.example", stmt4, "example_rule"), + NewAlterTableDisableRuleIssue("TABLE", "public.example", stmt4, "example_rule"), }, stmt5: []QueryIssue{ NewDeferrableConstraintIssue("TABLE", "abc", stmt5, "cnstr_id"), diff --git a/yb-voyager/src/utils/commonVariables.go b/yb-voyager/src/utils/commonVariables.go index c1d51326b..b42c547d9 100644 --- a/yb-voyager/src/utils/commonVariables.go +++ b/yb-voyager/src/utils/commonVariables.go @@ -78,7 +78,7 @@ type SchemaReport struct { TargetDBVersion *ybversion.YBVersion `json:"TargetDBVersion"` MigrationComplexity string `json:"MigrationComplexity"` SchemaSummary SchemaSummary `json:"Summary"` - Issues []Issue `json:"Issues"` + Issues []AnalyzeSchemaIssue `json:"Issues"` } type SchemaSummary struct { @@ -90,7 +90,7 @@ type SchemaSummary struct { DBObjects []DBObject `json:"DatabaseObjects"` } -//TODO: Rename the variables of TotalCount and InvalidCount -> TotalObjects and ObjectsWithIssues +// TODO: Rename the variables of TotalCount and InvalidCount -> TotalObjects and ObjectsWithIssues type DBObject struct { ObjectType string `json:"ObjectType"` TotalCount int `json:"TotalCount"` @@ -100,7 +100,8 @@ type DBObject struct { } // TODO: support MinimumVersionsFixedIn in xml -type Issue struct { +type AnalyzeSchemaIssue struct { + // TODO: rename IssueType to Category IssueType string `json:"IssueType"` //category: unsupported_features, unsupported_plpgsql_objects, etc ObjectType string `json:"ObjectType"` ObjectName string `json:"ObjectName"` @@ -114,7 +115,7 @@ type Issue struct { MinimumVersionsFixedIn map[string]*ybversion.YBVersion `json:"MinimumVersionsFixedIn" xml:"-"` // key: series (2024.1, 2.21, etc) } -func (i Issue) IsFixedIn(v *ybversion.YBVersion) (bool, error) { +func (i AnalyzeSchemaIssue) IsFixedIn(v *ybversion.YBVersion) (bool, error) { if i.MinimumVersionsFixedIn == nil { return false, nil }