Skip to content

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

fix: skip non-env databases in DATABASE_MIGRATE task creation (#19320)

boojack158eec26be03
diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.go
index 3ad12e3e39..50a59faee7 100644
--- a/backend/api/v1/rollout_service_task.go
+++ b/backend/api/v1/rollout_service_task.go
@@ -186,10 +186,10 @@ func getTaskCreatesFromChangeDatabaseConfig(
var tasks []*store.TaskMessage
for _, database := range databases {
- env := ""
- if database.EffectiveEnvironmentID != nil {
- env = *database.EffectiveEnvironmentID
+ if database.EffectiveEnvironmentID == nil {
+ continue
}
+ env := *database.EffectiveEnvironmentID
// All change database tasks use DATABASE_MIGRATE type
taskType := storepb.Task_DATABASE_MIGRATE
@@ -239,6 +239,10 @@ func getTaskCreatesFromChangeDatabaseConfig(
tasks = append(tasks, taskCreate)
}
+ if len(tasks) == 0 {
+ return nil, errors.Errorf("cannot create tasks for spec %s: all target databases are missing an environment", spec.Id)
+ }
+
return tasks, nil
}
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index 3d2b5cc7f1..eaa13a548b 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -16,6 +16,13 @@
</NButton>
</div>
+ <NAlert v-if="!isLoadingTargets && nonEnvDatabaseNames.length > 0" type="warning">
+ {{ $t("plan.targets.non-env-warning", { count: nonEnvDatabaseNames.length }) }}
+ <ul class="list-disc list-inside text-sm mt-1">
+ <li v-for="name in nonEnvDatabaseNames" :key="name">{{ name }}</li>
+ </ul>
+ </NAlert>
+
<div v-if="isLoadingTargets" class="flex items-center justify-center py-2">
<BBSpin />
</div>
@@ -56,7 +63,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
import { isEqual } from "lodash-es";
-import { NButton } from "naive-ui";
+import { NAlert, NButton } from "naive-ui";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBSpin } from "@/bbkit";
@@ -114,6 +121,23 @@ const allowEdit = computed(() => {
return (isCreating.value || !plan.value.hasRollout) && selectedSpec.value;
});
+const getDatabaseNamesForTarget = (target: string): string[] => {
+ if (!isValidDatabaseGroupName(target)) return [target];
+ const dbGroup = dbGroupStore.getDBGroupByName(target);
+ return dbGroup?.matchedDatabases?.map((m) => m.name) ?? [];
+};
+
+const hasNoEnvironment = (name: string): boolean => {
+ return !dbStore.getDatabaseByName(name).effectiveEnvironment;
+};
+
+const nonEnvDatabaseNames = computed(() => {
+ if (isLoadingTargets.value) return [];
+ return targets.value
+ .flatMap(getDatabaseNamesForTarget)
+ .filter(hasNoEnvironment);
+});
+
// Separate targets by type
const visibleTargets = computed(() => {
return targets.value.slice(
diff --git a/frontend/src/components/Plan/logic/rolloutPreview.ts b/frontend/src/components/Plan/logic/rolloutPreview.ts
index 03499ee7cb..084661f42c 100644
--- a/frontend/src/components/Plan/logic/rolloutPreview.ts
+++ b/frontend/src/components/Plan/logic/rolloutPreview.ts
@@ -165,6 +165,9 @@ function groupTasksIntoStages(
for (const task of tasks) {
const db = databaseStore.getDatabaseByName(task.databaseName);
const env = db.effectiveEnvironment ?? "";
+ if (env === "") {
+ continue;
+ }
let envTasks = tasksByEnv.get(env);
if (!envTasks) {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 5303eb254f..92b167646b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1177,7 +1177,8 @@
"targets": {
"title": "Targets",
"no-targets-found": "No targets found",
- "view-all": "View all ({count})"
+ "view-all": "View all ({count})",
+ "non-env-warning": "{count} database will be excluded from rollout because it has no effective environment: | {count} databases will be excluded from rollout because they have no effective environment:"
},
"select-isolation-level": "Select isolation level",
"isolation-level": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index d704c5e8c9..c6468f647f 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1177,7 +1177,8 @@
"targets": {
"title": "Objetivos",
"no-targets-found": "No se encontraron objetivos",
- "view-all": "Ver todo ({count})"
+ "view-all": "Ver todo ({count})",
+ "non-env-warning": "{count} base de datos será excluida del despliegue porque no tiene un entorno efectivo: | {count} bases de datos serán excluidas del despliegue porque no tienen un entorno efectivo:"
},
"select-isolation-level": "Seleccionar nivel de aislamiento",
"isolation-level": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 76265892e5..8bf5574198 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1177,7 +1177,8 @@
"targets": {
"title": "ターゲット",
"no-targets-found": "ターゲットが見つかりません",
- "view-all": "すべて表示 ({count})"
+ "view-all": "すべて表示 ({count})",
+ "non-env-warning": "{count} 個のデータベースは有効な環境がないためロールアウトから除外されます: | {count} 個のデータベースは有効な環境がないためロールアウトから除外されます:"
},
"select-isolation-level": "分離レベルを選択",
"isolation-level": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index ac9dd4427b..6707047c5f 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1177,7 +1177,8 @@
"targets": {
"title": "Mục tiêu",
"no-targets-found": "Không tìm thấy mục tiêu",
- "view-all": "Xem tất cả ({count})"
+ "view-all": "Xem tất cả ({count})",
+ "non-env-warning": "{count} cơ sở dữ liệu sẽ bị loại khỏi triển khai vì không có môi trường hiệu lực: | {count} cơ sở dữ liệu sẽ bị loại khỏi triển khai vì không có môi trường hiệu lực:"
},
"select-isolation-level": "Chọn mức độ cô lập",
"isolation-level": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index d79bfa9a54..3deb708731 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1177,7 +1177,8 @@
"targets": {
"title": "目标库",
"no-targets-found": "未找到目标库",
- "view-all": "查看全部 ({count})"
+ "view-all": "查看全部 ({count})",
+ "non-env-warning": "{count} 个数据库因没有环境将被排除在发布任务之外:"
},
"select-isolation-level": "选择隔离级别",
"isolation-level": {