Skip to content

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

Change default file path template from {{ENV_NAME}}/{{VERSION}}__{{DB_NAME}}__{{TYPE}}__{{DESCRIPTION}}.sql to {{ENV_NAME}}/{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql

天舟d09a70f359a0
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index 03990bd61a..511af6f86c 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -126,7 +126,7 @@ import { reactive } from "@vue/reactivity";
import { PropType } from "@vue/runtime-core";
import { ExternalRepositoryInfo, RepositoryConfig, VCSType } from "../types";
-const REQUIRED_PLACEHOLDER = "{{VERSION}}, {{DB_NAME}}, {{TYPE}}";
+const REQUIRED_PLACEHOLDER = "{{DB_NAME}}, {{VERSION}}, {{TYPE}}";
const OPTIONAL_PLACEHOLDER = "{{ENV_NAME}}, {{DESCRIPTION}}";
interface LocalState {}
diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vue
index 3f1eeedf0e..bf5cf30e3c 100644
--- a/frontend/src/components/RepositorySetupWizard.vue
+++ b/frontend/src/components/RepositorySetupWizard.vue
@@ -51,7 +51,7 @@ import { projectSlug } from "../utils";
// Default file path template is to organize migration files from different environments under separate directories.
const DEFAULT_FILE_PATH_TEMPLATE =
- "{{ENV_NAME}}/{{VERSION}}__{{DB_NAME}}__{{TYPE}}__{{DESCRIPTION}}.sql";
+ "{{ENV_NAME}}/{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql";
const CHOOSE_PROVIDER_STEP = 0;
const CHOOSE_REPOSITORY_STEP = 1;
diff --git a/plugin/db/driver_test.go b/plugin/db/driver_test.go
index ff32216d02..ddabdb7fe8 100644
--- a/plugin/db/driver_test.go
+++ b/plugin/db/driver_test.go
@@ -16,8 +16,8 @@ func TestParseMigrationInfo(t *testing.T) {
tests := []test{
{
- filePath: "001foo__db1",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}",
+ filePath: "db1__001foo",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -31,8 +31,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "1.2.3__db foo_+-=/_#?!$.",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}",
+ filePath: "db foo_+-=/_#?!$.__1.2.3",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}",
want: MigrationInfo{
Version: "1.2.3",
Namespace: "db foo_+-=/_#?!$.",
@@ -46,8 +46,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "bytebase/001foo__db1",
- filePathTemplate: "bytebase/{{VERSION}}__{{DB_NAME}}",
+ filePath: "bytebase/db1__001foo",
+ filePathTemplate: "bytebase/{{DB_NAME}}__{{VERSION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -61,8 +61,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "bytebase/dev/001foo__db1",
- filePathTemplate: "bytebase/{{ENV_NAME}}/{{VERSION}}__{{DB_NAME}}",
+ filePath: "bytebase/dev/db1__001foo",
+ filePathTemplate: "bytebase/{{ENV_NAME}}/{{DB_NAME}}__{{VERSION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -76,8 +76,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "001foo__db1__create_t1",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}__{{DESCRIPTION}}",
+ filePath: "db1__001foo__create_t1",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{DESCRIPTION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -91,8 +91,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "001foo__db1__migrate",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}__{{TYPE}}",
+ filePath: "db1__001foo__migrate",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -106,8 +106,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "001foo__db1__baseline",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}__{{TYPE}}",
+ filePath: "db1__001foo__baseline",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -121,8 +121,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "001foo__db1__baseline__create_t1",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}__{{TYPE}}__{{DESCRIPTION}}",
+ filePath: "db1__001foo__baseline__create_t1",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db1",
@@ -136,8 +136,8 @@ func TestParseMigrationInfo(t *testing.T) {
wantErr: "",
},
{
- filePath: "001foo__db_shop1__baseline__create_t1",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}__{{TYPE}}__{{DESCRIPTION}}",
+ filePath: "db_shop1__001foo__baseline__create_t1",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}",
want: MigrationInfo{
Version: "001foo",
Namespace: "db_shop1",
@@ -152,7 +152,7 @@ func TestParseMigrationInfo(t *testing.T) {
},
{
filePath: "db",
- filePathTemplate: "{{VERSION}}__{{DB_NAME}}",
+ filePathTemplate: "{{DB_NAME}}__{{VERSION}}",
want: MigrationInfo{
Version: "",
Namespace: "",