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: show schema drift alert in database detail (#15813)
boojackc04408df30ee
diff --git a/frontend/src/bbkit/BBAttention.vue b/frontend/src/bbkit/BBAttention.vueindex 022a1d6179..ce1931fa25 100644--- a/frontend/src/bbkit/BBAttention.vue+++ b/frontend/src/bbkit/BBAttention.vue@@ -4,7 +4,7 @@class="flex flex-col justify-start items-start md:flex-row md:items-center md:justify-between"><slot name="default">- <div v-if="description" class="mt-2 text-sm">+ <div v-if="description" class="text-sm"><p class="whitespace-pre-wrap">{{ $te(description) ? $t(description) : description }}<LearnMoreLink v-if="link" :url="link" class="ml-1 text-sm" />@@ -17,7 +17,11 @@v-if="actionText != ''"class="flex items-center justify-end mt-4 md:mt-0 md:ml-2">- <NButton :type="buttonType" @click.prevent="$emit('click')">+ <NButton+ :type="buttonType"+ size="small"+ @click.prevent="$emit('click')"+ >{{ $t(actionText) }}</NButton></div>@@ -27,10 +31,10 @@</template><script lang="ts" setup>-import LearnMoreLink from "@/components/LearnMoreLink.vue";import { NAlert, NButton } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";+import LearnMoreLink from "@/components/LearnMoreLink.vue";const props = withDefaults(defineProps<{@@ -64,6 +68,8 @@ const buttonType = computed(() => {switch (props.type) {case "error":return "default";+ case "warning":+ return "default";default:return "primary";}diff --git a/frontend/src/components/Database/DatabaseOverviewPanel.vue b/frontend/src/components/Database/DatabaseOverviewPanel.vueindex a3f0a68ea9..8e4bc55264 100644--- a/frontend/src/components/Database/DatabaseOverviewPanel.vue+++ b/frontend/src/components/Database/DatabaseOverviewPanel.vue@@ -1,7 +1,7 @@<template><div class="space-y-6 divide-y divide-block-border"><!-- Description list -->- <DatabaseOverviewInfo :database="database" class="pt-4" />+ <DatabaseOverviewInfo :database="database" /><div v-if="allowGetSchema" class="py-6"><divdiff --git a/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue b/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vueindex 3bbb1d7a54..c2c9fe2925 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/cells/DatabaseNameCell.vue@@ -6,10 +6,18 @@tag="span":keyword="keyword"/>+ <NTooltip v-if="database.drifted">+ <template #trigger>+ <GitPullRequestClosedIcon :size="16" class="text-warning-hover" />+ </template>+ {{ $t("database.drifted.schema-drift-detected.self") }}+ </NTooltip></div></template><script setup lang="ts">+import { GitPullRequestClosedIcon } from "lucide-vue-next";+import { NTooltip } from "naive-ui";import { DatabaseV1Name } from "@/components/v2";import type { ComposedDatabase } from "@/types";diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 7db690ba82..0eeb7620f3 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1491,12 +1491,12 @@"content": "This will delete these applied revisions and the database schema will not be changed. This action cannot be undone."}},- "not-found": "Cannot found the database"- },- "anomaly": {- "types": {- },- "action": {+ "not-found": "Cannot found the database",+ "drifted": {+ "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."+ }}},"project": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 009ae64833..c52096af2e 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1491,12 +1491,12 @@"content": "Esto eliminará las revisiones aplicadas y el esquema de la base de datos no se modificará. Esta acción no se puede deshacer."}},- "not-found": "No se puede encontrar la base de datos"- },- "anomaly": {- "types": {- },- "action": {+ "not-found": "No se puede encontrar la base de datos",+ "drifted": {+ "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."+ }}},"project": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 99cadd1259..8acc30795b 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1491,12 +1491,12 @@"content": "これにより、適用されたリビジョンが削除され、データベース スキーマは変更されません。このアクションは元に戻せません。"}},- "not-found": "データベースが見つかりません"- },- "anomaly": {- "types": {- },- "action": {+ "not-found": "データベースが見つかりません",+ "drifted": {+ "schema-drift-detected": {+ "self": "スキーマドリフトが検出されました",+ "description": "スキーマが最後に適用されたスキーマと異なります。アプリケーションエラーが発生する可能性があるため、解決する必要があります。"+ }}},"project": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 67b83f3194..05e7a94c9f 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1491,12 +1491,12 @@"content": "Thao tác này sẽ xóa các bản sửa đổi đã áp dụng này và lược đồ cơ sở dữ liệu sẽ không bị thay đổi. Hành động này không thể hoàn tác."}},- "not-found": "Không tìm thấy cơ sở dữ liệu"- },- "anomaly": {- "types": {- },- "action": {+ "not-found": "Không tìm thấy cơ sở dữ liệu",+ "drifted": {+ "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."+ }}},"project": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex dade763917..09be46f33e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1491,12 +1491,12 @@"content": "这将删除这些已应用的修改,但不会影响数据库 Schema。此操作无法撤消。"}},- "not-found": "找不到数据库"- },- "anomaly": {- "types": {- },- "action": {+ "not-found": "找不到数据库",+ "drifted": {+ "schema-drift-detected": {+ "self": "检测到 Schema 偏差",+ "description": "当前数据库 Schema 与 Bytebase 中记录的 Schema 不一致。请及时检查并修复以避免潜在问题。"+ }}},"project": {@@ -2591,4 +2591,4 @@"last-visit": "上次访问","changelog-for-version": "{version} 的更新日志"}-}\ No newline at end of file+}diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vueindex 9eb98cba37..0728ab2a5c 100644--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue@@ -4,6 +4,21 @@tabindex="0"v-bind="$attrs">+ <BBAttention+ v-if="database.drifted"+ type="warning"+ :title="$t('database.drifted.schema-drift-detected.self')"+ :description="$t('database.drifted.schema-drift-detected.description')"+ :link="'https://www.bytebase.com/docs/change-database/drift-detection/?source=console'"+ :action-text="+ database.project !== DEFAULT_PROJECT_NAME+ ? $t('changelog.establish-baseline')+ : ''+ "+ @click="doCreateBaselineIssue"+ >+ </BBAttention>+<main class="flex-1 relative"><!-- Highlight Panel --><div@@ -209,8 +224,9 @@ import dayjs from "dayjs";import { ArrowRightLeftIcon, ClipboardCopyIcon } from "lucide-vue-next";import { NButton, NTabPane, NTabs } from "naive-ui";import { computed, reactive, watch, ref, watchEffect } from "vue";+import { useI18n } from "vue-i18n";import { useRouter, useRoute } from "vue-router";-import { BBModal } from "@/bbkit";+import { BBAttention, BBModal } from "@/bbkit";import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";import DatabaseChangelogPanel from "@/components/Database/DatabaseChangelogPanel.vue";import DatabaseOverviewPanel from "@/components/Database/DatabaseOverviewPanel.vue";@@ -247,6 +263,7 @@ import {UNKNOWN_PROJECT_NAME,unknownEnvironment,isValidDatabaseName,+ DEFAULT_PROJECT_NAME,} from "@/types";import type { Anomaly } from "@/types/proto/v1/anomaly_service";import { State } from "@/types/proto/v1/common";@@ -284,6 +301,7 @@ const props = defineProps<{databaseName: string;}>();+const { t } = useI18n();const router = useRouter();const state = reactive<LocalState>({@@ -439,4 +457,21 @@ 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,+ },+ });+};</script>