Skip to content

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

chore: allow create instance and database without the environment (#17207)

ecmadao6a947322a02b
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 556ca642e8..c096f2c9f8 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -1061,30 +1061,13 @@ func getPlanEnvironmentSnapshots(ctx context.Context, s *store.Store, deployment
return snapshotEnvironments, environmentIndex, nil
}
-// filterTasksByEnvironments filters tasks to only include those in the given environment index.
-func filterTasksByEnvironments(tasks []*store.TaskMessage, environmentIndex map[string]int) []*store.TaskMessage {
- filteredTasks := []*store.TaskMessage{}
- for _, task := range tasks {
- if _, ok := environmentIndex[task.Environment]; ok {
- filteredTasks = append(filteredTasks, task)
- }
- }
- return filteredTasks
-}
-
// GetPipelineCreate gets a pipeline create message from a plan.
func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.Manager, dbFactory *dbfactory.DBFactory, specs []*storepb.PlanConfig_Spec, deployment *storepb.PlanConfig_Deployment /* nullable */, project *store.ProjectMessage) (*store.PipelineMessage, error) {
// Step 1 - transform database group specs.
// Others are untouched.
transformedSpecs := applyDatabaseGroupSpecTransformations(specs, deployment)
- // Step 2 - list snapshot environments.
- _, environmentIndex, err := getPlanEnvironmentSnapshots(ctx, s, deployment)
- if err != nil {
- return nil, errors.Wrap(err, "failed to get plan environment snapshots")
- }
-
- // Step 3 - convert all task creates.
+ // Step 2 - convert all task creates.
var taskCreates []*store.TaskMessage
for _, spec := range transformedSpecs {
tcs, err := getTaskCreatesFromSpec(ctx, s, sheetManager, dbFactory, spec, project)
@@ -1094,12 +1077,9 @@ func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.
taskCreates = append(taskCreates, tcs...)
}
- // Filter out tasks not in deployment environments
- filteredTasks := filterTasksByEnvironments(taskCreates, environmentIndex)
-
return &store.PipelineMessage{
ProjectID: project.ResourceID,
- Tasks: filteredTasks,
+ Tasks: taskCreates,
}, nil
}
diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.go
index 0bd17801ee..ce28068642 100644
--- a/backend/api/v1/rollout_service_converter.go
+++ b/backend/api/v1/rollout_service_converter.go
@@ -620,19 +620,9 @@ func convertToRollout(ctx context.Context, s *store.Store, project *store.Projec
}
}
- environmentExists := make(map[string]bool)
- for _, env := range environmentOrder {
- environmentExists[env] = true
- }
-
// Group tasks by environment.
tasksByEnv := map[string][]*v1pb.Task{}
for _, task := range rollout.Tasks {
- // Skip tasks with environments not in the deployment list
- if !environmentExists[task.Environment] {
- continue
- }
-
rolloutTask, err := convertToTask(ctx, s, project, task)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to convert task"))
@@ -652,6 +642,20 @@ func convertToRollout(ctx context.Context, s *store.Store, project *store.Projec
Tasks: tasks,
})
}
+ delete(tasksByEnv, environment)
+ }
+
+ for environment, tasks := range tasksByEnv {
+ if len(tasks) > 0 {
+ stages = append([]*v1pb.Stage{
+ {
+ Name: common.FormatStage(project.ResourceID, rollout.ID, environment),
+ Id: environment,
+ Environment: common.FormatEnvironment(environment),
+ Tasks: tasks,
+ },
+ }, stages...)
+ }
}
rolloutV1.Stages = stages
diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.go
index 49ef79e4d3..1a31ca71bb 100644
--- a/backend/api/v1/rollout_service_task.go
+++ b/backend/api/v1/rollout_service_task.go
@@ -83,15 +83,6 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,
effectiveEnvironmentID = dbEnvironmentID
} else if instance.EnvironmentID != nil && *instance.EnvironmentID != "" {
effectiveEnvironmentID = *instance.EnvironmentID
- } else {
- return nil, errors.Errorf("no environment specified for instance %v", instance.ResourceID)
- }
- environment, err := s.GetEnvironmentByID(ctx, effectiveEnvironmentID)
- if err != nil {
- return nil, err
- }
- if environment == nil {
- return nil, errors.Errorf("environment ID not found %v", effectiveEnvironmentID)
}
if instance.Metadata.GetEngine() == storepb.Engine_MONGODB && c.Table == "" {
diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
index 043934464e..88a8555a9a 100644
--- a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
@@ -83,7 +83,6 @@
<div class="w-full">
<label for="environment" class="textlabel">
{{ $t("common.environment") }}
- <RequiredStar />
</label>
<EnvironmentSelect
v-model:environment-name="state.environmentName"
@@ -178,7 +177,6 @@ import {
import {
defaultCharsetOfEngineV1,
defaultCollationOfEngineV1,
- isValidEnvironmentName,
isValidInstanceName,
isValidProjectName,
UNKNOWN_PROJECT_NAME,
@@ -256,7 +254,6 @@ const allowCreate = computed(() => {
validDatabaseOwnerName.value &&
!isReservedName.value &&
isValidProjectName(state.projectName) &&
- isValidEnvironmentName(state.environmentName) &&
isValidInstanceName(state.instanceName)
);
});
diff --git a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
index 3af8995b86..653897c2fa 100644
--- a/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
+++ b/frontend/src/components/DatabaseAndGroupSelector/DatabaseAndGroupSelector.vue
@@ -20,7 +20,6 @@
:parent="project.name"
:filter="filter"
:size="'small'"
- :select-disabled="(db: ComposedDatabase) => !db.effectiveEnvironment"
v-model:selected-database-names="
databaseSelectState.selectedDatabaseNameList
"
@@ -57,7 +56,7 @@ import {
instanceNamePrefix,
environmentNamePrefix,
} from "@/store/modules/v1/common";
-import type { ComposedDatabase, ComposedProject } from "@/types";
+import type { ComposedProject } from "@/types";
import {
CommonFilterScopeIdList,
extractProjectResourceName,
diff --git a/frontend/src/components/InstanceForm/Form.vue b/frontend/src/components/InstanceForm/Form.vue
index a2240033b0..4540b236de 100644
--- a/frontend/src/components/InstanceForm/Form.vue
+++ b/frontend/src/components/InstanceForm/Form.vue
@@ -21,7 +21,7 @@
<div class="sm:col-span-2 sm:col-start-1">
<label for="name" class="textlabel flex flex-row items-center">
{{ $t("instance.instance-name") }}
- <span class="text-red-600 ml-0.5">*</span>
+ <RequiredStar class="ml-0.5" />
<div v-if="instance" class="ml-2 flex items-center">
<InstanceV1EngineIcon :instance="instance" :tooltip="false" />
<span class="ml-1">{{ instance.engineVersion }}</span>
@@ -87,7 +87,6 @@
<label for="environment" class="textlabel">
{{ $t("common.environment") }}
</label>
- <span class="text-red-600 ml-0.5">*</span>
<EnvironmentSelect
class="mt-1 w-full"
required="true"
@@ -120,7 +119,7 @@
<label for="host" class="textlabel block">
<template v-if="basicInfo.engine === Engine.SNOWFLAKE">
{{ $t("instance.account-locator") }}
- <span class="text-red-600 mr-2">*</span>
+ <RequiredStar class="mr-2" />
<LearnMoreLink
url="https://docs.snowflake.com/en/user-guide/admin-account-identifier#using-an-account-locator-as-an-identifier"
class="text-sm"
@@ -128,7 +127,7 @@
</template>
<template v-else-if="basicInfo.engine === Engine.COSMOSDB">
{{ $t("instance.endpoint") }}
- <span class="text-red-600 mr-2">*</span>
+ <RequiredStar class="mr-2" />
</template>
<div
v-else-if="
@@ -138,7 +137,7 @@
>
<span>
{{ $t("instance.sentence.google-cloud-sql.instance-name") }}
- <span class="text-red-600 mr-2">*</span>
+ <RequiredStar class="mr-2" />
</span>
<div class="textinfolabel mb-1">
{{
@@ -148,11 +147,10 @@
</div>
<template v-else>
{{ $t("instance.host-or-socket") }}
- <span
+ <RequiredStar
v-if="basicInfo.engine !== Engine.DYNAMODB"
- class="text-red-600 mr-2"
- >*</span
- >
+ class="mr-2"
+ />
</template>
</label>
<NInput
@@ -500,6 +498,7 @@ import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { BBAttention, BBBetaBadge } from "@/bbkit";
import { InstanceArchiveRestoreButton } from "@/components/Instance";
+import RequiredStar from "@/components/RequiredStar.vue";
import {
EnvironmentSelect,
InstanceEngineRadioGrid,
diff --git a/frontend/src/components/InstanceForm/common.ts b/frontend/src/components/InstanceForm/common.ts
index f9b12203e1..6862fc28c4 100644
--- a/frontend/src/components/InstanceForm/common.ts
+++ b/frontend/src/components/InstanceForm/common.ts
@@ -1,11 +1,7 @@
import { cloneDeep, first } from "lodash-es";
import { t } from "@/plugins/i18n";
import { useActuatorV1Store, useSubscriptionV1Store } from "@/store";
-import {
- emptyDataSource,
- UNKNOWN_ENVIRONMENT_NAME,
- UNKNOWN_INSTANCE_NAME,
-} from "@/types";
+import { emptyDataSource, UNKNOWN_INSTANCE_NAME } from "@/types";
import { Engine, State } from "@/types/proto-es/v1/common_pb";
import type {
DataSource,
@@ -73,7 +69,7 @@ export const extractBasicInfo = (instance: Instance | undefined): BasicInfo => {
title: instance?.title ?? t("instance.new-instance"),
engine: instance?.engine ?? Engine.MYSQL,
externalLink: instance?.externalLink ?? "",
- environment: instance?.environment ?? UNKNOWN_ENVIRONMENT_NAME,
+ environment: instance?.environment,
activation: instance
? instance.activation
: subscriptionStore.currentPlan !== PlanType.FREE &&
diff --git a/frontend/src/components/InstanceForm/context.ts b/frontend/src/components/InstanceForm/context.ts
index a287430bbf..959fc35838 100644
--- a/frontend/src/components/InstanceForm/context.ts
+++ b/frontend/src/components/InstanceForm/context.ts
@@ -9,12 +9,10 @@ import { useI18n } from "vue-i18n";
import { instanceServiceClientConnect } from "@/grpcweb";
import { silentContextKey } from "@/grpcweb/context-key";
import {
- environmentNamePrefix,
pushNotification,
useEnvironmentV1Store,
useSubscriptionV1Store,
} from "@/store";
-import { isValidEnvironmentName } from "@/types";
import { Engine, State } from "@/types/proto-es/v1/common_pb";
import {
CreateInstanceRequestSchema,
@@ -216,11 +214,6 @@ export const provideInstanceFormContext = (baseContext: {
if (!hasWorkspacePermissionV2("bb.instances.create")) {
return false;
}
- if (
- !isValidEnvironmentName(`${environmentNamePrefix}${environment.value.id}`)
- ) {
- return false;
- }
if (basicInfo.value.engine === Engine.SPANNER) {
return (
basicInfo.value.title.trim() &&
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
index 599056d052..fdd5c4fbaa 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
@@ -237,10 +237,6 @@ const databaseSupportAlterSchema = computed(() => {
});
});
-const existDatabaseWithoutEnvironment = computed(() =>
- props.databases.some((db) => !db.effectiveEnvironment)
-);
-
const allowEditSchema = computed(() => {
return props.databases.every((db) => {
return hasPermissionToCreateChangeDatabaseIssue(db);
@@ -447,7 +443,6 @@ const actions = computed((): DatabaseAction[] => {
text: t("custom-approval.risk-rule.risk.namespace.data_export"),
disabled:
!allowExportData.value ||
- existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -458,9 +453,6 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
- if (existDatabaseWithoutEnvironment.value) {
- return t("database.batch-action-database-not-have-environment");
- }
return "";
},
});
@@ -566,7 +558,6 @@ const actions = computed((): DatabaseAction[] => {
text: t("database.change-data"),
disabled:
!allowChangeData.value ||
- existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -577,9 +568,6 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
- if (existDatabaseWithoutEnvironment.value) {
- return t("database.batch-action-database-not-have-environment");
- }
return getDisabledTooltip(action);
},
});
@@ -591,7 +579,6 @@ const actions = computed((): DatabaseAction[] => {
disabled:
!databaseSupportAlterSchema.value ||
!allowEditSchema.value ||
- existDatabaseWithoutEnvironment.value ||
!selectedProjectName.value ||
props.databases.length < 1 ||
selectedProjectNames.value.has(DEFAULT_PROJECT_NAME),
@@ -605,9 +592,6 @@ const actions = computed((): DatabaseAction[] => {
action,
});
}
- if (existDatabaseWithoutEnvironment.value) {
- return t("database.batch-action-database-not-have-environment");
- }
return getDisabledTooltip(action);
},
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 4e8c472ba7..d6f37dc9c5 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1574,7 +1574,6 @@
"table-detail": "Table detail",
"batch-action-not-support-alter-schema": "Some databases don't support altering schema",
"batch-action-permission-denied": "Don't have permission to {action} for databases",
- "batch-action-database-not-have-environment": "Exist databases which not bound with the environment",
"batch-action-disabled": "Can not {action} for the databases from different projects",
"batch-action-disabled-for-unassigned": "Can not {action} for unassigned database",
"successfully-transferred-databases": "Successfully transferred databases",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index c2eedd85ff..04969df98d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1574,7 +1574,6 @@
"table-detail": "Detalle de la tabla",
"batch-action-not-support-alter-schema": "Algunas bases de datos no admiten la modificación del esquema",
"batch-action-permission-denied": "No tengo permiso para {action} para bases de datos",
- "batch-action-database-not-have-environment": "Existen bases de datos que no están vinculadas con el entorno",
"batch-action-disabled": "No se puede {action} para las bases de datos de diferentes proyectos",
"batch-action-disabled-for-unassigned": "No se puede {action} para una base de datos no asignada",
"successfully-transferred-databases": "Bases de datos transferidas exitosamente",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 80d7c107d2..248543b20d 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1574,7 +1574,6 @@
"table-detail": "テーブルの詳細",
"batch-action-not-support-alter-schema": "一部のデータベースはテーブル構造の変更をサポートしていません",
"batch-action-permission-denied": "データベース {action} に対する権限がありません",
- "batch-action-database-not-have-environment": "環境に縛られないデータベースが存在する",
"batch-action-disabled": "異なるプロジェクトのデータベース {action} を比較できません",
"batch-action-disabled-for-unassigned": "未割り当てのデータベース {action} にアクセスできません",
"successfully-transferred-databases": "データベースの移行が完了しました",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 458fda4091..7f0996ddcc 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1574,7 +1574,6 @@
"table-detail": "Chi tiết bảng",
"batch-action-not-support-alter-schema": "Một số cơ sở dữ liệu không hỗ trợ thay đổi lược đồ",
"batch-action-permission-denied": "Không có quyền {action} đối với cơ sở dữ liệu",
- "batch-action-database-not-have-environment": "Tồn tại các cơ sở dữ liệu không liên kết với môi trường",
"batch-action-disabled": "Không thể {action} đối với các cơ sở dữ liệu từ các dự án khác nhau",
"batch-action-disabled-for-unassigned": "Không thể {action} đối với cơ sở dữ liệu chưa được gán",
"successfully-transferred-databases": "Đã chuyển thành công cơ sở dữ liệu",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index a6548db083..59ccefe4e6 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1574,7 +1574,6 @@
"table-detail": "表详情",
"batch-action-not-support-alter-schema": "一些数据库不支持修改表结构",
"batch-action-permission-denied": "没有权限对数据库{action}",
- "batch-action-database-not-have-environment": "存在未与环境绑定的数据库",
"batch-action-disabled": "无法对来自不同项目的数据库{action}",
"batch-action-disabled-for-unassigned": "无法对未分配的数据库{action}",
"successfully-transferred-databases": "数据库转移完成",
diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
index 7dc2369b5e..b9d396dd04 100644
--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
@@ -104,14 +104,12 @@
</NButton>
<NButton
v-if="allowChangeData"
- :disabled="!database.effectiveEnvironment"
@click="createMigration('bb.issue.database.data.update')"
>
<span>{{ $t("database.change-data") }}</span>
</NButton>
<NButton
v-if="allowAlterSchema"
- :disabled="!database.effectiveEnvironment"
@click="createMigration('bb.issue.database.schema.update')"
>
<span>{{ $t("database.edit-schema") }}</span>