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 source schema info (#14983)
boojackfe7763b49eb5
diff --git a/frontend/src/components/SyncDatabaseSchemaV1/DatabaseSchemaSelector.vue b/frontend/src/components/SyncDatabaseSchemaV1/DatabaseSchemaSelector.vueindex 5bd2790f80..a850d8dca9 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/DatabaseSchemaSelector.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/DatabaseSchemaSelector.vue@@ -296,14 +296,12 @@ watch(ALLOWED_CHANGELOG_TYPES.includes(changelog.type));- if (!state.changelogName) {- if (changelogList.length > 0) {- // Default select the first changelog.- state.changelogName = head(changelogList)?.name;- } else {- // If database has no changelog, we will use its latest schema.- state.changelogName = mockLatestChangelog(database).name;- }+ if (changelogList.length > 0) {+ // Default select the first changelog.+ state.changelogName = head(changelogList)?.name;+ } else {+ // If database has no changelog, we will use its latest schema.+ state.changelogName = mockLatestChangelog(database).name;}} finally {isPreparingSchemaVersionOptions.value = false;diff --git a/frontend/src/components/SyncDatabaseSchemaV1/RawSQLEditor.vue b/frontend/src/components/SyncDatabaseSchemaV1/RawSQLEditor.vueindex 4dc2598b5a..751b0f858c 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/RawSQLEditor.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/RawSQLEditor.vue@@ -3,9 +3,7 @@<div class="w-full h-auto shrink-0 flex flex-row justify-between items-end"><div class="flex flex-col justify-start items-start gap-y-2"><div class="flex flex-row justify-start items-center">- <span class="mr-2 w-20 shrink-0 text-sm">{{- $t("database.engine")- }}</span>+ <span class="mr-2 shrink-0 text-sm">{{ $t("database.engine") }}</span><NSelectv-model:value="state.engine":consistent-menu-width="false"diff --git a/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vueindex abea9573ee..7195569a9a 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue@@ -1,7 +1,13 @@<template><div- class="select-target-database-view h-full overflow-y-hidden flex flex-col gap-y-4"+ class="select-target-database-view h-full overflow-y-hidden flex flex-col gap-y-2">+ <SourceSchemaInfo+ :project="project"+ :schema-string="sourceSchemaString"+ :engine="sourceEngine"+ :changelog-source-schema="changelogSourceSchema"+ /><divclass="relative border rounded-lg w-full flex flex-row flex-1 overflow-hidden">@@ -177,7 +183,9 @@ import {isValidChangelogName,} from "@/utils/v1/changelog";import DiffViewPanel from "./DiffViewPanel.vue";+import SourceSchemaInfo from "./SourceSchemaInfo.vue";import TargetDatabasesSelectPanel from "./TargetDatabasesSelectPanel.vue";+import type { ChangelogSourceSchema } from "./types";interface LocalState {isLoading: boolean;@@ -192,7 +200,7 @@ const props = defineProps<{project: ComposedProject;sourceSchemaString: string;sourceEngine: Engine;- sourceChangelogName?: string;+ changelogSourceSchema?: ChangelogSourceSchema;}>();const { t } = useI18n();@@ -389,20 +397,20 @@ onMounted(async () => {// Prepare the source schema display string.if (- props.sourceChangelogName &&+ props.changelogSourceSchema?.changelogName &&instanceV1SupportsConciseSchema(props.sourceEngine)) {state.isLoading = true;- if (isValidChangelogName(props.sourceChangelogName)) {+ if (isValidChangelogName(props.changelogSourceSchema.changelogName)) {const changelog = await databaseServiceClient.getChangelog({- name: props.sourceChangelogName,+ name: props.changelogSourceSchema.changelogName,view: ChangelogView.CHANGELOG_VIEW_FULL,concise: true,});sourceSchemaDisplayString.value = changelog.schema;} else {const { databaseName } = extractDatabaseNameAndChangelogUID(- props.sourceChangelogName+ props.changelogSourceSchema.changelogName);const databaseSchema = await databaseStore.fetchDatabaseSchema(`${databaseName}/schema`,diff --git a/frontend/src/components/SyncDatabaseSchemaV1/SourceSchemaInfo.vue b/frontend/src/components/SyncDatabaseSchemaV1/SourceSchemaInfo.vuenew file mode 100644index 0000000000..a1a96dc83c--- /dev/null+++ b/frontend/src/components/SyncDatabaseSchemaV1/SourceSchemaInfo.vue@@ -0,0 +1,85 @@+<template>+ <div+ class="w-full flex flex-row justify-start items-center flex-wrap gap-2 text-sm"+ >+ <span>+ {{ t("database.sync-schema.source-schema") }}+ </span>+ <template v-if="changelogSourceSchema">+ <NTag round @click="gotoDatabase">+ <span class="opacity-60 mr-1">{{ t("common.database") }}</span>+ <EngineIcon custom-class="inline-flex w-4 h-auto" :engine="engine" />+ <span>{{ databaseFromChangelog.databaseName }}</span>+ </NTag>+ <NTag round @click="gotoChangelog">+ <span class="opacity-60 mr-1">{{ t("common.changelog") }}</span>+ <span>{{ changelogUID ? `#${changelogUID}` : "Latest" }}</span>+ </NTag>+ </template>+ <template v-else>+ <NTag round>+ {{ t("schema-editor.raw-sql") }}+ </NTag>+ <NTag round>+ <span class="opacity-60 mr-1">{{ t("database.engine") }}</span>+ <EngineIcon custom-class="inline-flex w-4 h-auto" :engine="engine" />+ <span>{{ engineNameV1(engine) }}</span>+ </NTag>+ </template>+ </div>+</template>++<script lang="ts" setup>+import { NTag } from "naive-ui";+import { computed } from "vue";+import { useI18n } from "vue-i18n";+import { useDatabaseV1Store } from "@/store";+import { isValidDatabaseName, type ComposedProject } from "@/types";+import { Engine } from "@/types/proto/v1/common";+import {+ databaseV1Url,+ engineNameV1,+ extractChangelogUID,+ isValidChangelogName,+} from "@/utils";+import { EngineIcon } from "../Icon";+import { type ChangelogSourceSchema } from "./types";++const props = defineProps<{+ project: ComposedProject;+ schemaString: string;+ engine: Engine;+ changelogSourceSchema?: ChangelogSourceSchema;+}>();++const { t } = useI18n();+const databaseStore = useDatabaseV1Store();++const databaseFromChangelog = computed(() => {+ return databaseStore.getDatabaseByName(+ props.changelogSourceSchema?.databaseName || "" // Or unknown database.+ );+});++const changelogUID = computed(() => {+ const maybeChangelogName = props.changelogSourceSchema?.changelogName || "";+ if (!isValidChangelogName(maybeChangelogName)) {+ return undefined;+ }+ return extractChangelogUID(maybeChangelogName);+});++const gotoDatabase = () => {+ if (isValidDatabaseName(databaseFromChangelog.value.name)) {+ window.open(databaseV1Url(databaseFromChangelog.value));+ }+};++const gotoChangelog = () => {+ if (isValidChangelogName(props.changelogSourceSchema?.changelogName || "")) {+ window.open(+ `${databaseV1Url(databaseFromChangelog.value)}/changelogs/${changelogUID.value}`+ );+ }+};+</script>diff --git a/frontend/src/components/SyncDatabaseSchemaV1/index.vue b/frontend/src/components/SyncDatabaseSchemaV1/index.vueindex 01fd33a930..3c2795bad7 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/index.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/index.vue@@ -15,7 +15,7 @@</div><StepTabv-else- class="pt-4 flex-1 overflow-hidden flex flex-col"+ class="pt-4 flex-1 overflow-hidden flex flex-col !space-y-4":step-list="stepTabList":current-index="state.currentStep":show-cancel="false"@@ -61,7 +61,11 @@:project="project":source-schema-string="sourceSchemaString":source-engine="sourceEngine"- :source-changelog-name="changelogSourceSchemaState.changelogName"+ :changelog-source-schema="+ state.sourceSchemaType === SourceSchemaType.SCHEMA_HISTORY_VERSION+ ? changelogSourceSchemaState+ : undefined+ "/></template></StepTab>@@ -208,12 +212,6 @@ const stepTabList = computed(() => {return [{title: t("database.sync-schema.select-source-schema"),- description:- state.currentStep === Step.SELECT_TARGET_DATABASE_LIST- ? state.sourceSchemaType === SourceSchemaType.SCHEMA_HISTORY_VERSION- ? t("database.sync-schema.schema-history-version")- : t("database.sync-schema.copy-schema")- : undefined,},{title: t("database.sync-schema.select-target-databases"),