Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: fix gh-ost check order (#15277)
boojacka8022a7eaa15
diff --git a/backend/plugin/advisor/mysql/advisor_online_migration.go b/backend/plugin/advisor/mysql/advisor_online_migration.goindex 7317fc154d..3e9ca30713 100644--- a/backend/plugin/advisor/mysql/advisor_online_migration.go+++ b/backend/plugin/advisor/mysql/advisor_online_migration.go@@ -57,21 +57,7 @@ func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.title := string(ctx.Rule.Type)var adviceList []*storepb.Advice- // Check if the ghost database exists first.- if !advisor.DatabaseExists(ctx, ghostDatabaseName) {- adviceList = append(adviceList, &storepb.Advice{- Status: level,- Title: title,- Content: fmt.Sprintf("Needs database %q to save temporary data for online migration but it does not exist", ghostDatabaseName),- Code: advisor.DatabaseNotExists.Int32(),- StartPosition: &storepb.Position{- Line: 0,- },- })- return adviceList, nil- }-- // Check statements.+ // Check statements first.for _, stmt := range stmtList {checker := &useGhostChecker{currentDatabase: ctx.CurrentDatabase,@@ -103,6 +89,23 @@ func (*OnlineMigrationAdvisor) Check(ctx advisor.Context, _ string) ([]*storepb.}}+ // Check if the ghost database exists if there is any statement that needs online migration and gh-ost is enabled.+ if len(adviceList) > 0 && ctx.ChangeType == storepb.PlanCheckRunConfig_DDL_GHOST {+ if !advisor.DatabaseExists(ctx, ghostDatabaseName) {+ // Prepend the advice.+ adviceList = append([]*storepb.Advice{+ {Status: level,+ Title: title,+ Content: fmt.Sprintf("Needs database %q to save temporary data for online migration but it does not exist", ghostDatabaseName),+ Code: advisor.DatabaseNotExists.Int32(),+ StartPosition: &storepb.Position{+ Line: 0,+ }},+ }, adviceList...)+ return adviceList, nil+ }+ }+// More than one statements need online migration.// Advise running each statement in separate issues.if len(adviceList) > 1 {