Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support ddl/dml aliasing for GitOps name template (#2570)

Danny Xu1e8b857640f4
diff --git a/plugin/db/driver.go b/plugin/db/driver.go
index 02904732c6..7399a63fe5 100644
--- a/plugin/db/driver.go
+++ b/plugin/db/driver.go
@@ -296,10 +296,14 @@ func ParseMigrationInfo(filePath, filePathTemplate string) (*MigrationInfo, erro
switch matchList[index] {
case "data":
mi.Type = Data
+ case "dml":
+ mi.Type = Data
case "migrate":
mi.Type = Migrate
+ case "ddl":
+ mi.Type = Migrate
default:
- return nil, errors.Errorf("file path %q contains invalid migration type %q, must be 'migrate' or 'data'", filePath, matchList[index])
+ return nil, errors.Errorf("file path %q contains invalid migration type %q, must be 'migrate'('ddl') or 'data'('dml')", filePath, matchList[index])
}
case "DESCRIPTION":
mi.Description = matchList[index]
diff --git a/plugin/db/driver_test.go b/plugin/db/driver_test.go
index 662a82b841..e450045e66 100644
--- a/plugin/db/driver_test.go
+++ b/plugin/db/driver_test.go
@@ -106,6 +106,36 @@ func TestParseMigrationInfo(t *testing.T) {
},
wantErr: "",
},
+ {
+ filePath: "db1__001foo__ddl",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}",
+ want: MigrationInfo{
+ Version: "001foo",
+ Namespace: "db1",
+ Database: "db1",
+ Environment: "",
+ Source: VCS,
+ Type: Migrate,
+ Description: "Create db1 schema migration",
+ Creator: "",
+ },
+ wantErr: "",
+ },
+ {
+ filePath: "db1__001foo__dml",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}",
+ want: MigrationInfo{
+ Version: "001foo",
+ Namespace: "db1",
+ Database: "db1",
+ Environment: "",
+ Source: VCS,
+ Type: Data,
+ Description: "Create db1 data change",
+ Creator: "",
+ },
+ wantErr: "",
+ },
{
filePath: "db_shop1__001foo__data",
filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}",