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: remove branch from sync schema (#9004)
boojack2ac721616cb3
diff --git a/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue b/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vuedeleted file mode 100644index ab6fdd8c5c..0000000000--- a/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue+++ /dev/null@@ -1,178 +0,0 @@-<template>- <div class="w-full" v-bind="$attrs">- <div- class="w-full mb-4 flex flex-row justify-between items-center space-x-2"- >- <span>- {{ $t("database.select-branch") }}- </span>- <div>- <NButton @click="handleCreateBranch">- <heroicons-solid:plus class="w-4 h-auto mr-0.5" />- <span>{{ $t("database.new-branch") }}</span>- </NButton>- </div>- </div>- <BBGrid- class="border"- :ready="schemaDesignListReady"- :show-placeholder="true"- :column-list="COLUMN_LIST"- :data-source="schemaDesignList"- @click-row="clickSchemaDesign"- >- <template #item="{ item: schemaDesign }: { item: SchemaDesign }">- <div class="bb-grid-cell">- <NRadio :checked="schemaDesign.name === selectedSchemaDesign?.name" />- </div>- <div class="bb-grid-cell">- {{ projectV1Name(getFormattedValue(schemaDesign).project) }}- </div>- <div class="bb-grid-cell">- <NEllipsis :line-clamp="1">{{ schemaDesign.title }}</NEllipsis>- </div>- <div class="bb-grid-cell">- <NEllipsis :line-clamp="1">{{- getFormattedValue(schemaDesign).parentBranch- }}</NEllipsis>- </div>- <div class="bb-grid-cell">- <DatabaseInfo :database="getFormattedValue(schemaDesign).database" />- </div>- <div class="bb-grid-cell">- <span class="text-gray-400">{{- getFormattedValue(schemaDesign).updatedTimeStr- }}</span>- </div>-- <div class="bb-grid-cell">- <NButton- size="small"- @click.stop="handleViewSchemaDesign(schemaDesign)"- >- {{ $t("common.view") }}- </NButton>- </div>- </template>- </BBGrid>- </div>-</template>--<script lang="ts" setup>-import dayjs from "dayjs";-import { NRadio, NButton, NEllipsis } from "naive-ui";-import { computed, ref } from "vue";-import { useI18n } from "vue-i18n";-import { useRouter } from "vue-router";-import { BBGridColumn } from "@/bbkit";-import DatabaseInfo from "@/components/DatabaseInfo.vue";-import { useDatabaseV1Store, useProjectV1Store, useUserStore } from "@/store";-import { useSchemaDesignList } from "@/store/modules/schemaDesign";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";-import {- SchemaDesign,- SchemaDesign_Type,-} from "@/types/proto/v1/schema_design_service";-import { projectV1Name, projectV1Slug } from "@/utils";--const emit = defineEmits<{- (event: "select", schemaDesign: SchemaDesign): void;-}>();--const props = defineProps<{- selectedSchemaDesign?: SchemaDesign;- projectName?: string;-}>();--const { t } = useI18n();-const router = useRouter();-const userV1Store = useUserStore();-const projectV1Store = useProjectV1Store();-const databaseV1Store = useDatabaseV1Store();-const { schemaDesignList, ready: schemaDesignListReady } = useSchemaDesignList(- props.projectName-);-const selectedSchemaDesign = ref<SchemaDesign | undefined>(- props.selectedSchemaDesign-);--const COLUMN_LIST = computed(() => {- const columns: BBGridColumn[] = [- { title: "", width: "3rem" },- {- title: t("common.project"),- width: "minmax(auto, 0.5fr)",- },- { title: t("database.branch"), width: "minmax(auto, 0.5fr)" },- { title: t("schema-designer.parent-branch"), width: "minmax(auto, 0.5fr)" },- { title: t("common.database"), width: "1fr" },- { title: "", width: "1fr" },- { title: "", width: "5rem" },- ];-- return columns;-});--const getFormattedValue = (schemaDesign: SchemaDesign) => {- const [projectName] = getProjectAndSchemaDesignSheetId(schemaDesign.name);- const project = projectV1Store.getProjectByName(`projects/${projectName}`);- let parentBranch = "";- if (schemaDesign.type === SchemaDesign_Type.PERSONAL_DRAFT) {- const parentSchemaDesign = schemaDesignList.value.find(- (parent) => parent.name === schemaDesign.baselineSheetName- );- if (parentSchemaDesign) {- parentBranch = parentSchemaDesign.title;- }- }-- const updater = userV1Store.getUserByEmail(- schemaDesign.updater.split("/")[1]- );- const updatedTimeStr = t("schema-designer.message.updated-time-by-user", {- time: dayjs- .duration((schemaDesign.updateTime ?? new Date()).getTime() - Date.now())- .humanize(true),- user: updater?.title,- });-- return {- name: schemaDesign.title,- project: project,- database: databaseV1Store.getDatabaseByName(schemaDesign.baselineDatabase),- parentBranch: parentBranch,- updatedTimeStr,- };-};--const clickSchemaDesign = (schemaDesign: SchemaDesign) => {- selectedSchemaDesign.value = schemaDesign;- emit("select", schemaDesign);-};--const handleCreateBranch = () => {- const route = router.resolve({- name: "workspace.branch.detail",- params: {- projectSlug: "-",- branchName: "new",- },- });- window.open(route.href, "_blank");-};--const handleViewSchemaDesign = (schemaDesign: SchemaDesign) => {- const [_, sheetId] = getProjectAndSchemaDesignSheetId(schemaDesign.name);- const baselineDatabase = databaseV1Store.getDatabaseByName(- schemaDesign.baselineDatabase- );- const route = router.resolve({- name: "workspace.branch.detail",- params: {- projectSlug: projectV1Slug(baselineDatabase.projectEntity),- branchName: sheetId,- },- });- window.open(route.href, "_blank");-};-</script>diff --git a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vueindex 5c1650859c..0d7269ac3b 100644--- a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue+++ b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue@@ -51,28 +51,6 @@</div></div></template>- <template- v-else-if="sourceSchemaType === 'SCHEMA_DESIGN' && selectedSchemaDesign"- >- <div>- <span>{{ $t("common.project") }} - </span>- <a- class="normal-link inline-flex items-center"- :href="`/project/${projectV1Slug(project)}`"- >{{ project.title }}</a- >- </div>- <div class="flex flex-row justify-start items-center">- <span>{{ $t("database.branch") }} - </span>- <span- class="normal-link inline-flex items-center ml-1"- @click="handleViewBranch"- >- <EngineIcon class="mr-1" :engine="engine" />- {{ selectedSchemaDesign?.title || "Unknown" }}- </span>- </div>- </template><template v-else><div><span>{{ $t("common.project") }} - </span>@@ -251,14 +229,11 @@<script lang="ts" setup>import { toClipboard } from "@soerenmartius/vue3-clipboard";-import { asyncComputed } from "@vueuse/core";import { head } from "lodash-es";import { NEllipsis } from "naive-ui";import { computed, nextTick, onMounted, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";-import { useRouter } from "vue-router";import { InstanceV1EngineIcon } from "@/components/v2";-import { sqlServiceClient } from "@/grpcweb";import {pushNotification,useDatabaseV1Store,@@ -266,8 +241,6 @@ import {useProjectV1Store,useSheetV1Store,} from "@/store";-import { useSchemaDesignStore } from "@/store/modules/schemaDesign";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";import { ComposedDatabase, UNKNOWN_ID } from "@/types";import { Engine } from "@/types/proto/v1/common";import { ChangeHistory } from "@/types/proto/v1/database_service";@@ -289,7 +262,6 @@ interface LocalState {selectedDatabaseId: string | undefined;selectedDatabaseIdList: string[];showSelectDatabasePanel: boolean;- showViewSchemaDesignPanel: boolean;showViewRawSQLPanel: boolean;}@@ -297,15 +269,12 @@ const props = defineProps<{projectId: string;sourceSchemaType: SourceSchemaType;databaseSourceSchema?: DatabaseSourceSchema;- schemaDesignName?: string;rawSqlState?: RawSQLState;}>();const { t } = useI18n();-const router = useRouter();const environmentV1Store = useEnvironmentV1Store();const databaseStore = useDatabaseV1Store();-const schemaDesignStore = useSchemaDesignStore();const sheetStore = useSheetV1Store();const diffViewerRef = ref<HTMLDivElement>();const state = reactive<LocalState>({@@ -314,7 +283,6 @@ const state = reactive<LocalState>({showSelectDatabasePanel: false,selectedDatabaseId: undefined,selectedDatabaseIdList: [],- showViewSchemaDesignPanel: false,showViewRawSQLPanel: false,});const databaseSchemaCache = reactive<Record<string, string>>({});@@ -327,32 +295,13 @@ const databaseDiffCache = reactive<}>>({});-const schemaDesignPreviewCache = reactive<Record<string, string>>({});const project = computed(() => {return useProjectV1Store().getProjectByUID(props.projectId);});-const selectedSchemaDesign = asyncComputed(() => {- if (!props.schemaDesignName) {- return undefined;- }- return schemaDesignStore.fetchSchemaDesignByName(- props.schemaDesignName,- true /* useCache */- );-}, undefined);const sourceDatabaseSchema = computed(() => {if (props.sourceSchemaType === "SCHEMA_HISTORY_VERSION") {return props.databaseSourceSchema?.changeHistory.schema || "";- } else if (props.sourceSchemaType === "SCHEMA_DESIGN") {- const databaseId = state.selectedDatabaseId || "";- return (- schemaDesignPreviewCache[- databaseId + "|" + selectedSchemaDesign.value?.name- ] ||- selectedSchemaDesign.value?.schema ||- ""- );} else if (props.sourceSchemaType === "RAW_SQL") {let statement = props.rawSqlState?.statement || "";if (props.rawSqlState?.sheetId) {@@ -371,8 +320,6 @@ const engine = computed(() => {return databaseStore.getDatabaseByUID(props.databaseSourceSchema!.databaseId).instanceEntity.engine;- } else if (props.sourceSchemaType === "SCHEMA_DESIGN") {- return selectedSchemaDesign.value?.engine ?? Engine.ENGINE_UNSPECIFIED;} else if (props.sourceSchemaType === "RAW_SQL") {return props.rawSqlState!.engine;} else {@@ -445,24 +392,6 @@ onMounted(async () => {}});-const handleViewBranch = () => {- if (!selectedSchemaDesign.value) {- return;- }-- const [_, sheetId] = getProjectAndSchemaDesignSheetId(- selectedSchemaDesign.value.name- );- const route = router.resolve({- name: "workspace.branch.detail",- params: {- projectSlug: projectV1Slug(project.value),- branchName: sheetId,- },- });- window.open(route.href, "_blank");-};-const getSourceDatabase = () => {if (!props.databaseSourceSchema) {return;@@ -520,24 +449,6 @@ watch(});-watch(- () => [state.selectedDatabaseId, selectedSchemaDesign.value],- async () => {- if (!state.selectedDatabaseId || !selectedSchemaDesign.value) {- return;- }- const schema = await sqlServiceClient.differPreview({- engine: engine.value,- oldSchema: targetDatabaseSchema.value,- newMetadata: selectedSchemaDesign.value?.schemaMetadata,- });- const databaseId = state.selectedDatabaseId || "";- schemaDesignPreviewCache[- databaseId + "|" + selectedSchemaDesign.value?.name- ] = schema.schema;- }-);-watch(() => [state.selectedDatabaseIdList, sourceDatabaseSchema.value],async (_, oldValue) => {diff --git a/frontend/src/components/SyncDatabaseSchema/index.vue b/frontend/src/components/SyncDatabaseSchema/index.vueindex a49a120e84..606b53bc3d 100644--- a/frontend/src/components/SyncDatabaseSchema/index.vue+++ b/frontend/src/components/SyncDatabaseSchema/index.vue@@ -25,7 +25,6 @@:value="'SCHEMA_HISTORY_VERSION'":label="$t('database.sync-schema.schema-history-version')"/>- <NRadio :value="'SCHEMA_DESIGN'" :label="$t('database.branch')" /><NRadio :value="'RAW_SQL'" :label="$t('schema-editor.raw-sql')" /></NRadioGroup></div>@@ -35,15 +34,6 @@:disable-project-select="!!project"@update="handleChangeHistorySchameVersionChanges"/>- <SchemaDesignSelector- v-if="state.sourceSchemaType === 'SCHEMA_DESIGN'"- :project-name="project?.name"- :selected-schema-design="schemaDesignState.selectedSchemaDesign"- @select="- (schemaDesign) =>- (schemaDesignState.selectedSchemaDesign = schemaDesign)- "- /><RawSQLEditorv-if="state.sourceSchemaType === 'RAW_SQL'":project-id="rawSQLState.projectId"@@ -60,7 +50,6 @@:project-id="projectId!":source-schema-type="state.sourceSchemaType":database-source-schema="(changeHistorySourceSchemaState as any)"- :schema-design-name="schemaDesignState.selectedSchemaDesign?.name":raw-sql-state="rawSQLState"/></template>@@ -72,19 +61,15 @@import dayjs from "dayjs";import { isNull, isUndefined } from "lodash-es";import { NRadioGroup, NRadio, useDialog } from "naive-ui";-import { computed, onMounted, reactive, ref } from "vue";+import { computed, reactive, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { BBStepTab } from "@/bbkit";import { useProjectV1Store } from "@/store";-import { useSchemaDesignStore } from "@/store/modules/schemaDesign";-import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";import { UNKNOWN_ID, ComposedProject } from "@/types";import { Engine } from "@/types/proto/v1/common";-import { SchemaDesign } from "@/types/proto/v1/schema_design_service";import DatabaseSchemaSelector from "./DatabaseSchemaSelector.vue";import RawSQLEditor from "./RawSQLEditor.vue";-import SchemaDesignSelector from "./SchemaDesignSelector.vue";import SelectTargetDatabasesView from "./SelectTargetDatabasesView.vue";import {ChangeHistorySourceSchema,@@ -112,7 +97,6 @@ const router = useRouter();const dialog = useDialog();const bbStepTabRef = ref<InstanceType<typeof BBStepTab>>();const projectStore = useProjectV1Store();-const schemaDesignStore = useSchemaDesignStore();const targetDatabaseViewRef =ref<InstanceType<typeof SelectTargetDatabasesView>>();const state = reactive<LocalState>({@@ -122,9 +106,6 @@ const state = reactive<LocalState>({const changeHistorySourceSchemaState = reactive<ChangeHistorySourceSchema>({projectId: props.project?.uid,});-const schemaDesignState = reactive<{- selectedSchemaDesign?: SchemaDesign;-}>({});const rawSQLState = reactive<RawSQLState>({projectId: props.project?.uid,engine: Engine.MYSQL,@@ -137,15 +118,6 @@ const projectId = computed(() => {}if (state.sourceSchemaType === "SCHEMA_HISTORY_VERSION") {return changeHistorySourceSchemaState.projectId;- } else if (state.sourceSchemaType === "SCHEMA_DESIGN") {- if (!schemaDesignState.selectedSchemaDesign) {- return undefined;- }- const [projectName] = getProjectAndSchemaDesignSheetId(- schemaDesignState.selectedSchemaDesign.name- );- const project = projectStore.getProjectByName(`projects/${projectName}`);- return project.uid;} else {return rawSQLState.projectId;}@@ -179,8 +151,6 @@ const allowNext = computed(() => {isValidId(changeHistorySourceSchemaState.databaseId) &&!isUndefined(changeHistorySourceSchemaState.changeHistory));- } else if (state.sourceSchemaType === "SCHEMA_DESIGN") {- return !isUndefined(schemaDesignState.selectedSchemaDesign);} else {return (!isUndefined(rawSQLState.projectId) &&@@ -205,26 +175,6 @@ const allowNext = computed(() => {}});-onMounted(async () => {- const schemaDesignName = router.currentRoute.value.query- .schemaDesignName as string;- if (schemaDesignName) {- try {- const schemaDesign = await schemaDesignStore.fetchSchemaDesignByName(- schemaDesignName,- false /* !useCache */- );- if (schemaDesign) {- state.sourceSchemaType = "SCHEMA_DESIGN";- schemaDesignState.selectedSchemaDesign = schemaDesign;- bbStepTabRef.value?.changeStep(SELECT_TARGET_DATABASE_LIST);- }- } catch (error) {- // do nothing- }- }-});-const handleRawSQLStateChange = (state: RawSQLState) => {Object.assign(rawSQLState, state);};@@ -291,9 +241,6 @@ const tryFinishSetup = async () => {query.name = generateIssueName(targetDatabaseList.map((db) => db.databaseName));- if (schemaDesignState.selectedSchemaDesign) {- query.branch = schemaDesignState.selectedSchemaDesign.name;- }const routeInfo = {name: "workspace.issue.detail",diff --git a/frontend/src/components/SyncDatabaseSchema/types.ts b/frontend/src/components/SyncDatabaseSchema/types.tsindex 7e8844544e..07d352429a 100644--- a/frontend/src/components/SyncDatabaseSchema/types.ts+++ b/frontend/src/components/SyncDatabaseSchema/types.ts@@ -1,10 +1,7 @@import { Engine } from "@/types/proto/v1/common";import { ChangeHistory } from "@/types/proto/v1/database_service";-export type SourceSchemaType =- | "SCHEMA_HISTORY_VERSION"- | "SCHEMA_DESIGN"- | "RAW_SQL";+export type SourceSchemaType = "SCHEMA_HISTORY_VERSION" | "RAW_SQL";export interface ChangeHistorySourceSchema {projectId?: string;