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: transform writeback schema to standard style for SDL (#3072)
Danny Xue6b1401999d3
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.goindex 799b98c090..ca414d357f 100644--- a/bin/server/cmd/root.go+++ b/bin/server/cmd/root.go@@ -46,6 +46,8 @@ import (_ "github.com/bytebase/bytebase/plugin/parser/differ/pg"// Register postgres parser driver._ "github.com/bytebase/bytebase/plugin/parser/engine/pg"+ // Register mysql transform driver.+ _ "github.com/bytebase/bytebase/plugin/parser/transform/mysql")// -----------------------------------Global constant BEGIN----------------------------------------.diff --git a/server/task_executor.go b/server/task_executor.goindex acecaba715..31040d2b9e 100644--- a/server/task_executor.go+++ b/server/task_executor.go@@ -15,6 +15,8 @@ import ("github.com/bytebase/bytebase/common""github.com/bytebase/bytebase/common/log""github.com/bytebase/bytebase/plugin/db"+ "github.com/bytebase/bytebase/plugin/parser"+ "github.com/bytebase/bytebase/plugin/parser/transform"vcsPlugin "github.com/bytebase/bytebase/plugin/vcs")@@ -179,7 +181,17 @@ func postMigration(ctx context.Context, server *Server, task *api.Task, vcsPushEwriteBack := falseif repo != nil && repo.SchemaPathTemplate != "" {if repo.Project.SchemaChangeType == api.ProjectSchemaChangeTypeSDL {- writeBack = (task.Type == api.TaskDatabaseSchemaBaseline)+ if task.Type == api.TaskDatabaseSchemaBaseline {+ writeBack = true+ // Transform the schema to standard style for SDL mode.+ if task.Database.Instance.Engine == db.MySQL {+ standardSchema, err := transform.SchemaTransform(parser.MySQL, schema)+ if err != nil {+ return true, nil, errors.Errorf("failed to transform to standard schema for database %q", task.Database.Name)+ }+ schema = standardSchema+ }+ }} else {writeBack = (vcsPushEvent != nil) && (task.Type == api.TaskDatabaseSchemaUpdate || task.Type == api.TaskDatabaseSchemaUpdateGhostCutover)}