Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(schema-design): implement diff editor to resolve conflicts (#7720)

boojackc0a419cc2faf
diff --git a/backend/api/v1/schema_design_service.go b/backend/api/v1/schema_design_service.go
index ea5c9215ee..d035609fe0 100644
--- a/backend/api/v1/schema_design_service.go
+++ b/backend/api/v1/schema_design_service.go
@@ -378,9 +378,10 @@ func (s *SchemaDesignService) MergeSchemaDesign(ctx context.Context, request *v1
return nil, status.Errorf(codes.InvalidArgument, "only main branch schema design can be merged to")
}
+ baselineEtag := GenerateEtag([]byte(schemaDesign.BaselineSchema))
// Restrict merging only when the target schema design is not updated.
// Maybe we can support auto-merging in the future.
- if schemaDesign.Etag != targetSchemaDesign.Etag {
+ if baselineEtag != targetSchemaDesign.Etag {
return nil, status.Errorf(codes.FailedPrecondition, "schema design has been updated")
}
@@ -512,7 +513,7 @@ func (s *SchemaDesignService) convertSheetToSchemaDesign(ctx context.Context, sh
return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to transform schema string to database metadata: %v", err))
}
- baselineSchema, etag, baselineSheetName := "", "", ""
+ baselineSchema, baselineSheetName := "", ""
schemaDesignType := v1pb.SchemaDesign_Type(sheetPayload.SchemaDesign.Type)
// For backward compatibility, we default to MAIN_BRANCH if the type is not specified.
if schemaDesignType == v1pb.SchemaDesign_TYPE_UNSPECIFIED {
@@ -533,12 +534,10 @@ func (s *SchemaDesignService) convertSheetToSchemaDesign(ctx context.Context, sh
}
if schemaDesignType == v1pb.SchemaDesign_MAIN_BRANCH {
- etag = GenerateEtag([]byte(schema))
if sheetPayload.SchemaDesign.BaselineSheetId != "" {
baselineSheetName = fmt.Sprintf("%s%s/%s%v", common.ProjectNamePrefix, project.ResourceID, common.SheetIDPrefix, sheetPayload.SchemaDesign.BaselineSheetId)
}
} else {
- etag = GenerateEtag([]byte(baselineSchema))
if sheetPayload.SchemaDesign.BaselineSchemaDesignId != "" {
baselineSheetName = fmt.Sprintf("%s%s/%s%v", common.ProjectNamePrefix, project.ResourceID, common.SchemaDesignPrefix, sheetPayload.SchemaDesign.BaselineSchemaDesignId)
}
@@ -561,7 +560,7 @@ func (s *SchemaDesignService) convertSheetToSchemaDesign(ctx context.Context, sh
Engine: engine,
BaselineDatabase: fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, database.InstanceID, common.DatabaseIDPrefix, database.DatabaseName),
Type: schemaDesignType,
- Etag: etag,
+ Etag: GenerateEtag([]byte(schema)),
Creator: fmt.Sprintf("users/%s", creator.Email),
Updater: fmt.Sprintf("users/%s", updater.Email),
CreateTime: timestamppb.New(sheet.CreatedTime),
diff --git a/frontend/src/components/MonacoEditor/DiffEditor.vue b/frontend/src/components/MonacoEditor/DiffEditor.vue
new file mode 100644
index 0000000000..c4b9c7389f
--- /dev/null
+++ b/frontend/src/components/MonacoEditor/DiffEditor.vue
@@ -0,0 +1,156 @@
+<template>
+ <div ref="editorContainerRef" v-bind="$attrs" class="relative">
+ <div
+ v-if="!isEditorLoaded"
+ class="absolute inset-0 flex flex-col items-center justify-center"
+ >
+ <BBSpin />
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { editor as Editor } from "monaco-editor";
+import {
+ onMounted,
+ ref,
+ toRef,
+ nextTick,
+ watch,
+ shallowRef,
+ PropType,
+ onBeforeUnmount,
+} from "vue";
+import { Language, SQLDialect } from "@/types";
+
+const props = defineProps({
+ original: {
+ type: String,
+ default: "",
+ },
+ value: {
+ type: String,
+ default: "",
+ },
+ language: {
+ type: String as PropType<Language>,
+ default: "sql",
+ },
+ dialect: {
+ type: String as PropType<SQLDialect>,
+ default: "MYSQL",
+ },
+ readonly: {
+ type: Boolean,
+ default: false,
+ },
+ autoFocus: {
+ type: Boolean,
+ default: true,
+ },
+});
+
+const emit = defineEmits<{
+ (e: "change", content: string): void;
+ (e: "ready"): void;
+}>();
+
+const sqlCode = toRef(props, "value");
+const readOnly = toRef(props, "readonly");
+const editorContainerRef = ref<HTMLDivElement>();
+// use shallowRef to avoid deep conversion which will cause page crash.
+const editorInstanceRef = shallowRef<Editor.IStandaloneDiffEditor>();
+
+const isEditorLoaded = ref(false);
+
+const initEditorInstance = () => {
+ const originalModel = Editor.createModel(props.original, "text/sql");
+ const valueModel = Editor.createModel(sqlCode.value, "text/sql");
+ const editorInstance = Editor.createDiffEditor(editorContainerRef.value!, {
+ // Learn more: https://github.com/microsoft/monaco-editor/issues/311
+ enableSplitViewResizing: false,
+ renderValidationDecorations: "on",
+ theme: "bb",
+ autoClosingQuotes: "always",
+ folding: false,
+ automaticLayout: true,
+ readOnly: readOnly.value,
+ minimap: {
+ enabled: false,
+ },
+ wordWrap: "on",
+ fixedOverflowWidgets: true,
+ fontSize: 15,
+ lineHeight: 24,
+ scrollBeyondLastLine: false,
+ padding: {
+ top: 8,
+ bottom: 8,
+ },
+ renderLineHighlight: "none",
+ codeLens: false,
+ scrollbar: {
+ alwaysConsumeMouseWheel: false,
+ },
+ });
+
+ editorInstance.setModel({
+ original: originalModel,
+ modified: valueModel,
+ });
+
+ // typed something, change the text
+ editorInstance.onDidUpdateDiff(() => {
+ const value = editorInstance.getModifiedEditor().getValue();
+ emit("change", value);
+ });
+
+ return editorInstance;
+};
+
+onMounted(async () => {
+ if (!editorContainerRef.value) {
+ // Give up creating monaco editor if the component has been unmounted
+ // very quickly.
+ console.debug(
+ "<MonacoEditor> has been unmounted before useMonaco is ready"
+ );
+ return;
+ }
+
+ const editorInstance = initEditorInstance();
+ editorInstanceRef.value = editorInstance;
+
+ isEditorLoaded.value = true;
+
+ nextTick(() => {
+ emit("ready");
+ });
+});
+
+onBeforeUnmount(() => {
+ editorInstanceRef.value?.dispose();
+});
+
+watch(
+ () => readOnly.value,
+ (readOnly) => {
+ editorInstanceRef.value?.updateOptions({
+ readOnly: readOnly,
+ });
+ },
+ {
+ deep: true,
+ immediate: true,
+ }
+);
+</script>
+
+<style>
+.monaco-editor .monaco-mouse-cursor-text {
+ box-shadow: none !important;
+}
+.monaco-editor .scroll-decoration {
+ display: none !important;
+}
+</style>
diff --git a/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue b/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue
index 3d5f1d6289..a54a7ef4cd 100644
--- a/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue
+++ b/frontend/src/components/SchemaDesigner/EditSchemaDesignPanel.vue
@@ -29,22 +29,29 @@
>
{{ $t("schema-designer.personal-draft") }}
</NTag>
+ <NTag v-else type="primary" size="small" round>Main</NTag>
+
+ <NDropdown
+ v-if="!state.isEditing && schemaDesignDrafts.length > 0"
+ class="max-w-[10rem]"
+ trigger="click"
+ :options="schemaDesignDraftDropdownOptions"
+ :render-label="renderDraftsLabel"
+ @select="handleSchemaDesignDraftSelect"
+ >
+ <NButton size="small" quaternary>
+ <template #icon>
+ <NIcon size="16">
+ <History class="opacity-80" />
+ </NIcon>
+ </template>
+ </NButton>
+ </NDropdown>
</div>
<div>
<div class="w-full flex flex-row justify-between items-center">
<div class="flex flex-row justify-end items-center space-x-2">
<template v-if="!state.isEditing">
- <NDropdown
- trigger="click"
- :options="schemaDesignDraftDropdownOptions"
- @select="handleSchemaDesignDraftSelect"
- >
- <NButton text style="font-size: 18px">
- <NIcon>
- <History class="opacity-60" />
- </NIcon>
- </NButton>
- </NDropdown>
<NButton @click="handleEdit">{{ $t("common.edit") }}</NButton>
<NButton
v-if="!viewMode && !isSchemaDesignDraft"
@@ -125,6 +132,13 @@
</template>
</NDrawerContent>
</NDrawer>
+
+ <ResolveConflictPanel
+ v-if="state.showDiffEditor"
+ :schema-design-name="state.schemaDesignName"
+ @dismiss="state.showDiffEditor = false"
+ @try-merge="handleMergeAfterConflictResolved"
+ />
</template>
<script lang="ts" setup>
@@ -138,9 +152,12 @@ import {
NIcon,
NInput,
NTag,
+ useDialog,
+ DropdownOption,
+ NEllipsis,
} from "naive-ui";
import { Status } from "nice-grpc-common";
-import { computed, onMounted, reactive, ref, watch } from "vue";
+import { computed, h, onMounted, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { DatabaseV1Name, InstanceV1EngineIcon } from "@/components/v2";
@@ -152,6 +169,7 @@ import {
SchemaDesign_Type,
} from "@/types/proto/v1/schema_design_service";
import { projectV1Slug } from "@/utils";
+import ResolveConflictPanel from "./ResolveConflictPanel.vue";
import { mergeSchemaEditToMetadata } from "./common/util";
import SchemaDesigner from "./index.vue";
@@ -160,6 +178,7 @@ interface LocalState {
// Pre edit or editing schema design name.
schemaDesignName: string;
isEditing: boolean;
+ showDiffEditor: boolean;
}
const props = defineProps<{
@@ -173,13 +192,19 @@ const { t } = useI18n();
const router = useRouter();
const databaseStore = useDatabaseV1Store();
const schemaDesignStore = useSchemaDesignStore();
+const dialog = useDialog();
const state = reactive<LocalState>({
schemaDesignTitle: "",
schemaDesignName: props.schemaDesignName,
isEditing: false,
+ showDiffEditor: false,
});
const schemaDesignerRef = ref<InstanceType<typeof SchemaDesigner>>();
+const mainSchemaDesign = computed(() => {
+ return schemaDesignStore.getSchemaDesignByName(props.schemaDesignName || "");
+});
+
const schemaDesign = computed(() => {
return schemaDesignStore.getSchemaDesignByName(state.schemaDesignName || "");
});
@@ -198,19 +223,14 @@ const schemaDesignDrafts = computed(() => {
});
const schemaDesignDraftDropdownOptions = computed(() => {
- return schemaDesignDrafts.value
+ return [mainSchemaDesign.value]
+ .concat(schemaDesignDrafts.value)
.map((schemaDesign) => {
return {
label: schemaDesign.title,
key: schemaDesign.name,
};
- })
- .concat([
- {
- label: "Clear",
- key: props.schemaDesignName,
- },
- ]);
+ });
});
const baselineDatabase = computed(() => {
@@ -241,6 +261,43 @@ watch(
}
);
+const renderDraftsLabel = (option: DropdownOption) => {
+ const schemaDesign = schemaDesignStore.getSchemaDesignByName(
+ option.key as string
+ );
+ if (!schemaDesign) {
+ // Should not reach here.
+ return h(NEllipsis, {}, () => [h("span", {}, () => [option.label])]);
+ }
+
+ return h(
+ "div",
+ {
+ class: "w-full flex justify-between items-center",
+ },
+ [
+ h(
+ NEllipsis,
+ {
+ class: "shrink !max-w-[4rem]",
+ },
+ [schemaDesign.title]
+ ),
+ h(
+ "span",
+ {
+ class: "text-xs font-mono shrink-0 text-gray-400 ml-1 mt-0.5",
+ },
+ [
+ schemaDesign.name === props.schemaDesignName
+ ? "main"
+ : schemaDesign.etag.slice(0, 6),
+ ]
+ ),
+ ]
+ );
+};
+
const handleEdit = async () => {
// Allow editing directly if it's a personal draft.
if (schemaDesign.value.type === SchemaDesign_Type.PERSONAL_DRAFT) {
@@ -344,12 +401,21 @@ const handleMergeSchemaDesign = async () => {
} catch (error: any) {
// If there is conflict, we need to show the conflict and let user resolve it.
if (error.code === Status.FAILED_PRECONDITION) {
- // TODO(steven): show the conflict and let user resolve it.
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: "Merge to main failed",
- description: error.details,
+ dialog.create({
+ positiveText: t("schema-designer.diff-editor.resolve"),
+ negativeText: t("common.cancel"),
+ title: t("schema-designer.diff-editor.auto-merge-failed"),
+ content: t("schema-designer.diff-editor.need-to-resolve-conflicts"),
+ autoFocus: false,
+ closable: false,
+ maskClosable: false,
+ closeOnEsc: false,
+ onNegativeClick: () => {
+ // nothing to do
+ },
+ onPositiveClick: () => {
+ state.showDiffEditor = true;
+ },
});
} else {
pushNotification({
@@ -365,12 +431,17 @@ const handleMergeSchemaDesign = async () => {
pushNotification({
module: "bytebase",
style: "SUCCESS",
- title: "Merge to main succeed",
+ title: t("schema-designer.message.merge-to-main-successfully"),
});
// Auto select the main branch after merged.
state.schemaDesignName = props.schemaDesignName;
};
+const handleMergeAfterConflictResolved = () => {
+ state.showDiffEditor = false;
+ handleMergeSchemaDesign();
+};
+
const handleApplySchemaDesignClick = () => {
router.push({
name: "workspace.sync-schema",
diff --git a/frontend/src/components/SchemaDesigner/ResolveConflictPanel.vue b/frontend/src/components/SchemaDesigner/ResolveConflictPanel.vue
new file mode 100644
index 0000000000..3279b3c9a0
--- /dev/null
+++ b/frontend/src/components/SchemaDesigner/ResolveConflictPanel.vue
@@ -0,0 +1,134 @@
+<template>
+ <NDrawer
+ :show="true"
+ width="auto"
+ :auto-focus="false"
+ :close-on-esc="true"
+ @update:show="(show: boolean) => !show && emit('dismiss')"
+ >
+ <NDrawerContent
+ :title="$t('schema-designer.diff-editor.self')"
+ :closable="true"
+ >
+ <div
+ class="space-y-3 w-[calc(100vw-24rem)] min-w-[64rem] max-w-[calc(100vw-8rem)] h-full overflow-x-auto"
+ >
+ <div class="w-full grid grid-cols-2">
+ <div class="col-span-1">
+ <span>{{ $t("schema-designer.diff-editor.latest-schema") }}</span>
+ </div>
+ <div class="col-span-1">
+ <span>{{ $t("schema-designer.diff-editor.editing-schema") }}</span>
+ </div>
+ </div>
+ <div class="w-full h-[calc(100%-8rem)] border">
+ <DiffEditor
+ v-if="state.initialized"
+ class="h-full"
+ :original="baselineSchemaDesign.schema"
+ :value="state.editingSchema"
+ @change="state.editingSchema = $event"
+ />
+ </div>
+ </div>
+
+ <template #footer>
+ <div class="flex items-center justify-end gap-x-2">
+ <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>
+ <NButton type="primary" @click="handleResolveSchemaDesignDraft">
+ {{ $t("schema-designer.diff-editor.resolve-and-merge-again") }}
+ </NButton>
+ </div>
+ </template>
+ </NDrawerContent>
+ </NDrawer>
+</template>
+
+<script lang="ts" setup>
+import { NDrawer, NDrawerContent } from "naive-ui";
+import { computed, onMounted, reactive } from "vue";
+import DiffEditor from "@/components/MonacoEditor/DiffEditor.vue";
+import { useSheetV1Store } from "@/store";
+import { useSchemaDesignStore } from "@/store/modules/schemaDesign";
+import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";
+import { SchemaDesign } from "@/types/proto/v1/schema_design_service";
+import {
+ Sheet_Source,
+ Sheet_Type,
+ Sheet_Visibility,
+} from "@/types/proto/v1/sheet_service";
+
+interface LocalState {
+ editingSchema: string;
+ initialized: boolean;
+}
+
+const props = defineProps<{
+ // Should be a schema design name of personal draft.
+ schemaDesignName: string;
+}>();
+
+const emit = defineEmits(["dismiss", "try-merge"]);
+
+const state = reactive<LocalState>({
+ editingSchema: "",
+ initialized: false,
+});
+const sheetStore = useSheetV1Store();
+const schemaDesignStore = useSchemaDesignStore();
+
+const schemaDesign = computed(() => {
+ return schemaDesignStore.getSchemaDesignByName(props.schemaDesignName || "");
+});
+
+const baselineSchemaDesign = computed(() => {
+ return schemaDesignStore.getSchemaDesignByName(
+ schemaDesign.value.baselineSheetName || ""
+ );
+});
+
+const prepareLastestBaselineSchemaDesign = async () => {
+ await schemaDesignStore.fetchSchemaDesignByName(
+ schemaDesign.value.baselineSheetName
+ );
+};
+
+onMounted(async () => {
+ await prepareLastestBaselineSchemaDesign();
+ state.editingSchema = schemaDesign.value.schema;
+ state.initialized = true;
+});
+
+const handleResolveSchemaDesignDraft = async () => {
+ const updateMask = ["schema", "baseline_sheet_name"];
+ const [projectName] = getProjectAndSchemaDesignSheetId(
+ baselineSchemaDesign.value.name
+ );
+ // Create a baseline sheet for the schema design.
+ const baselineSheet = await sheetStore.createSheet(
+ `projects/${projectName}`,
+ {
+ name: `baseline schema of ${baselineSchemaDesign.value.title}`,
+ database: schemaDesign.value.baselineDatabase,
+ content: new TextEncoder().encode(baselineSchemaDesign.value.schema),
+ visibility: Sheet_Visibility.VISIBILITY_PROJECT,
+ source: Sheet_Source.SOURCE_BYTEBASE_ARTIFACT,
+ type: Sheet_Type.TYPE_SQL,
+ }
+ );
+
+ // Update the schema design draft first.
+ await schemaDesignStore.updateSchemaDesign(
+ SchemaDesign.fromPartial({
+ name: schemaDesign.value.name,
+ engine: schemaDesign.value.engine,
+ schema: state.editingSchema,
+ baselineSheetName: baselineSheet.name,
+ }),
+ updateMask
+ );
+
+ // Try to merge the schema design draft again.
+ emit("try-merge");
+};
+</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index b059681af6..726d1383b5 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2807,6 +2807,15 @@
"personal-draft": "Personal draft",
"save-draft": "Save draft",
"merge-to-main": "Merge to main",
+ "diff-editor": {
+ "self": "Diff editor",
+ "resolve": "Resolve",
+ "latest-schema": "Latest schema",
+ "editing-schema": "Editing schema",
+ "auto-merge-failed": "Auto merge failed",
+ "need-to-resolve-conflicts": "Schema design has been updated by others. You need to resolve the conflicts before you can merge.",
+ "resolve-and-merge-again": "Resolve and merge again"
+ },
"tables": "Tables",
"search-tables": "Search tables",
"use-tips": "Click a table to start.",
@@ -2815,7 +2824,8 @@
"select-database-placeholder": "Select a database (MySQL only)",
"message": {
"created-succeed": "Schema design created successfully",
- "updated-succeed": "Schema design updated successfully"
+ "updated-succeed": "Schema design updated successfully",
+ "merge-to-main-successfully": "Merge to main successfully"
}
}
}
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 4ad4be5516..dbbe479d3b 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2803,6 +2803,15 @@
"personal-draft": "Borrador personal",
"save-draft": "Guardar borrador",
"merge-to-main": "Fusionar a principal",
+ "diff-editor": {
+ "self": "Editor de diferencias",
+ "resolve": "Resolver",
+ "latest-schema": "Último esquema",
+ "editing-schema": "Editando esquema",
+ "auto-merge-failed": "Falló la fusión automática",
+ "need-to-resolve-conflicts": "El diseño del esquema ha sido actualizado por otros. Debe resolver los conflictos antes de poder fusionar.",
+ "resolve-and-merge-again": "Resolver y fusionar nuevamente"
+ },
"tables": "Tablas",
"search-tables": "Buscar tablas",
"use-tips": "Selecciona las tablas a diseñar",
@@ -2811,7 +2820,8 @@
"select-database-placeholder": "Seleccionar base de datos (sólo MySQL)",
"message": {
"created-succeed": "Diseño de esquema creado con éxito",
- "updated-succeed": "Diseño de esquema actualizado con éxito"
+ "updated-succeed": "Diseño de esquema actualizado con éxito",
+ "merge-to-main-successfully": "Fusionar con el principal exitosamente"
}
}
}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 79b78423fd..d0253d434c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2799,6 +2799,15 @@
"personal-draft": "个人草稿",
"save-draft": "保存草稿",
"merge-to-main": "合并到主版本",
+ "diff-editor": {
+ "self": "Diff 编辑器",
+ "resolve": "解决",
+ "latest-schema": "最新 Schema",
+ "editing-schema": "正在编辑的 Schema",
+ "auto-merge-failed": "自动合并失败",
+ "need-to-resolve-conflicts": "Schema 设计已经被其他用户更新,您需要先解决可能存在的冲突。",
+ "resolve-and-merge-again": "解决冲突并再次合并"
+ },
"tables": "表",
"search-tables": "搜索表",
"use-tips": "选择需要设计的表",
@@ -2807,7 +2816,8 @@
"select-database-placeholder": "选择数据库 (仅限 MySQL)",
"message": {
"created-succeed": "Schema 设计创建成功",
- "updated-succeed": "Schema 设计更新成功"
+ "updated-succeed": "Schema 设计更新成功",
+ "merge-to-main-successfully": "成功合并到主版本"
}
}
}
diff --git a/frontend/src/types/proto/v1/schema_design_service.ts b/frontend/src/types/proto/v1/schema_design_service.ts
index 33e8531668..6dfdcff8b7 100644
--- a/frontend/src/types/proto/v1/schema_design_service.ts
+++ b/frontend/src/types/proto/v1/schema_design_service.ts
@@ -39,7 +39,8 @@ export interface SchemaDesign {
baselineDatabase: string;
/**
* The name of the baseline sheet.
- * Format: projects/{project}/sheets/{sheet}
+ * For main branch, its format will be: projects/{project}/sheets/{sheet}
+ * For personal draft, its format will be: projects/{project}/schemaDesigns/{schemaDesign}
*/
baselineSheetName: string;
/** The type of the schema design. */
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 10eab010d2..669ca9ce13 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -8140,7 +8140,7 @@ When paginating, all other parameters provided to `ListSchemaDesigns` must match
| baseline_schema_metadata | [DatabaseMetadata](#bytebase-v1-DatabaseMetadata) | | The metadata of the baseline schema. |
| engine | [Engine](#bytebase-v1-Engine) | | The database engine of the schema design. |
| baseline_database | [string](#string) | | The name of the baseline database. Format: instances/{instance}/databases/{database} |
-| baseline_sheet_name | [string](#string) | | The name of the baseline sheet. Format: projects/{project}/sheets/{sheet} |
+| baseline_sheet_name | [string](#string) | | The name of the baseline sheet. For main branch, its format will be: projects/{project}/sheets/{sheet} For personal draft, its format will be: projects/{project}/schemaDesigns/{schemaDesign} |
| type | [SchemaDesign.Type](#bytebase-v1-SchemaDesign-Type) | | The type of the schema design. |
| etag | [string](#string) | | The etag of the schema design. |
| creator | [string](#string) | | The creator of the schema design. Format: users/{email} |
diff --git a/proto/generated-go/v1/schema_design_service.pb.go b/proto/generated-go/v1/schema_design_service.pb.go
index a2c60b3c04..64d1d891e7 100644
--- a/proto/generated-go/v1/schema_design_service.pb.go
+++ b/proto/generated-go/v1/schema_design_service.pb.go
@@ -100,7 +100,8 @@ type SchemaDesign struct {
// Format: instances/{instance}/databases/{database}
BaselineDatabase string `protobuf:"bytes,8,opt,name=baseline_database,json=baselineDatabase,proto3" json:"baseline_database,omitempty"`
// The name of the baseline sheet.
- // Format: projects/{project}/sheets/{sheet}
+ // For main branch, its format will be: projects/{project}/sheets/{sheet}
+ // For personal draft, its format will be: projects/{project}/schemaDesigns/{schemaDesign}
BaselineSheetName string `protobuf:"bytes,9,opt,name=baseline_sheet_name,json=baselineSheetName,proto3" json:"baseline_sheet_name,omitempty"`
// The type of the schema design.
Type SchemaDesign_Type `protobuf:"varint,10,opt,name=type,proto3,enum=bytebase.v1.SchemaDesign_Type" json:"type,omitempty"`
diff --git a/proto/v1/schema_design_service.proto b/proto/v1/schema_design_service.proto
index 979c07ee77..f59f6791af 100644
--- a/proto/v1/schema_design_service.proto
+++ b/proto/v1/schema_design_service.proto
@@ -87,7 +87,8 @@ message SchemaDesign {
string baseline_database = 8 [(google.api.field_behavior) = IMMUTABLE];
// The name of the baseline sheet.
- // Format: projects/{project}/sheets/{sheet}
+ // For main branch, its format will be: projects/{project}/sheets/{sheet}
+ // For personal draft, its format will be: projects/{project}/schemaDesigns/{schemaDesign}
string baseline_sheet_name = 9 [(google.api.field_behavior) = IMMUTABLE];
enum Type {