Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: use full changehistory schema to create branch (#8700)
Liu Jie6029b70b017
diff --git a/frontend/src/components/Branch/BaselineSchemaSelector.vue b/frontend/src/components/Branch/BaselineSchemaSelector.vueindex cfb54e87b7..2e01bac117 100644--- a/frontend/src/components/Branch/BaselineSchemaSelector.vue+++ b/frontend/src/components/Branch/BaselineSchemaSelector.vue@@ -91,7 +91,7 @@<script lang="ts" setup>import { head, isNull, isUndefined } from "lodash-es";import { NEllipsis } from "naive-ui";-import { computed, onMounted, reactive, ref, watch } from "vue";+import { computed, onMounted, reactive, watch } from "vue";import { InstanceV1EngineIcon } from "@/components/v2";import {useChangeHistoryStore,@@ -103,7 +103,6 @@ import { UNKNOWN_ID } from "@/types";import { Engine } from "@/types/proto/v1/common";import {ChangeHistory,- ChangeHistoryView,ChangeHistory_Type,} from "@/types/proto/v1/database_service";import { instanceV1Name } from "@/utils";@@ -134,7 +133,6 @@ const databaseStore = useDatabaseV1Store();const dbSchemaStore = useDBSchemaV1Store();const changeHistoryStore = useChangeHistoryStore();const environmentStore = useEnvironmentV1Store();-const fullViewChangeHistoryCache = ref<Map<string, ChangeHistory>>(new Map());const database = computed(() => {const databaseId = state.databaseId;@@ -210,30 +208,6 @@ watch(});-const prepareFullViewChangeHistory = async () => {- const changeHistory = state.changeHistory;- if (!changeHistory || changeHistory.uid === String(UNKNOWN_ID)) {- return;- }-- const cache = fullViewChangeHistoryCache.value.get(changeHistory.name);- if (!cache) {- const fullViewChangeHistory = await changeHistoryStore.fetchChangeHistory({- name: changeHistory.name,- view: ChangeHistoryView.CHANGE_HISTORY_VIEW_FULL,- });- fullViewChangeHistoryCache.value.set(- fullViewChangeHistory.name,- fullViewChangeHistory- );- }-};--watch(() => state.changeHistory, prepareFullViewChangeHistory, {- immediate: true,- deep: true,-});-const allowedEngineTypeList: Engine[] = [Engine.MYSQL,Engine.TIDB,diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vueindex 20306343c2..e8d6477a03 100644--- a/frontend/src/components/Branch/BranchCreateView.vue+++ b/frontend/src/components/Branch/BranchCreateView.vue@@ -68,6 +68,7 @@ import { useRoute, useRouter } from "vue-router";import SchemaEditorV1 from "@/components/SchemaEditorV1/index.vue";import {pushNotification,+ useChangeHistoryStore,useDatabaseV1Store,useProjectV1Store,useSchemaEditorV1Store,@@ -82,6 +83,7 @@ import {import { UNKNOWN_ID } from "@/types";import {ChangeHistory,+ ChangeHistoryView,DatabaseMetadata,} from "@/types/proto/v1/database_service";import {@@ -159,15 +161,20 @@ const prepareSchemaDesign = async () => {const database = databaseStore.getDatabaseByUID(state.baselineSchema.databaseId);+ const changeHistoryWithFullView =+ await useChangeHistoryStore().fetchChangeHistory({+ name: changeHistory.name,+ view: ChangeHistoryView.CHANGE_HISTORY_VIEW_FULL,+ });const baselineMetadata = await schemaDesignStore.parseSchemaString(- changeHistory.schema,+ changeHistoryWithFullView.schema,database.instanceEntity.engine);return SchemaDesign.fromPartial({engine: database.instanceEntity.engine,- baselineSchema: changeHistory.schema,+ baselineSchema: changeHistoryWithFullView.schema,baselineSchemaMetadata: baselineMetadata,- schema: changeHistory.schema,+ schema: changeHistoryWithFullView.schema,schemaMetadata: baselineMetadata,});}diff --git a/frontend/src/store/modules/v1/changeHistory.ts b/frontend/src/store/modules/v1/changeHistory.tsindex 66fd115edd..46515cb452 100644--- a/frontend/src/store/modules/v1/changeHistory.ts+++ b/frontend/src/store/modules/v1/changeHistory.ts@@ -26,7 +26,6 @@ export const useChangeHistoryStore = defineStore("changeHistory_v1", () => {historyList: ChangeHistory[]) => {changeHistoryListMapByDatabase.set(parent, historyList);- await upsertChangeHistoryMap(historyList);};const fetchChangeHistoryList = async (