Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add validation for mixed release and sheet configs in plans (#17658)
Danny Xu44f7a7af5ca4
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.goindex 62ae242aa1..45872ed46b 100644--- a/backend/api/v1/plan_service.go+++ b/backend/api/v1/plan_service.go@@ -1293,6 +1293,7 @@ func validateSpecs(specs []*v1pb.Plan_Spec) error {configTypeCount := map[string]int{}seenID := map[string]bool{}+ var releaseCount, sheetCount intfor _, spec := range specs {id := spec.GetId()if id == "" {@@ -1322,6 +1323,13 @@ func validateSpecs(specs []*v1pb.Plan_Spec) error {if databaseTarget > 0 && databaseGroupTarget > 0 {return errors.Errorf("found databaseTarget and databaseGroupTarget, expect only one kind")}+ // Track if this spec uses release or sheet.+ if config.ChangeDatabaseConfig.Release != "" {+ releaseCount+++ }+ if config.ChangeDatabaseConfig.Sheet != "" {+ sheetCount+++ }case *v1pb.Plan_Spec_ExportDataConfig:configTypeCount["export_data"]++default:@@ -1331,6 +1339,14 @@ func validateSpecs(specs []*v1pb.Plan_Spec) error {if len(configTypeCount) > 1 {return errors.Errorf("plan contains multiple types of spec configurations (%v), but each plan must contain only one type", len(configTypeCount))}+ // Disallow mixing ChangeDatabaseConfig specs with release and sheet.+ if releaseCount > 0 && sheetCount > 0 {+ return errors.Errorf("plan contains both release and sheet based change database configs, but each plan must use only one approach")+ }+ // Allow at most one ChangeDatabaseConfig with release.+ if releaseCount > 1 {+ return errors.Errorf("plan contains multiple change database configs with release, but only one is allowed")+ }return nil}