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: use ENV_ID instead of ENV_NAME for git file path (#5082)
Danny Xub1c9dea1c94b
diff --git a/backend/legacyapi/project.go b/backend/legacyapi/project.goindex 44123dbe3e..f8f773eafb 100644--- a/backend/legacyapi/project.go+++ b/backend/legacyapi/project.go@@ -147,7 +147,7 @@ var (// DBNameToken is the token for database name.DBNameToken = "{{DB_NAME}}"// EnvironmentToken is the token for environment.- EnvironmentToken = "{{ENV_NAME}}"+ EnvironmentToken = "{{ENV_ID}}"// LocationToken is the token for location.LocationToken = "{{LOCATION}}"// TenantToken is the token for tenant.diff --git a/backend/legacyapi/project_test.go b/backend/legacyapi/project_test.goindex dcd6a811bd..c87ab5f4ba 100644--- a/backend/legacyapi/project_test.go+++ b/backend/legacyapi/project_test.go@@ -54,7 +54,7 @@ func TestValidateRepositoryFilePathTemplate(t *testing.T) {"",}, {"OK with optional tokens",- "{{ENV_NAME}}/{{DB_NAME}}_{{TYPE}}_{{VERSION}}_{{DESCRIPTION}}.sql",+ "{{ENV_ID}}/{{DB_NAME}}_{{TYPE}}_{{VERSION}}_{{DESCRIPTION}}.sql",TenantModeDisabled,"",}, {@@ -74,8 +74,8 @@ func TestValidateRepositoryFilePathTemplate(t *testing.T) {"unknown token {{UNKNOWN}}",},{- "Tenant mode {{ENV_NAME}}",- "{{ENV_NAME}}/{{VERSION}}_{{TYPE}}.sql",+ "Tenant mode {{ENV_ID}}",+ "{{ENV_ID}}/{{VERSION}}_{{TYPE}}.sql",TenantModeTenant,"in file path template",},@@ -120,7 +120,7 @@ func TestValidateRepositorySchemaPathTemplate(t *testing.T) {"",}, {"OK with optional tokens",- "{{ENV_NAME}}/{{DB_NAME}}.sql",+ "{{ENV_ID}}/{{DB_NAME}}.sql",TenantModeDisabled,"",}, {@@ -129,8 +129,8 @@ func TestValidateRepositorySchemaPathTemplate(t *testing.T) {TenantModeDisabled,"unknown token {{TYPE}}",}, {- "Tenant mode {{ENV_NAME}}",- "{{ENV_NAME}}/LATEST.sql",+ "Tenant mode {{ENV_ID}}",+ "{{ENV_ID}}/LATEST.sql",TenantModeTenant,"in schema path template",}, {diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.goindex f0a923091e..1dd016b5ab 100644--- a/backend/plugin/db/driver.go+++ b/backend/plugin/db/driver.go@@ -189,7 +189,7 @@ const placeholderRegexp = `[^\\/?%*:|"<>]+`// It returns (nil, nil) if it doesn't look like a migration file path.func ParseMigrationInfo(filePath, filePathTemplate string, allowOmitDatabaseName bool) (*MigrationInfo, error) {placeholderList := []string{- "ENV_NAME",+ "ENV_ID","VERSION","DB_NAME","TYPE",@@ -223,7 +223,7 @@ func ParseMigrationInfo(filePath, filePathTemplate string, allowOmitDatabaseNameindex := myRegex.SubexpIndex(placeholder)if index >= 0 {switch placeholder {- case "ENV_NAME":+ case "ENV_ID":mi.Environment = matchList[index]case "VERSION":mi.Version = matchList[index]@@ -287,7 +287,7 @@ func ParseSchemaFileInfo(baseDirectory, schemaPathTemplate, file string) (*MigraschemaFilePathRegex := strings.ReplaceAll(schemaPathTemplate, ".", `\.`)placeholders := []string{- "ENV_NAME",+ "ENV_ID","DB_NAME",}for _, placeholder := range placeholders {@@ -313,7 +313,7 @@ func ParseSchemaFileInfo(baseDirectory, schemaPathTemplate, file string) (*Migrareturn &MigrationInfo{Source: VCS,Type: Migrate,- Environment: info["ENV_NAME"],+ Environment: info["ENV_ID"],Database: info["DB_NAME"],}, nil}diff --git a/backend/plugin/db/driver_test.go b/backend/plugin/db/driver_test.goindex 641e6db27e..e0b08fac61 100644--- a/backend/plugin/db/driver_test.go+++ b/backend/plugin/db/driver_test.go@@ -65,7 +65,7 @@ func TestParseMigrationInfo(t *testing.T) {},{filePath: "bytebase/dev/db1##001foo",- filePathTemplate: "bytebase/{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}",+ filePathTemplate: "bytebase/{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}",want: &MigrationInfo{Version: "001foo",Namespace: "db1",@@ -276,9 +276,9 @@ func TestParseSchemaFileInfo(t *testing.T) {},},{- name: "has both ENV_NAME and DB_NAME",+ name: "has both ENV_ID and DB_NAME",baseDirectory: "",- schemaPathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##LATEST.sql",+ schemaPathTemplate: "{{ENV_ID}}/{{DB_NAME}}##LATEST.sql",file: "Test/testdb##LATEST.sql",schemaInfo: &MigrationInfo{Source: VCS,@@ -291,14 +291,14 @@ func TestParseSchemaFileInfo(t *testing.T) {{name: "baseDirectory does not match",baseDirectory: "bytebase",- schemaPathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##LATEST.sql",+ schemaPathTemplate: "{{ENV_ID}}/{{DB_NAME}}##LATEST.sql",file: "Test/testdb##LATEST.sql",schemaInfo: nil,},{- name: "baseDirectory with both ENV_NAME and DB_NAME",+ name: "baseDirectory with both ENV_ID and DB_NAME",baseDirectory: "bytebase",- schemaPathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##LATEST.sql",+ schemaPathTemplate: "{{ENV_ID}}/{{DB_NAME}}##LATEST.sql",file: "bytebase/Test/testdb##LATEST.sql",schemaInfo: &MigrationInfo{Source: VCS,diff --git a/backend/plugin/vcs/vcs_test.go b/backend/plugin/vcs/vcs_test.goindex 2c11d31300..a8ebb9e1cf 100644--- a/backend/plugin/vcs/vcs_test.go+++ b/backend/plugin/vcs/vcs_test.go@@ -16,24 +16,24 @@ func TestIsDoubleTimesAsteriskInTemplateValid(t *testing.T) {err: true,},{- template: "bytebase/{{ENV_NAME}}/**",+ template: "bytebase/{{ENV_ID}}/**",err: true,},{- template: "**/{{ENV_NAME}}/{{DB_NAME}}.sql",+ template: "**/{{ENV_ID}}/{{DB_NAME}}.sql",err: true,},{- template: "bytebase/**/{{ENV_NAME}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ template: "bytebase/**/{{ENV_ID}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",err: false,},{- template: "/**/{{ENV_NAME}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ template: "/**/{{ENV_ID}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",err: false,},// Credit to Linear Issue BYT-1267{- template: "/configure/configure/{{ENV_NAME}}/**/**/{{DESCRIPTION}}.sql",+ template: "/configure/configure/{{ENV_ID}}/**/**/{{DESCRIPTION}}.sql",err: false,},}diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.goindex 66c7de4be2..7fce45a4d2 100644--- a/backend/runner/taskrun/executor.go+++ b/backend/runner/taskrun/executor.go@@ -371,7 +371,7 @@ func postMigration(ctx context.Context, stores *store.Store, activityManager *ac}latestSchemaFile := filepath.Join(repo.BaseDirectory, repo.SchemaPathTemplate)- latestSchemaFile = strings.ReplaceAll(latestSchemaFile, "{{ENV_NAME}}", mi.Environment)+ latestSchemaFile = strings.ReplaceAll(latestSchemaFile, "{{ENV_ID}}", mi.Environment)latestSchemaFile = strings.ReplaceAll(latestSchemaFile, "{{DB_NAME}}", mi.Database)vcs, err := stores.GetVCSByID(ctx, repo.VCSID)diff --git a/backend/server/project.go b/backend/server/project.goindex d716f257bb..4065972f13 100644--- a/backend/server/project.go+++ b/backend/server/project.go@@ -883,8 +883,8 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {}var databaseID *int- // In non-tenant mode, we can set a databaseId for sheet with ENV_NAME and DB_NAME,- // and ENV_NAME and DB_NAME is either both present or neither present.+ // In non-tenant mode, we can set a databaseId for sheet with ENV_ID and DB_NAME,+ // and ENV_ID and DB_NAME is either both present or neither present.if project.TenantMode != api.TenantModeDisabled {if sheetInfo.EnvironmentID != "" && sheetInfo.DatabaseName != "" {databases, err := s.store.ListDatabases(ctx, &store.FindDatabaseMessage{ProjectID: &project.ResourceID, DatabaseName: &sheetInfo.DatabaseName})diff --git a/backend/server/sheet.go b/backend/server/sheet.goindex 9a6c8beacf..7626d370ae 100644--- a/backend/server/sheet.go+++ b/backend/server/sheet.go@@ -250,7 +250,7 @@ type SheetInfo struct {// Both sheetPath and sheetPathTemplate are the full file path(including the base directory) of the repository.func parseSheetInfo(sheetPath string, sheetPathTemplate string) (*SheetInfo, error) {placeholderList := []string{- "ENV_NAME",+ "ENV_ID","DB_NAME","NAME",}@@ -272,7 +272,7 @@ func parseSheetInfo(sheetPath string, sheetPathTemplate string) (*SheetInfo, errindex := sheetRegex.SubexpIndex(placeholder)if index >= 0 {switch placeholder {- case "ENV_NAME":+ case "ENV_ID":sheetInfo.EnvironmentID = matchList[index]case "DB_NAME":sheetInfo.DatabaseName = matchList[index]diff --git a/backend/server/sheet_test.go b/backend/server/sheet_test.goindex 91cf4425dc..3ec1600c18 100644--- a/backend/server/sheet_test.go+++ b/backend/server/sheet_test.go@@ -26,7 +26,7 @@ func TestParseSheetInfo(t *testing.T) {},{filePath: "sheet/dev##TEST##test.sql",- sheetPathTemplate: "sheet/{{ENV_NAME}}##{{DB_NAME}}##{{NAME}}.sql",+ sheetPathTemplate: "sheet/{{ENV_ID}}##{{DB_NAME}}##{{NAME}}.sql",want: &SheetInfo{EnvironmentID: "dev",DatabaseName: "TEST",@@ -36,7 +36,7 @@ func TestParseSheetInfo(t *testing.T) {},{filePath: "sheet/dev##test.sql",- sheetPathTemplate: "sheet/{{ENV_NAME}}##{{NAME}}.sql",+ sheetPathTemplate: "sheet/{{ENV_ID}}##{{NAME}}.sql",want: &SheetInfo{EnvironmentID: "dev",DatabaseName: "",diff --git a/backend/store/demo/default/10180##repository.sql b/backend/store/demo/default/10180##repository.sqlindex 33d717aa5c..4c2e167f85 100644--- a/backend/store/demo/default/10180##repository.sql+++ b/backend/store/demo/default/10180##repository.sql@@ -35,8 +35,8 @@ VALUES'http://gitlab.bytebase.com/bytebase-demo/blog','master','bytebase',- '{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql',- '{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql',+ '{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql',+ '{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql','script/{{NAME}}.sql',-- Refers to the bytebase-demo/blog'13',@@ -86,9 +86,9 @@ VALUES'http://gitlab.bytebase.com/bytebase-demo/shop','master','bytebase',- '{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql',- '{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql',- 'script/{{ENV_NAME}}##{{DB_NAME}}##{{NAME}}.sql',+ '{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql',+ '{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql',+ 'script/{{ENV_ID}}##{{DB_NAME}}##{{NAME}}.sql',-- Refers to the bytebase-demo/shop'14',-- Refers to the webhook in bytebase-demo/shopdiff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.goindex 0d9b4fed4d..38bb57dd50 100644--- a/backend/tests/schema_update_test.go+++ b/backend/tests/schema_update_test.go@@ -409,8 +409,8 @@ func TestVCS(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, test.repositoryFullPath),BranchFilter: "feature/foo",BaseDirectory: baseDirectory,- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalID: test.externalID,AccessToken: "accessToken1",RefreshToken: "refreshToken1",@@ -846,8 +846,8 @@ func TestVCS_SDL(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, test.repositoryFullPath),BranchFilter: "feature/foo",BaseDirectory: baseDirectory,- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalID: test.externalID,AccessToken: "accessToken1",RefreshToken: "refreshToken1",@@ -1118,7 +1118,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {vcsType: vcs.GitLab,baseDirectory: "bbtest",envName: "wildcard",- filePathTemplate: "{{ENV_NAME}}/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ filePathTemplate: "{{ENV_ID}}/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",commitNewFileNames: []string{// Normalfmt.Sprintf("%s/%s/foo/%s##ver1##migrate##create_table_t1.sql", baseDirectory, "wildcard", dbName),@@ -1145,7 +1145,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {vcsType: vcs.GitLab,baseDirectory: "bbtest",envName: "wildcard",- filePathTemplate: "{{ENV_NAME}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ filePathTemplate: "{{ENV_ID}}/**/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",commitNewFileNames: []string{// Two singleAsterisk can match one directory.fmt.Sprintf("%s/%s/foo/%s##ver1##migrate##create_table_t1.sql", baseDirectory, "wildcard", dbName),@@ -1176,7 +1176,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {envName: "wildcard",baseDirectory: "",vcsType: vcs.GitLab,- filePathTemplate: "{{ENV_NAME}}/**/foo/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ filePathTemplate: "{{ENV_ID}}/**/foo/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",commitNewFileNames: []string{// ** matches foo, foo matches foo, * matches barfmt.Sprintf("%s/foo/foo/bar/%s##ver1##migrate##create_table_t1.sql", "wildcard", dbName),@@ -1204,7 +1204,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {envName: "prod1",baseDirectory: "bbtest",vcsType: vcs.GitLab,- filePathTemplate: "{{ENV_NAME}}/**/foo/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ filePathTemplate: "{{ENV_ID}}/**/foo/*/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",commitNewFileNames: []string{// ** matches foo, foo matches foo, * matches barfmt.Sprintf("%s/%s/foo/foo/bar/%s##ver1##migrate##create_table_t1.sql", baseDirectory, "prod1", dbName),@@ -1232,7 +1232,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {envName: "ZO",baseDirectory: "bbtest",vcsType: vcs.GitLab,- filePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}/sql/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ filePathTemplate: "{{ENV_ID}}/{{DB_NAME}}/sql/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",commitNewFileNames: []string{fmt.Sprintf("%s/%s/%s/sql/%s##ver1##migrate##create_table_t1.sql", baseDirectory, "ZO", dbName, dbName),fmt.Sprintf("%s/%s/%s/%s##ver2##migrate##create_table_t2.sql", baseDirectory, "ZO", dbName, dbName),@@ -1312,7 +1312,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {BranchFilter: branchFilter,BaseDirectory: test.baseDirectory,FilePathTemplate: test.filePathTemplate,- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalID: externalID,AccessToken: "accessToken1",RefreshToken: "refreshToken1",@@ -1580,8 +1580,8 @@ func TestVCS_SQL_Review(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, test.repositoryFullPath),BranchFilter: "feature/foo",BaseDirectory: baseDirectory,- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalID: test.externalID,AccessToken: "accessToken1",RefreshToken: "refreshToken1",@@ -1817,7 +1817,7 @@ func TestBranchNameInVCSSetupAndUpdate(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, vcsTest.repoFullPath),BranchFilter: test.branchFilter,BaseDirectory: "",- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",SchemaPathTemplate: "",ExternalID: vcsTest.externalID,AccessToken: "accessToken1",@@ -2383,8 +2383,8 @@ func TestVCS_SDL_MySQL(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, test.repositoryFullPath),BranchFilter: "feature/foo",BaseDirectory: baseDirectory,- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",ExternalID: test.externalID,AccessToken: "accessToken1",RefreshToken: "refreshToken1",diff --git a/backend/tests/sheet_vcs_test.go b/backend/tests/sheet_vcs_test.goindex b3c8a9e702..e3029ad2ef 100644--- a/backend/tests/sheet_vcs_test.go+++ b/backend/tests/sheet_vcs_test.go@@ -93,8 +93,8 @@ func TestSheetVCS(t *testing.T) {WebURL: fmt.Sprintf("%s/%s", ctl.vcsURL, test.repositoryFullPath),BranchFilter: "feature/foo",BaseDirectory: baseDirectory,- FilePathTemplate: "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",- SchemaPathTemplate: "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql",+ FilePathTemplate: "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql",+ SchemaPathTemplate: "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql",SheetPathTemplate: "sheet/{{NAME}}.sql",ExternalID: test.externalID,AccessToken: "accessToken1",diff --git a/docs/design/gh-ost-integration.md b/docs/design/gh-ost-integration.mdindex e254fe09dc..4433a1521e 100644--- a/docs/design/gh-ost-integration.md+++ b/docs/design/gh-ost-integration.md@@ -223,7 +223,7 @@ Users can set a workspace-level gh-ost configuration, which will be the default.In the UI workflow, the user can select to use gh-ost and supply statements.-In the VCS workflow, user commit `{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.ghost.sql` to trigger gh-ost to execute migration. We use the suffix to tell if it is a gh-ost migration. The content is a vanilla SQL statement.+In the VCS workflow, user commit `{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.ghost.sql` to trigger gh-ost to execute migration. We use the suffix to tell if it is a gh-ost migration. The content is a vanilla SQL statement.Users can change the gh-ost configuration in the related issue tab.diff --git a/docs/design/tenancy.md b/docs/design/tenancy.mdindex 2618dff65a..b0a2e27703 100644--- a/docs/design/tenancy.md+++ b/docs/design/tenancy.md@@ -215,7 +215,7 @@ Tenant mode projects should show databases in tenant view (TBD). Schema altering#### VCSSince we will still take the database name that's plugged to deployment configuration, the [file path template](https://www.bytebase.com/docs/vcs-integration/name-and-organize-schema-files#file-path-template) will not change.```-{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql+{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql```#### Other Workflowsdiff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vueindex 500b44573a..edc4143b73 100644--- a/frontend/src/components/RepositoryForm.vue+++ b/frontend/src/components/RepositoryForm.vue@@ -247,7 +247,7 @@<span class="text-red-600">*</span>{{ $t("common.required-placeholder") }}: {{ "\{\{NAME\}\}" }};<template v-if="schemaOptionalTagPlaceholder.length > 0">- {{ $t("common.optional-placeholder") }}: {{ "\{\{ENV_NAME\}\}" }},+ {{ $t("common.optional-placeholder") }}: {{ "\{\{ENV_ID\}\}" }},{{ "\{\{DB_NAME\}\}" }}</template></div>@@ -399,7 +399,7 @@ export default defineComponent({sampleText: type,},{- placeholder: "{{ENV_NAME}}",+ placeholder: "{{ENV_ID}}",sampleText: "env1",},{@@ -442,8 +442,8 @@ export default defineComponent({const fileOptionalPlaceholder = computed(() => {const tags = [] as string[];- // Only allows {{ENV_NAME}} to be an optional placeholder for non-tenant mode projects- if (!isTenantProject.value) tags.push("{{ENV_NAME}}");+ // Only allows {{ENV_ID}} to be an optional placeholder for non-tenant mode projects+ if (!isTenantProject.value) tags.push("{{ENV_ID}}");tags.push("{{DESCRIPTION}}");return tags;});@@ -457,8 +457,8 @@ export default defineComponent({const schemaOptionalTagPlaceholder = computed(() => {const tags = [] as string[];- // Only allows {{ENV_NAME}} to be an optional placeholder for non-tenant mode projects- if (!isTenantProject.value) tags.push("{{ENV_NAME}}");+ // Only allows {{ENV_ID}} to be an optional placeholder for non-tenant mode projects+ if (!isTenantProject.value) tags.push("{{ENV_ID}}");return tags;});diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vueindex 487eb8e6ad..10fea1538a 100644--- a/frontend/src/components/RepositorySetupWizard.vue+++ b/frontend/src/components/RepositorySetupWizard.vue@@ -151,14 +151,14 @@ import { useProjectStore, useRepositoryStore, hasFeature } from "@/store";// Default file path template is to organize migration files from different environments under separate directories.const DEFAULT_FILE_PATH_TEMPLATE =- "{{ENV_NAME}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql";+ "{{ENV_ID}}/{{DB_NAME}}##{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql";// Default schema path template is co-locate with the corresponding db's migration files and use .(dot) to appear the first.-const DEFAULT_SCHEMA_PATH_TEMPLATE = "{{ENV_NAME}}/.{{DB_NAME}}##LATEST.sql";+const DEFAULT_SCHEMA_PATH_TEMPLATE = "{{ENV_ID}}/.{{DB_NAME}}##LATEST.sql";// Default sheet path tempalte is to organize script files for SQL Editor.const DEFAULT_SHEET_PATH_TEMPLATE =- "script/{{ENV_NAME}}##{{DB_NAME}}##{{NAME}}.sql";+ "script/{{ENV_ID}}##{{DB_NAME}}##{{NAME}}.sql";-// For tenant mode projects, {{ENV_NAME}} and {{DB_NAME}} is not supported.+// For tenant mode projects, {{ENV_ID}} and {{DB_NAME}} is not supported.const DEFAULT_TENANT_MODE_FILE_PATH_TEMPLATE ="{{VERSION}}##{{TYPE}}##{{DESCRIPTION}}.sql";const DEFAULT_TENANT_MODE_SCHEMA_PATH_TEMPLATE = ".LATEST.sql";diff --git a/frontend/src/types/proto/v1/externalvs_service.ts b/frontend/src/types/proto/v1/externalvs_service.tsindex 92fdc6a1bc..00b82d4d93 100644--- a/frontend/src/types/proto/v1/externalvs_service.ts+++ b/frontend/src/types/proto/v1/externalvs_service.ts@@ -184,19 +184,19 @@ export interface ProjectGitOpsInfo {/*** Bytebase only observes the file path name matching the template pattern **relative** to the base directory.* Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}.- * Optional Placeholder: {{ENV_NAME}}, {{DESCRIPTION}}.+ * Optional Placeholder: {{ENV_ID}}, {{DESCRIPTION}}.* Optional Directory Wildcard: '*', '**'.*/filePathTemplate: string;/*** The file path template for storing the latest schema auto-generated by Bytebase after migration.* If empty, then Bytebase won't auto generate it.- * If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_NAME}}.+ * If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.*/schemaPathTemplate: string;/*** The file path template for matching the sql files for sheet.- * If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_NAME}}, {{DB_NAME}}.+ * If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.*/sheetPathTemplate: string;/** Set to true to enable SQL review CI for all PR/MRs. */diff --git a/frontend/src/types/repository.ts b/frontend/src/types/repository.tsindex ede8f9245c..8f380dcbdd 100644--- a/frontend/src/types/repository.ts+++ b/frontend/src/types/repository.ts@@ -84,7 +84,7 @@ type WebUrlReplaceParams = {DB_NAME?: string;VERSION?: string;TYPE?: "ddl" | "dml";- ENV_NAME?: string;+ ENV_ID?: string;};export function baseDirectoryWebUrl(@@ -115,18 +115,18 @@ export function baseDirectoryWebUrl(// Once we meet a "dynamic" segment which has a pattern that cannot be replaced// we won't push it, either the segments behind it.// E.g., the filePathTemplate is- // configure/{{ENV_NAME}}/20220707-wechat/{{TYPE}}/**/**/**/{{DB_NAME}}##{{VERSION}}##{{DESCRIPTION}}.sql+ // configure/{{ENV_ID}}/20220707-wechat/{{TYPE}}/**/**/**/{{DB_NAME}}##{{VERSION}}##{{DESCRIPTION}}.sql/**The segments are- configure- - {{ENV_NAME}}+ - {{ENV_ID}}- 20220707-wechat- {{TYPE}}- **- **- **When- - ENV_NAME=dev+ - ENV_ID=dev- TYPE=migratewe are confident enough that the path will be started with"/configure/dev/20220707-wechat/migrate"diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 4834772041..ae76ba86bf 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -1907,9 +1907,9 @@ The environment's `name` field is used to identify the environment to update| web_url | [string](#string) | | The web url of the repository. For axample: https://gitlab.bytebase.com/bytebase/sample. || branch_filter | [string](#string) | | The branch Bytebase listens to for changes. For example: main. || base_directory | [string](#string) | | The root directory where Bytebase observes the file change. If empty, then it observes the entire repository. |-| file_path_template | [string](#string) | | Bytebase only observes the file path name matching the template pattern **relative** to the base directory. Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}. Optional Placeholder: {{ENV_NAME}}, {{DESCRIPTION}}. Optional Directory Wildcard: '*', '**'. |-| schema_path_template | [string](#string) | | The file path template for storing the latest schema auto-generated by Bytebase after migration. If empty, then Bytebase won't auto generate it. If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_NAME}}. |-| sheet_path_template | [string](#string) | | The file path template for matching the sql files for sheet. If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_NAME}}, {{DB_NAME}}. |+| file_path_template | [string](#string) | | Bytebase only observes the file path name matching the template pattern **relative** to the base directory. Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}. Optional Placeholder: {{ENV_ID}}, {{DESCRIPTION}}. Optional Directory Wildcard: '*', '**'. |+| schema_path_template | [string](#string) | | The file path template for storing the latest schema auto-generated by Bytebase after migration. If empty, then Bytebase won't auto generate it. If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}. |+| sheet_path_template | [string](#string) | | The file path template for matching the sql files for sheet. If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}. || enable_sql_review_ci | [bool](#bool) | | Set to true to enable SQL review CI for all PR/MRs. || webhook_endpoint_id | [string](#string) | | The webhook endpoint ID of the repository. |diff --git a/proto/generated-go/v1/externalvs_service.pb.go b/proto/generated-go/v1/externalvs_service.pb.goindex 7a3917c414..87428503ac 100644--- a/proto/generated-go/v1/externalvs_service.pb.go+++ b/proto/generated-go/v1/externalvs_service.pb.go@@ -730,15 +730,15 @@ type ProjectGitOpsInfo struct {BaseDirectory string `protobuf:"bytes,6,opt,name=base_directory,json=baseDirectory,proto3" json:"base_directory,omitempty"`// Bytebase only observes the file path name matching the template pattern **relative** to the base directory.// Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}.- // Optional Placeholder: {{ENV_NAME}}, {{DESCRIPTION}}.+ // Optional Placeholder: {{ENV_ID}}, {{DESCRIPTION}}.// Optional Directory Wildcard: '*', '**'.FilePathTemplate string `protobuf:"bytes,7,opt,name=file_path_template,json=filePathTemplate,proto3" json:"file_path_template,omitempty"`// The file path template for storing the latest schema auto-generated by Bytebase after migration.// If empty, then Bytebase won't auto generate it.- // If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_NAME}}.+ // If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.SchemaPathTemplate string `protobuf:"bytes,8,opt,name=schema_path_template,json=schemaPathTemplate,proto3" json:"schema_path_template,omitempty"`// The file path template for matching the sql files for sheet.- // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_NAME}}, {{DB_NAME}}.+ // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.SheetPathTemplate string `protobuf:"bytes,9,opt,name=sheet_path_template,json=sheetPathTemplate,proto3" json:"sheet_path_template,omitempty"`// Set to true to enable SQL review CI for all PR/MRs.EnableSqlReviewCi bool `protobuf:"varint,10,opt,name=enable_sql_review_ci,json=enableSqlReviewCi,proto3" json:"enable_sql_review_ci,omitempty"`diff --git a/proto/v1/externalvs_service.proto b/proto/v1/externalvs_service.protoindex 33e7514824..6f3ff5e23c 100644--- a/proto/v1/externalvs_service.proto+++ b/proto/v1/externalvs_service.proto@@ -198,17 +198,17 @@ message ProjectGitOpsInfo {// Bytebase only observes the file path name matching the template pattern **relative** to the base directory.// Required Placeholder: {{DB_NAME}}, {{VERSION}}, {{TYPE]}.- // Optional Placeholder: {{ENV_NAME}}, {{DESCRIPTION}}.+ // Optional Placeholder: {{ENV_ID}}, {{DESCRIPTION}}.// Optional Directory Wildcard: '*', '**'.string file_path_template = 7 [(google.api.field_behavior) = REQUIRED];// The file path template for storing the latest schema auto-generated by Bytebase after migration.// If empty, then Bytebase won't auto generate it.- // If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_NAME}}.+ // If specified, required placeholder: {{DB_NAME}}, optional placeholder: {{ENV_ID}}.string schema_path_template = 8;// The file path template for matching the sql files for sheet.- // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_NAME}}, {{DB_NAME}}.+ // If specified, required Placeholder: {{NAME}}, optional Placeholder: {{ENV_ID}}, {{DB_NAME}}.string sheet_path_template = 9;// Set to true to enable SQL review CI for all PR/MRs.