Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add sync schema dialog (#2720)
boojack0a0d01ddf962
diff --git a/frontend/src/bbkit/BBSelect.vue b/frontend/src/bbkit/BBSelect.vueindex e65b42f124..3d69959ff5 100644--- a/frontend/src/bbkit/BBSelect.vue+++ b/frontend/src/bbkit/BBSelect.vue@@ -64,6 +64,7 @@:key="index"role="option"class="group text-main hover:text-main-text hover:bg-main-hover cursor-default select-none relative py-2 pl-3 pr-9"+ :class="itemAdditionClass"@click="if (item !== state.selectedItem) {$emit('select-item', item, () => {@@ -146,6 +147,10 @@ export default defineComponent({type: String as PropType<FitWidthMode>,default: "fit",},+ itemAdditionClass: {+ type: String,+ default: "",+ },},emits: ["select-item"],setup(props) {diff --git a/frontend/src/components/DatabaseSelect.vue b/frontend/src/components/DatabaseSelect.vueindex 42e70bc29d..d08f0c7904 100644--- a/frontend/src/components/DatabaseSelect.vue+++ b/frontend/src/components/DatabaseSelect.vue@@ -5,17 +5,25 @@:disabled="disabled":placeholder="$t('database.select')":show-prefix-item="true"+ :item-addition-class="+ showEngineIcon ? 'hover:!bg-gray-200 hover:text-main' : ''+ "@select-item="(database: Database) => $emit('select-database-id', database.id)"><template #menuItem="{ item: database }"><div class="flex items-center">- {{ database.name }}+ <InstanceEngineIcon+ v-if="showEngineIcon"+ :instance="database.instance"+ />+ <span :class="showEngineIcon ? 'ml-2' : ''">{{ database.name }}</span></div></template></BBSelect></template><script lang="ts">+import { isNullOrUndefined } from "@/plugins/demo/utils";import { useCurrentUser, useDatabaseStore } from "@/store";import {computed,@@ -31,6 +39,7 @@ import {ProjectId,InstanceId,EnvironmentId,+ EngineType,} from "../types";interface LocalState {@@ -61,6 +70,14 @@ export default defineComponent({default: UNKNOWN_ID,type: Number as PropType<ProjectId>,},+ engineType: {+ default: undefined,+ type: String as PropType<EngineType>,+ },+ showEngineIcon: {+ type: Boolean,+ default: false,+ },disabled: {default: false,type: Boolean,@@ -113,6 +130,13 @@ export default defineComponent({});}}++ if (!isNullOrUndefined(props.engineType)) {+ list = list.filter((database: Database) => {+ return database.instance.engine === props.engineType;+ });+ }+return list;});diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex dc05d680e7..74fa5207aa 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -86,7 +86,20 @@{{ $t("database.change-data") }}</h3></div>-+ <div+ v-if="isDev && quickAction === 'quickaction.bb.database.schema.sync'"+ class="flex flex-col items-center w-28 py-1"+ >+ <button+ class="btn-icon-primary p-3"+ @click.prevent="syncDatabaseSchema"+ >+ <heroicons-outline:refresh class="w-6 h-6" />+ </button>+ <h3 class="mt-1 text-center text-base font-normal text-main">+ {{ $t("quick-action.sync-schema") }}+ </h3>+ </div><divv-if="quickAction === 'quickaction.bb.database.troubleshoot'"class="flex flex-col items-center w-28 py-1"@@ -215,6 +228,15 @@@dismiss="state.showModal = false"/></template>+ <template+ v-else-if="state.quickActionType == 'quickaction.bb.database.schema.sync'"+ >+ <SyncDatabaseSchemaPrepForm+ v-if="projectId"+ :project-id="projectId"+ @dismiss="state.showModal = false"+ />+ </template></BBModal><FeatureModalv-if="state.showFeatureModal"@@ -224,24 +246,25 @@</template><script lang="ts">+import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";+import { kebabCase } from "lodash-es";import { defineComponent, reactive, PropType, computed, watch } from "vue";+import { useI18n } from "vue-i18n";import { useRoute, useRouter } from "vue-router";-import { kebabCase } from "lodash-es";-import ProjectCreate from "../components/ProjectCreate.vue";-import CreateInstanceForm from "../components/CreateInstanceForm.vue";-import AlterSchemaPrepForm from "./AlterSchemaPrepForm/";-import CreateDatabasePrepForm from "../components/CreateDatabasePrepForm.vue";-import RequestDatabasePrepForm from "../components/RequestDatabasePrepForm.vue";-import TransferDatabaseForm from "../components/TransferDatabaseForm.vue";import { ProjectId, QuickActionType } from "../types";import { idFromSlug } from "../utils";-import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";-import { useI18n } from "vue-i18n";import {useCommandStore,useInstanceStore,useSubscriptionStore,} from "@/store";+import ProjectCreate from "../components/ProjectCreate.vue";+import CreateInstanceForm from "../components/CreateInstanceForm.vue";+import AlterSchemaPrepForm from "./AlterSchemaPrepForm/";+import CreateDatabasePrepForm from "../components/CreateDatabasePrepForm.vue";+import RequestDatabasePrepForm from "../components/RequestDatabasePrepForm.vue";+import TransferDatabaseForm from "../components/TransferDatabaseForm.vue";+import SyncDatabaseSchemaPrepForm from "./SyncDatabaseSchemaPrepForm.vue";interface LocalState {showModal: boolean;@@ -260,6 +283,7 @@ export default defineComponent({CreateDatabasePrepForm,RequestDatabasePrepForm,TransferDatabaseForm,+ SyncDatabaseSchemaPrepForm,},props: {quickActionList: {@@ -328,6 +352,12 @@ export default defineComponent({state.showModal = true;};+ const syncDatabaseSchema = () => {+ state.modalTitle = t("quick-action.sync-schema");+ state.quickActionType = "quickaction.bb.database.schema.sync";+ state.showModal = true;+ };+const changeData = () => {state.modalTitle = t("database.change-data");state.modalSubtitle = t("quick-action.choose-db");@@ -382,6 +412,10 @@ export default defineComponent({name: t("quick-action.troubleshoot"),perform: () => router.push({ path: "/issue/new" }),},+ "quickaction.bb.database.schema.sync": {+ name: t("quick-action.sync-schema"),+ perform: () => syncDatabaseSchema(),+ },"quickaction.bb.environment.create": {name: t("quick-action.add-environment"),perform: () => createEnvironment(),@@ -426,6 +460,7 @@ export default defineComponent({createInstance,alterSchema,changeData,+ syncDatabaseSchema,createDatabase,requestDatabase,createEnvironment,diff --git a/frontend/src/components/SyncDatabaseSchemaPrepForm.vue b/frontend/src/components/SyncDatabaseSchemaPrepForm.vuenew file mode 100644index 0000000000..7e7fc5d40d--- /dev/null+++ b/frontend/src/components/SyncDatabaseSchemaPrepForm.vue@@ -0,0 +1,467 @@+<template>+ <div+ class="space-y-4 overflow-x-hidden w-144 transition-all"+ :class="state.currentStep === 1 ? 'w-176' : ''"+ >+ <!-- Base and target database selectors -->+ <div+ v-show="state.currentStep === 0"+ class="w-full flex flex-col justify-start items-start"+ >+ <p class="mb-2">{{ $t("database.sync-schema.description") }}</p>+ <div class="w-full">+ <p class="mt-4 mb-2 text-gray-600">+ {{ $t("database.sync-schema.base-database") }}+ </p>+ <div class="w-full flex flex-row justify-start items-center">+ <EnvironmentSelect+ class="!w-48 mr-2 shrink-0"+ name="environment"+ :selected-id="state.baseSchemaInfo.environmentId"+ :select-default="false"+ @select-environment-id="+ (environmentId) =>+ (state.baseSchemaInfo.environmentId = environmentId)+ "+ />+ <DatabaseSelect+ class="!w-48 mr-2 shrink-0"+ :selected-id="(state.baseSchemaInfo.databaseId as DatabaseId)"+ :mode="'ENVIRONMENT'"+ :environment-id="state.baseSchemaInfo.environmentId"+ :project-id="props.projectId"+ :show-engine-icon="true"+ @select-database-id="+ (databaseId: DatabaseId) => {+ state.baseSchemaInfo.databaseId = databaseId;+ }+ "+ />+ <BBSelect+ class=""+ :selected-item="state.baseSchemaInfo.migrationHistory"+ :item-list="+ databaseMigrationHistoryList(state.baseSchemaInfo.databaseId as DatabaseId)+ "+ :placeholder="$t('migration-history.select')"+ :show-prefix-item="true"+ @select-item="(migrationHistory: MigrationHistory) => state.baseSchemaInfo.migrationHistory = migrationHistory"+ >+ <template #menuItem="{ item: migrationHistory }">+ <div class="flex items-center">+ {{ migrationHistory.version }}+ </div>+ </template>+ </BBSelect>+ </div>+ </div>+ <div class="w-full">+ <p class="mt-4 mb-2 text-gray-600">+ {{ $t("database.sync-schema.target-database") }}+ </p>+ <div class="w-full flex flex-row justify-start items-center">+ <EnvironmentSelect+ class="!w-48 mr-2 shrink-0"+ name="environment"+ :selected-id="state.targetSchemaInfo.environmentId"+ :select-default="false"+ @select-environment-id="+ (environmentId) =>+ (state.targetSchemaInfo.environmentId = environmentId)+ "+ />+ <DatabaseSelect+ class="!grow !w-full"+ :selected-id="(state.targetSchemaInfo.databaseId as DatabaseId)"+ :mode="'ENVIRONMENT'"+ :environment-id="state.targetSchemaInfo.environmentId"+ :project-id="props.projectId"+ :engine-type="state.engineType"+ :show-engine-icon="true"+ @select-database-id="+ (databaseId: DatabaseId) => {+ state.targetSchemaInfo.databaseId = databaseId;+ }+ "+ />+ </div>+ </div>+ </div>++ <!-- Schema diff statement editor container -->+ <div+ v-show="state.currentStep === 1"+ class="w-full flex flex-col justify-start items-start"+ >+ <div+ class="w-full flex flex-row justify-between items-center mb-2 leading-8"+ >+ <div class="flex flex-row justify-start items-center">+ <span>{{ $t("database.sync-schema.synchronize-statements") }}</span>+ <button+ type="button"+ class="btn-icon ml-2"+ @click.prevent="copyStatement"+ >+ <heroicons-solid:clipboard class="h-5 w-5" />+ </button>+ </div>+ <div>+ <button+ v-if="state.recommandStatement !== state.editStatement"+ type="button"+ class="btn-icon border px-3 pl-4 leading-7 hover:border-gray-500"+ @click.prevent="handleGenerateButtonClick"+ >+ {{ $t("common.restore") }}+ <heroicons-solid:refresh class="h-4 w-4 ml-1" />+ </button>+ </div>+ </div>+ <p+ class="text-sm border px-2 mb-3 -mt-1 rounded leading-6 text-yellow-600 border-yellow-600 bg-yellow-50"+ >+ {{ $t("database.sync-schema.check-generated-ddl-statement") }}+ </p>+ <div class="whitespace-pre-wrap w-full overflow-hidden border">+ <MonacoEditor+ ref="editorRef"+ class="w-full h-auto max-h-[300px]"+ data-label="bb-issue-sql-editor"+ :value="state.editStatement"+ :auto-focus="false"+ :dialect="(state.engineType as SQLDialect)"+ @change="onStatementChange"+ @ready="updateEditorHeight"+ />+ </div>+ <div class="w-full flex flex-row justify-start items-center mt-4 mb-2">+ <span>{{ $t("database.sync-schema.schema-comparison-result") }}</span>+ </div>+ <code-diff+ class="w-full"+ :old-string="state.baseSchemaInfo.migrationHistory?.schema ?? ''"+ :new-string="targetDatabaseLatestDoneMigrationHistory?.schema ?? ''"+ output-format="side-by-side"+ data-label="bb-migration-history-code-diff-block"+ />+ </div>++ <!-- Buttons group -->+ <div class="pt-2 flex items-center justify-between">+ <span></span>+ <div class="flex items-center justify-end">+ <button+ type="button"+ class="btn-normal py-2 px-4"+ @click.prevent="handleCancelButtonClick"+ >+ {{+ state.currentStep === 0 ? $t("common.cancel") : $t("common.back")+ }}+ </button>+ <button+ :disabled="!allowNext"+ class="btn-primary ml-3 inline-flex justify-center py-2 px-4"+ @click="handleNextButtonClick"+ >+ {{+ state.currentStep === 0 ? $t("common.next") : $t("common.confirm")+ }}+ </button>+ </div>+ </div>+ </div>+</template>++<script lang="ts" setup>+import dayjs from "dayjs";+import axios from "axios";+import { computed, reactive, ref, watch } from "vue";+import { useEventListener } from "@vueuse/core";+import { useRouter } from "vue-router";+import { CodeDiff } from "v-code-diff";+import { toClipboard } from "@soerenmartius/vue3-clipboard";+import {+ DatabaseId,+ EngineType,+ EnvironmentId,+ IssueCreate,+ MigrationHistory,+ MigrationSchemaStatus,+ ProjectId,+ SQLDialect,+ SYSTEM_BOT_ID,+ UNKNOWN_ID,+ MigrationContext,+} from "@/types";+import {+ pushNotification,+ useDatabaseStore,+ useInstanceStore,+ useIssueStore,+} from "@/store";+import { isNullOrUndefined } from "@/plugins/demo/utils";+import EnvironmentSelect from "./EnvironmentSelect.vue";+import DatabaseSelect from "./DatabaseSelect.vue";+import MonacoEditor from "./MonacoEditor/MonacoEditor.vue";+import { issueSlug } from "@/utils";++type LocalState = {+ currentStep: 0 | 1;+ baseSchemaInfo: {+ environmentId?: EnvironmentId;+ databaseId?: DatabaseId;+ migrationHistory?: MigrationHistory;+ migrationSchemaStatus?: MigrationSchemaStatus;+ };+ targetSchemaInfo: {+ environmentId?: EnvironmentId;+ databaseId?: DatabaseId;+ };+ engineType?: EngineType;+ recommandStatement: string;+ editStatement: string;+};++const props = withDefaults(+ defineProps<{+ projectId: ProjectId;+ }>(),+ {+ projectId: UNKNOWN_ID,+ }+);+const emit = defineEmits(["dismiss"]);++const router = useRouter();++const editorRef = ref<InstanceType<typeof MonacoEditor>>();+const instanceStore = useInstanceStore();+const databaseStore = useDatabaseStore();++useEventListener(window, "keydown", (e) => {+ if (e.code === "Escape") {+ emit("dismiss");+ }+});++const state = reactive<LocalState>({+ currentStep: 0,+ baseSchemaInfo: {},+ targetSchemaInfo: {},+ recommandStatement: "",+ editStatement: "",+});++const targetDatabaseLatestDoneMigrationHistory = computed(() => {+ const database = databaseStore.getDatabaseById(+ state.targetSchemaInfo.databaseId as DatabaseId+ );+ const list = instanceStore+ .getMigrationHistoryListByInstanceIdAndDatabaseName(+ database.instance.id,+ database.name+ )+ .filter((history) => history.status === "DONE");++ return list[0];+});++const isValidId = (id: any) => {+ if (isNullOrUndefined(id) || id === UNKNOWN_ID) {+ return false;+ }+ return true;+};++const allowNext = computed(() => {+ if (state.currentStep === 0) {+ return (+ isValidId(state.baseSchemaInfo.environmentId) &&+ isValidId(state.baseSchemaInfo.databaseId) &&+ !isNullOrUndefined(state.baseSchemaInfo.migrationHistory) &&+ isValidId(state.targetSchemaInfo.environmentId) &&+ isValidId(state.targetSchemaInfo.databaseId)+ );+ } else {+ return state.editStatement !== "";+ }+});++const databaseMigrationHistoryList = (databaseId: DatabaseId) => {+ const database = databaseStore.getDatabaseById(databaseId);+ const list = instanceStore.getMigrationHistoryListByInstanceIdAndDatabaseName(+ database.instance.id,+ database.name+ );++ return list;+};++const handleCancelButtonClick = () => {+ if (state.currentStep === 0) {+ emit("dismiss");+ } else {+ state.currentStep = 0;+ state.recommandStatement = "";+ state.editStatement = "";+ }+};++const handleNextButtonClick = async () => {+ if (state.currentStep === 0 && allowNext.value) {+ state.currentStep = 1;+ const schema = await getSchemaDiff(+ state.engineType as EngineType,+ state.baseSchemaInfo.migrationHistory?.schema ?? "",+ targetDatabaseLatestDoneMigrationHistory.value.schema ?? ""+ );+ state.recommandStatement = schema;+ state.editStatement = schema;+ } else if (state.currentStep === 1) {+ if (state.editStatement === "") {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: "Statements shouldn't be empty",+ });+ return;+ }++ const sourceDatabase = databaseStore.getDatabaseById(+ state.baseSchemaInfo.databaseId as DatabaseId+ );+ const targetDatabase = databaseStore.getDatabaseById(+ state.targetSchemaInfo.databaseId as DatabaseId+ );++ const migrationContext: MigrationContext = {+ migrationType: "MIGRATE",+ detailList: [+ {+ databaseId: targetDatabase.id,+ databaseName: targetDatabase.name,+ statement: state.editStatement,+ earliestAllowedTs: 0,+ },+ ],+ };++ const databaseName = targetDatabase.name;+ const newIssue: IssueCreate = {+ name: `[${databaseName}] Sync Schema from ${+ sourceDatabase.name+ } @ ${dayjs().format("MM-DD HH:mm")}`,+ type: "bb.issue.database.schema.update",+ description: "",+ assigneeId: SYSTEM_BOT_ID,+ projectId: targetDatabase.projectId,+ pipeline: {+ stageList: [],+ name: "",+ },+ createContext: migrationContext,+ payload: {},+ };++ useIssueStore()+ .createIssue(newIssue)+ .then((createdIssue) => {+ router.push(`/issue/${issueSlug(createdIssue.name, createdIssue.id)}`);+ });+ }+};++const prepareMigrationHistoryList = async (databaseId: DatabaseId) => {+ const database = databaseStore.getDatabaseById(databaseId);+ if (database && database.instance.id) {+ const migration = await instanceStore.checkMigrationSetup(+ database.instance.id+ );+ state.baseSchemaInfo.migrationSchemaStatus = migration.status;+ if (state.baseSchemaInfo.migrationSchemaStatus == "OK") {+ await instanceStore.fetchMigrationHistory({+ instanceId: database.instance.id,+ databaseName: database.name,+ });+ }+ }+};++const getSchemaDiff = async (+ engineType: EngineType,+ sourceSchema: string,+ targetSchema: string+) => {+ const { data } = await axios.post("/v1/sql/schema/diff", {+ engineType,+ sourceSchema,+ targetSchema,+ });+ return data;+};++const onStatementChange = (value: string) => {+ state.editStatement = value;+ updateEditorHeight();+};++const updateEditorHeight = () => {+ const contentHeight =+ editorRef.value?.editorInstance?.getContentHeight() as number;+ const actualHeight = contentHeight;+ editorRef.value?.setEditorContentHeight(actualHeight);+};++const copyStatement = () => {+ toClipboard(state.editStatement).then(() => {+ pushNotification({+ module: "bytebase",+ style: "INFO",+ title: `Statement copied to clipboard.`,+ });+ });+};++const handleGenerateButtonClick = async () => {+ const schema = await getSchemaDiff(+ state.engineType as EngineType,+ state.baseSchemaInfo.migrationHistory?.schema ?? "",+ targetDatabaseLatestDoneMigrationHistory.value.schema ?? ""+ );+ state.recommandStatement = schema;+ state.editStatement = schema;+};++watch(+ () => [state.baseSchemaInfo.environmentId, state.baseSchemaInfo.databaseId],+ () => {+ const databaseId = state.baseSchemaInfo.databaseId;++ if (isValidId(databaseId)) {+ prepareMigrationHistoryList(databaseId as DatabaseId);+ const database = databaseStore.getDatabaseById(+ state.baseSchemaInfo.databaseId as DatabaseId+ );+ state.engineType = database.instance.engine;+ } else {+ state.engineType = undefined;+ }+ state.baseSchemaInfo.migrationHistory = undefined;+ }+);++watch(+ () => [+ state.targetSchemaInfo.environmentId,+ state.targetSchemaInfo.databaseId,+ ],+ () => {+ const databaseId = state.targetSchemaInfo.databaseId;+ if (isValidId(databaseId)) {+ prepareMigrationHistoryList(databaseId as DatabaseId);+ }+ }+);+</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d5bf0b93af..82fbcd7153 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -535,6 +535,7 @@"create-project": "@:common.create @:common.project","edit-data": "Edit Data","troubleshoot": "Troubleshoot",+ "sync-schema": "Sync Schema","transfer-in-db": "Transfer in DB","request-db": "Request DB","from-unassigned-databases": "From unassigned databases",@@ -754,6 +755,7 @@},"migration-history": {"self": "Migration History",+ "select": "Select a version","workflow": "Workflow","commit-info": "by {author} at {time}","no-schema-change": "this migration has no schema change",@@ -782,6 +784,7 @@"no-succeed-vcs-migration-record": "No succeed migration record from VCS"},"database": {+ "select": "Select database","the-list-might-be-out-of-date-and-is-refreshed-roughly-every-10-minutes": "The list might be out of date and is refreshed roughly every 10 minutes","no-anomalies-detected": "No anomalies detected","sync-status": "Sync status",@@ -888,7 +891,15 @@"view-unassigned-databases": "View unassigned databases","unassigned-databases": "Unassigned databases","restore-database": "Restore database",- "selected-n-databases": "{n} database selected | {n} databases selected"+ "selected-n-databases": "{n} database selected | {n} databases selected",+ "sync-schema": {+ "description": "Synchronize schema from the base database to the target database with the selected migration version.",+ "base-database": "Base database",+ "target-database": "Target database",+ "synchronize-statements": "The statements to synchronize",+ "schema-comparison-result": "The schema comparison result",+ "check-generated-ddl-statement": "Please check the following generated DDL statement."+ }},"repository": {"branch-observe-file-change": "The branch where Bytebase observes the file change.",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 82d6c32048..e8a5adc74c 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -535,6 +535,7 @@"create-project": "@:common.create@:common.project","edit-data": "编辑数据","troubleshoot": "问题排查",+ "sync-schema": "同步 Schema","transfer-in-db": "转移数据库","request-db": "申请数据库","from-unassigned-databases": "从未分配的数据库",@@ -754,6 +755,7 @@},"migration-history": {"self": "变更历史",+ "select": "选择一个版本","workflow": "工作流","commit-info": "由 {author} 于 {time}","no-schema-change": "本次变更没有任何 Schema 的改动",@@ -782,6 +784,7 @@"no-succeed-vcs-migration-record": "没有来自 VCS 的变更历史。"},"database": {+ "select": "选择数据库","the-list-might-be-out-of-date-and-is-refreshed-roughly-every-10-minutes": "该表每隔约10分钟刷新一次,所以展示的可能不是最新信息。","last-successful-sync": "最后一次成功的同步","no-anomalies-detected": "没有检测到异常",@@ -888,7 +891,15 @@"view-unassigned-databases": "查看未分配的数据库","unassigned-databases": "未分配的数据库","restore-database": "恢复数据库",- "selected-n-databases": "已选择 {n} 个数据库"+ "selected-n-databases": "已选择 {n} 个数据库",+ "sync-schema": {+ "description": "使用选定的迁移版本将架构从基础数据库同步到目标数据库。",+ "base-database": "基础数据库",+ "target-database": "目标数据库",+ "synchronize-statements": "生成的 Schema DDL 语句",+ "schema-comparison-result": "Schema 比较结果",+ "check-generated-ddl-statement": "请检查下面的自动生成的 DDL 语句。"+ }},"repository": {"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex e2a481b0b5..9edb960429 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -160,8 +160,6 @@ const routes: Array<RouteRecordRaw> = [? ["quickaction.bb.database.schema.update","quickaction.bb.database.data.update",- // "quickaction.bb.database.request",- // "quickaction.bb.database.troubleshoot","quickaction.bb.project.create",]: [@@ -565,7 +563,8 @@ const routes: Array<RouteRecordRaw> = [if (allowAlterSchemaOrChangeData) {actionList.push("quickaction.bb.database.schema.update",- "quickaction.bb.database.data.update"+ "quickaction.bb.database.data.update",+ "quickaction.bb.database.schema.sync");}diff --git a/frontend/src/store/modules/db_extension.ts b/frontend/src/store/modules/dbExtension.tssimilarity index 100%rename from frontend/src/store/modules/db_extension.tsrename to frontend/src/store/modules/dbExtension.tsdiff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.tsindex eccfe95f69..6cfb81b3b1 100644--- a/frontend/src/store/modules/index.ts+++ b/frontend/src/store/modules/index.ts@@ -39,6 +39,6 @@ export * from "./task";export * from "./uistate";export * from "./vcs";export * from "./view";-export * from "./db_extension";+export * from "./dbExtension";export * from "./sqlReview";export * from "./onboardingGuide";diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex c25a0f94b7..251607b540 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -93,7 +93,8 @@ export type DatabaseQuickActionType =| "quickaction.bb.database.request" // Used by Developer| "quickaction.bb.database.schema.update"| "quickaction.bb.database.data.update"- | "quickaction.bb.database.troubleshoot";+ | "quickaction.bb.database.troubleshoot"+ | "quickaction.bb.database.schema.sync";export type QuickActionType =| EnvironmentQuickActionTypediff --git a/frontend/vite.config.ts b/frontend/vite.config.tsindex cb644b0219..10d7757ea8 100644--- a/frontend/vite.config.ts+++ b/frontend/vite.config.ts@@ -53,6 +53,11 @@ export default defineConfig(() => {changeOrigin: true,rewrite: (path: string) => path.replace(/^\/api/, ""),},+ "/v1": {+ target: "http://localhost:8080/v1",+ changeOrigin: true,+ rewrite: (path: string) => path.replace(/^\/v1/, ""),+ },},hmr: {port: IS_RUNNING_GITPOD ? HTTPS_PORT : SERVER_PORT,diff --git a/server/openapi.go b/server/openapi.goindex 657805ed29..ec816bbc21 100644--- a/server/openapi.go+++ b/server/openapi.go@@ -196,7 +196,7 @@ type schemaDiffRequestBody struct {// @Param engineType body string true "The database engine type."// @Param sourceSchema body string true "The source schema statement."// @Param targetSchema body string false "The target schema statement."-// @Success 200 {array} the target diff string of schemas+// @Success 200 {string} the target diff string of schemas// @Failure 400 {object} echo.HTTPError// @Failure 500 {object} echo.HTTPError// @Router /sql/schema/diff [post].@@ -222,12 +222,12 @@ func schemaDiff(c echo.Context) error {sourceSchemaNodes, err := parser.Parse(engine, parser.ParseContext{}, request.SourceSchema)if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to parse source schema to AST nodes: %s", request.SourceSchema)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to parse source schema into AST nodes").SetInternal(err)}targetSchemaNodes, err := parser.Parse(engine, parser.ParseContext{}, request.TargetSchema)if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to parse target schema to AST nodes: %s", request.TargetSchema)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to parse target schema into AST nodes").SetInternal(err)}diff, err := parser.SchemaDiff(sourceSchemaNodes, targetSchemaNodes)