Skip to content

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

chore: use UpdateDatabase to resolve drifted (#15900)

boojack6b938c588752
diff --git a/frontend/src/components/Database/DatabaseChangelogPanel.vue b/frontend/src/components/Database/DatabaseChangelogPanel.vue
index b80505dc66..30d8f7ef40 100644
--- a/frontend/src/components/Database/DatabaseChangelogPanel.vue
+++ b/frontend/src/components/Database/DatabaseChangelogPanel.vue
@@ -103,7 +103,7 @@
})
"
:description="$t('changelog.establish-baseline-description')"
- @ok="doCreateBaseline"
+ @ok="updateDatabaseDrift"
@cancel="state.showBaselineModal = false"
/>
</template>
@@ -125,11 +125,12 @@ import {
import { useDatabaseDetailContext } from "@/components/Database/context";
import { TooltipButton } from "@/components/v2";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
+import { PROJECT_V1_ROUTE_SYNC_SCHEMA } from "@/router/dashboard/projectV1";
import {
- PROJECT_V1_ROUTE_ISSUE_DETAIL,
- PROJECT_V1_ROUTE_SYNC_SCHEMA,
-} from "@/router/dashboard/projectV1";
-import { useChangelogStore } from "@/store";
+ pushNotification,
+ useChangelogStore,
+ useDatabaseV1Store,
+} from "@/store";
import type { ComposedDatabase, Table, SearchChangeLogParams } from "@/types";
import { DEFAULT_PROJECT_NAME, getDateForPbTimestamp } from "@/types";
import {
@@ -157,6 +158,7 @@ const props = defineProps<{
const { t } = useI18n();
const router = useRouter();
const changelogStore = useChangelogStore();
+const databaseStore = useDatabaseV1Store();
const changedlogPagedTable =
ref<ComponentExposed<typeof PagedTable<Changelog>>>();
@@ -303,22 +305,19 @@ const handleExportChangelogs = async () => {
state.isExporting = false;
};
-const doCreateBaseline = () => {
- state.showBaselineModal = false;
-
- router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
- params: {
- projectId: extractProjectResourceName(props.database.project),
- issueSlug: "create",
- },
- query: {
- template: "bb.issue.database.schema.baseline",
- name: t("changelog.establish-database-baseline", {
- name: props.database.databaseName,
- }),
- databaseList: props.database.name,
+const updateDatabaseDrift = async () => {
+ await databaseStore.updateDatabase({
+ database: {
+ ...props.database,
+ drifted: false,
},
+ updateMask: ["drifted"],
});
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("database.drifted.new-baseline.successfully-established"),
+ });
+ state.showBaselineModal = false;
};
</script>
diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.ts
index 1c41fc6798..8e3b0be751 100644
--- a/frontend/src/components/IssueV1/logic/initialize/create.ts
+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts
@@ -345,12 +345,6 @@ export const buildSpecForTarget = async (
spec.changeDatabaseConfig.schemaVersion = version;
}
}
- if (template === "bb.issue.database.schema.baseline") {
- spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromJSON({
- target,
- type: Plan_ChangeDatabaseConfig_Type.BASELINE,
- });
- }
if (template === "bb.issue.database.data.export") {
spec.exportDataConfig = Plan_ExportDataConfig.fromJSON({
target,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index ee80ed8742..3681013c76 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1495,6 +1495,10 @@
"schema-drift-detected": {
"self": "Schema drift detected",
"description": "The schema is different from the last applied schema. This may cause application errors and should be resolved."
+ },
+ "new-baseline": {
+ "self": "New baseline",
+ "successfully-established": "Successfully established new baseline"
}
}
},
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 8312fc0e71..e9303b20c8 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1495,6 +1495,10 @@
"schema-drift-detected": {
"self": "Se detectó una desviación del esquema",
"description": "El esquema es diferente del último aplicado. Esto puede causar errores de aplicación y debe solucionarse."
+ },
+ "new-baseline": {
+ "self": "Nueva línea base",
+ "successfully-established": "Se estableció con éxito una nueva línea base"
}
}
},
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 4e10075633..77030fb5b4 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1495,6 +1495,10 @@
"schema-drift-detected": {
"self": "スキーマドリフトが検出されました",
"description": "スキーマが最後に適用されたスキーマと異なります。アプリケーションエラーが発生する可能性があるため、解決する必要があります。"
+ },
+ "new-baseline": {
+ "self": "新しいベースライン",
+ "successfully-established": "新しいベースラインを確立しました"
}
}
},
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 3a2a94ebfd..9a1fde5427 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1495,6 +1495,10 @@
"schema-drift-detected": {
"self": "Đã phát hiện sự trôi dạt của sơ đồ",
"description": "Sơ đồ khác với sơ đồ được áp dụng lần cuối. Điều này có thể gây ra lỗi ứng dụng và cần được giải quyết."
+ },
+ "new-baseline": {
+ "self": "Đường cơ sở mới",
+ "successfully-established": "Đã thiết lập thành công đường cơ sở mới"
}
}
},
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f35ec25a42..afaf55de65 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1495,6 +1495,10 @@
"schema-drift-detected": {
"self": "检测到 Schema 偏差",
"description": "当前数据库 Schema 与 Bytebase 中记录的 Schema 不一致。请及时检查并修复以避免潜在问题。"
+ },
+ "new-baseline": {
+ "self": "建立新基线",
+ "successfully-established": "成功建立新的基线"
}
}
},
diff --git a/frontend/src/plugins/issue/template.ts b/frontend/src/plugins/issue/template.ts
index 0eeab434d8..e226b7b233 100644
--- a/frontend/src/plugins/issue/template.ts
+++ b/frontend/src/plugins/issue/template.ts
@@ -1,3 +1,3 @@
import type { IssueType } from "@/types";
-export type TemplateType = IssueType | "bb.issue.database.schema.baseline";
+export type TemplateType = IssueType;
diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
index 665e7f89af..96165efbe8 100644
--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue
@@ -12,12 +12,11 @@
:link="'https://www.bytebase.com/docs/change-database/drift-detection/?source=console'"
:action-text="
database.project !== DEFAULT_PROJECT_NAME
- ? $t('changelog.establish-baseline')
- : ''
+ ? $t('database.drifted.new-baseline.self')
+ : undefined
"
- @click="doCreateBaselineIssue"
- >
- </BBAttention>
+ @click="updateDatabaseDrift"
+ />
<main class="flex-1 relative">
<!-- Highlight Panel -->
@@ -136,10 +135,7 @@
<NTabs v-if="ready" v-model:value="state.selectedTab">
<NTabPane name="overview" :tab="$t('common.overview')">
- <DatabaseOverviewPanel
- class="mt-2"
- :database="database"
- />
+ <DatabaseOverviewPanel class="mt-2" :database="database" />
</NTabPane>
<NTabPane
v-if="
@@ -251,6 +247,7 @@ import {
useEnvironmentV1Store,
useDatabaseV1ByName,
pushNotification,
+ useDatabaseV1Store,
} from "@/store";
import {
databaseNamePrefix,
@@ -298,6 +295,7 @@ const props = defineProps<{
const { t } = useI18n();
const router = useRouter();
+const databaseStore = useDatabaseV1Store();
const state = reactive<LocalState>({
showTransferDatabaseModal: false,
@@ -436,20 +434,18 @@ const handleCopyDatabaseName = (name: string) => {
});
};
-const doCreateBaselineIssue = () => {
- router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
- params: {
- projectId: extractProjectResourceName(database.value.project),
- issueSlug: "create",
- },
- query: {
- template: "bb.issue.database.schema.baseline",
- name: t("changelog.establish-database-baseline", {
- name: database.value.databaseName,
- }),
- databaseList: database.value.name,
+const updateDatabaseDrift = async () => {
+ await databaseStore.updateDatabase({
+ database: {
+ ...database.value,
+ drifted: false,
},
+ updateMask: ["drifted"],
+ });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("database.drifted.new-baseline.successfully-established"),
});
};
</script>