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: schema design cache in sync schema (#7335)
boojack562027f281c0
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex ab25d32cdf..85ec2d7c93 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -246,6 +246,8 @@</div><Drawer+ :auto-focus="true"+ :trap-focus="true":show="state.quickActionType !== undefined"@close="state.quickActionType = undefined">diff --git a/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue b/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vueindex d56623550d..f4e31d20a8 100644--- a/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue+++ b/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue@@ -78,7 +78,8 @@:engine="schemaDesign.engine":schema-design="schemaDesign"/>- <div>+ <!-- Don't show delete button in view mode. -->+ <div v-if="!viewMode"><BBButtonConfirm:style="'DELETE'":button-text="$t('schema-designer.delete-this-design')"diff --git a/frontend/src/components/SchemaDesigner/Modals/EditColumnForeignKeyModal.vue b/frontend/src/components/SchemaDesigner/Modals/EditColumnForeignKeyModal.vueindex 61d3f3254e..ba5341fd05 100644--- a/frontend/src/components/SchemaDesigner/Modals/EditColumnForeignKeyModal.vue+++ b/frontend/src/components/SchemaDesigner/Modals/EditColumnForeignKeyModal.vue@@ -56,7 +56,7 @@class="btn-danger"@click="handleRemoveFKButtonClick">- Remove+ {{ $t("common.delete") }}</button></div><div class="flex items-center justify-end space-x-2">diff --git a/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue b/frontend/src/components/SchemaDesigner/Panels/TableEditor.vueindex 9773588f6c..3c7b8d40e5 100644--- a/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue+++ b/frontend/src/components/SchemaDesigner/Panels/TableEditor.vue@@ -144,7 +144,7 @@</div><div class="table-body-item-container"><input- v-model="column.comment"+ v-model="column.userComment":disabled="disableAlterColumn(column)"placeholder="comment"class="column-field-input"diff --git a/frontend/src/components/SchemaDesigner/PrepForm/index.vue b/frontend/src/components/SchemaDesigner/PrepForm/index.vueindex d647888da8..c89b15c0fa 100644--- a/frontend/src/components/SchemaDesigner/PrepForm/index.vue+++ b/frontend/src/components/SchemaDesigner/PrepForm/index.vue@@ -57,7 +57,6 @@ import { SchemaDesign } from "@/types/proto/v1/schema_design_service";import { useSchemaDesignList } from "@/store/modules/schemaDesign";import SchemaDesignTable from "./SchemaDesignTable.vue";import { DrawerContent } from "@/components/v2";-import { useEventListener } from "@vueuse/core";import CreateSchemaDesignPanel from "../CreateSchemaDesignPanel.vue";import EditSchemaDesignPanel from "../EditSchemaDesignPanel.vue";@@ -66,13 +65,6 @@ interface LocalState {selectedSchemaDesignName?: string;}-const emit = defineEmits(["dismiss"]);-useEventListener("keydown", (e) => {- if (e.code == "Escape") {- emit("dismiss");- }-});-const { schemaDesignList, ready } = useSchemaDesignList();const state = reactive<LocalState>({showCreatePanel: false,diff --git a/frontend/src/components/SchemaDesigner/common/util.ts b/frontend/src/components/SchemaDesigner/common/util.tsindex 0963ae2737..4cbced7904 100644--- a/frontend/src/components/SchemaDesigner/common/util.ts+++ b/frontend/src/components/SchemaDesigner/common/util.ts@@ -64,6 +64,7 @@ export const mergeSchemaEditToMetadata = (column.type = columnEdit.type;column.nullable = columnEdit.nullable;column.comment = columnEdit.comment;+ column.userComment = columnEdit.userComment;column.default = columnEdit.default;}}@@ -169,6 +170,7 @@ const transformSchemaEditToMetadata = (schemaEdit: Schema): SchemaMetadata => {nullable: column.nullable,default: column.default,comment: column.comment,+ userComment: column.userComment,}));}@@ -214,6 +216,7 @@ const transformTableEditToMetadata = (tableEdit: Table): TableMetadata => {nullable: column.nullable,default: column.default,comment: column.comment,+ userComment: column.userComment,}));}@@ -247,5 +250,6 @@ const transformColumnEditToMetadata = (columnEdit: Column): ColumnMetadata => {nullable: columnEdit.nullable,default: columnEdit.default,comment: columnEdit.comment,+ userComment: columnEdit.userComment,});};diff --git a/frontend/src/components/v2/Container/Drawer.vue b/frontend/src/components/v2/Container/Drawer.vueindex 2096dfebdc..cdacb40c50 100644--- a/frontend/src/components/v2/Container/Drawer.vue+++ b/frontend/src/components/v2/Container/Drawer.vue@@ -4,6 +4,8 @@:show="show":auto-focus="false":trap-focus="false"+ :close-on-esc="true"+ v-bind="$attrs"@update:show="onUpdateShow"><slot />diff --git a/frontend/src/types/schemaEditor/atomType.ts b/frontend/src/types/schemaEditor/atomType.tsindex 496194ef00..25bf0f3b1e 100644--- a/frontend/src/types/schemaEditor/atomType.ts+++ b/frontend/src/types/schemaEditor/atomType.ts@@ -14,6 +14,7 @@ export interface Column {type: string;nullable: boolean;comment: string;+ userComment: string;default?: string;status: AtomResourceStatus;}@@ -65,6 +66,7 @@ export const convertColumnMetadataToColumn = (type: columnMetadata.type,nullable: columnMetadata.nullable,comment: columnMetadata.comment,+ userComment: columnMetadata.userComment,default: columnMetadata.default,status: "normal",};diff --git a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vueindex 0780bd0b48..58014805f9 100644--- a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue+++ b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue@@ -63,7 +63,7 @@class="normal-link inline-flex items-center"@click="state.showViewSchemaDesignPanel = true">- {{ schemaDesign?.title || "Unknown" }}+ {{ selectedSchemaDesign?.title || "Unknown" }}</span></div></template>@@ -216,8 +216,8 @@/><EditSchemaDesignPanel- v-if="state.showViewSchemaDesignPanel && schemaDesign"- :schema-design-name="schemaDesign.name"+ v-if="state.showViewSchemaDesignPanel && selectedSchemaDesign"+ :schema-design-name="selectedSchemaDesign.name":view-mode="true"@dismiss="state.showViewSchemaDesignPanel = false"/>@@ -243,9 +243,9 @@ import DiffViewPanel from "./DiffViewPanel.vue";import { Engine, engineToJSON } from "@/types/proto/v1/common";import { InstanceV1EngineIcon } from "@/components/v2";import { ChangeHistory } from "@/types/proto/v1/database_service";-import { SchemaDesign } from "@/types/proto/v1/schema_design_service";import { SourceSchemaType } from "./types";import EditSchemaDesignPanel from "@/components/SchemaDesigner/EditSchemaDesignPanel.vue";+import { useSchemaDesignStore } from "@/store/modules/schemaDesign";interface DatabaseSourceSchema {environmentId: string;@@ -266,12 +266,13 @@ const props = defineProps<{projectId: string;sourceSchemaType: SourceSchemaType;databaseSourceSchema?: DatabaseSourceSchema;- schemaDesign?: SchemaDesign;+ schemaDesignName?: string;}>();const { t } = useI18n();const environmentV1Store = useEnvironmentV1Store();const databaseStore = useDatabaseV1Store();+const schemaDesignStore = useSchemaDesignStore();const diffViewerRef = ref<HTMLDivElement>();const state = reactive<LocalState>({isLoading: true,@@ -293,11 +294,17 @@ const databaseDiffCache = reactive<>({});const { project } = useProjectV1ByUID(props.projectId);+const selectedSchemaDesign = computed(() => {+ if (!props.schemaDesignName) {+ return undefined;+ }+ return schemaDesignStore.getSchemaDesignByName(props.schemaDesignName);+});const sourceDatabaseSchema = computed(() => {if (props.sourceSchemaType === "SCHEMA_HISTORY_VERSION") {return props.databaseSourceSchema?.changeHistory.schema || "";} else {- return props.schemaDesign?.schema || "";+ return selectedSchemaDesign.value?.schema || "";}});const engine = computed(() => {@@ -305,8 +312,10 @@ const engine = computed(() => {return databaseStore.getDatabaseByUID(props.databaseSourceSchema!.databaseId).instanceEntity.engine;+ } else if (props.sourceSchemaType === "SCHEMA_DESIGN") {+ return selectedSchemaDesign.value!.engine;} else {- return props.schemaDesign!.engine;+ return Engine.MYSQL;}});const targetDatabaseList = computed(() => {@@ -425,14 +434,16 @@ watch();watch(- () => state.selectedDatabaseIdList,- async () => {+ () => [state.selectedDatabaseIdList, sourceDatabaseSchema.value],+ async (_, oldValue) => {+ // If source schema changed, we need to recompute the diff for all target databases.+ const skipCache = oldValue[1] !== sourceDatabaseSchema.value;const schedule = setTimeout(() => {state.isLoading = true;}, 300);for (const id of state.selectedDatabaseIdList) {- if (databaseSchemaCache[id]) {+ if (databaseSchemaCache[id] && !skipCache) {continue;}const db = databaseStore.getDatabaseByUID(id);@@ -440,7 +451,7 @@ watch(`${db.name}/schema`);databaseSchemaCache[id] = schema.schema;- if (databaseDiffCache[id]) {+ if (databaseDiffCache[id] && !skipCache) {continue;} else {const schemaDiff = await getSchemaDiff(diff --git a/frontend/src/views/SyncDatabaseSchema/index.vue b/frontend/src/views/SyncDatabaseSchema/index.vueindex 771346e1cc..d0fa5734f0 100644--- a/frontend/src/views/SyncDatabaseSchema/index.vue+++ b/frontend/src/views/SyncDatabaseSchema/index.vue@@ -51,7 +51,7 @@:project-id="projectId!":source-schema-type="state.sourceSchemaType":database-source-schema="(changeHistorySourceSchemaState as any)"- :schema-design="schemaDesignState.selectedSchemaDesign"+ :schema-design-name="schemaDesignState.selectedSchemaDesign?.name"/></template></BBStepTab>