Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor(schema-editor): use SchemaEditorLite to replace SchemaEditorV1 (#12015)
Liu Jia9ed927605f5
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 8af17719c0..4240e2e05b 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -298,7 +298,7 @@ import { State } from "@/types/proto/v1/common";import { TenantMode } from "@/types/proto/v1/project_service";import type { SearchParams } from "@/utils";import {- allowUsingSchemaEditorV1,+ allowUsingSchemaEditor,instanceV1HasAlterSchema,filterDatabaseV1ByKeyword,sortDatabaseV1List,@@ -590,7 +590,7 @@ const generateMultiDb = async () => {(id) => selectableDatabaseList.value.find((db) => db.uid === id)!);- if (isEditSchema.value && allowUsingSchemaEditorV1(selectedDatabaseList)) {+ if (isEditSchema.value && allowUsingSchemaEditor(selectedDatabaseList)) {schemaEditorContext.value.databaseIdList = [...flattenSelectedDatabaseUidList.value,];@@ -694,7 +694,7 @@ const generateTenant = async () => {const databaseList = databaseV1Store.databaseListByProject(selectedProject.value.name);- if (isEditSchema.value && allowUsingSchemaEditorV1(databaseList)) {+ if (isEditSchema.value && allowUsingSchemaEditor(databaseList)) {schemaEditorContext.value.databaseIdList = databaseList.filter((database) => database.syncState === State.ACTIVE).map((database) => database.uid);@@ -717,7 +717,7 @@ const generateTenant = async () => {databaseList.push(database);}}- if (isEditSchema.value && allowUsingSchemaEditorV1(databaseList)) {+ if (isEditSchema.value && allowUsingSchemaEditor(databaseList)) {schemaEditorContext.value.databaseIdList = [...flattenSelectedDatabaseUidList.value,];diff --git a/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vueindex 7fe90946fa..fe114603cc 100644--- a/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue@@ -64,7 +64,7 @@ import { computed, onMounted, reactive } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { MonacoEditor } from "@/components/MonacoEditor";-import ActionConfirmModal from "@/components/SchemaEditorV1/Modals/ActionConfirmModal.vue";+import { ActionConfirmModal } from "@/components/SchemaEditorLite";import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";import { useDBGroupStore } from "@/store";import type { ComposedDatabaseGroup, ComposedSchemaGroup } from "@/types";diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vueindex 24f40d81d3..c575c1ad81 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue@@ -125,7 +125,7 @@ import type { PropType } from "vue";import { computed, onMounted, h, reactive, ref, watch } from "vue";import { I18nT, useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import ActionConfirmModal from "@/components/SchemaEditorV1/Modals/ActionConfirmModal.vue";+import { ActionConfirmModal } from "@/components/SchemaEditorLite";import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";import { databaseServiceClient } from "@/grpcweb";import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vueindex 8a236ee42d..5015350606 100644--- a/frontend/src/components/Branch/BranchDetailView.vue+++ b/frontend/src/components/Branch/BranchDetailView.vue@@ -143,7 +143,7 @@ import { computed, nextTick, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import DatabaseInfo from "@/components/DatabaseInfo.vue";-import { validateDatabaseMetadata } from "@/components/SchemaEditorV1/utils";+import { validateDatabaseMetadata } from "@/components/SchemaEditorLite";import TargetDatabasesSelectPanel from "@/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue";import {PROJECT_V1_ROUTE_BRANCHES,diff --git a/frontend/src/components/ColumnDataTable/index.vue b/frontend/src/components/ColumnDataTable/index.vueindex 97626c8d9c..8161e3448d 100644--- a/frontend/src/components/ColumnDataTable/index.vue+++ b/frontend/src/components/ColumnDataTable/index.vue@@ -16,7 +16,7 @@ import type { PropType } from "vue";import { computed } from "vue";import { h } from "vue";import { useI18n } from "vue-i18n";-import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorV1/utils/columnDefaultValue";+import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite";import {useCurrentUserV1,useSubscriptionV1Store,@@ -41,6 +41,10 @@ import {supportSetClassificationFromComment,} from "./utils";+defineOptions({+ name: "ColumnDataTable",+});+const props = defineProps({database: {required: true,diff --git a/frontend/src/components/SchemaEditorLite/index.ts b/frontend/src/components/SchemaEditorLite/index.tsindex 7372ebd2d8..c7a9f6e412 100644--- a/frontend/src/components/SchemaEditorLite/index.ts+++ b/frontend/src/components/SchemaEditorLite/index.ts@@ -1,6 +1,18 @@+import ActionConfirmModal from "./Modals/ActionConfirmModal.vue";+import ColumnDefaultValueExpressionModal from "./Modals/ColumnDefaultValueExpressionModal.vue";+import TableColumnEditor from "./Panels/TableColumnEditor";import SchemaEditorLite from "./SchemaEditorLite.vue";export * from "./types";export * from "./common";export * from "./spec";+export * from "./utils";+export * from "./context";+export * from "./edit";+export {+ ActionConfirmModal,+ ColumnDefaultValueExpressionModal,+ TableColumnEditor,+};+export default SchemaEditorLite;diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue b/frontend/src/components/SchemaTemplate/FieldTemplateForm.vueindex 79ae3173ee..e1329823f4 100644--- a/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue+++ b/frontend/src/components/SchemaTemplate/FieldTemplateForm.vue@@ -249,7 +249,9 @@ import {getDefaultValueByKey,getColumnDefaultValueOptions,isTextOfColumnType,-} from "@/components/SchemaEditorV1/utils/columnDefaultValue";+} from "@/components/SchemaEditorLite";+import { ColumnDefaultValueExpressionModal } from "@/components/SchemaEditorLite";+import SemanticTypesDrawer from "@/components/SensitiveData/components/SemanticTypesDrawer.vue";import {DrawerContent,DropdownInput,@@ -270,8 +272,6 @@ import {convertKVListToLabels,convertLabelsToKVList,} from "@/utils";-import ColumnDefaultValueExpressionModal from "../SchemaEditorV1/Modals/ColumnDefaultValueExpressionModal.vue";-import SemanticTypesDrawer from "../SensitiveData/components/SemanticTypesDrawer.vue";import { engineList, categoryList, classificationConfig } from "./utils";const props = defineProps<{diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vueindex 3dffef3ec8..634b283019 100644--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue@@ -63,7 +63,7 @@ import { computed } from "vue";import { useI18n } from "vue-i18n";import type { BBGridColumn } from "@/bbkit";import { BBGrid } from "@/bbkit";-import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorV1/utils/columnDefaultValue";+import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite";import { MiniActionButton } from "@/components/v2";import { DatabaseLabelsCell } from "@/components/v2/Model/DatabaseV1Table/cells";import { useSettingV1Store } from "@/store";diff --git a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue b/frontend/src/components/SchemaTemplate/TableTemplateForm.vueindex a837354b4e..342fd9a690 100644--- a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue+++ b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue@@ -12,7 +12,7 @@</p><div class="relative flex flex-row justify-between items-center mt-1"><DropdownInput- v-model:value="state.category"+ v-model:value="editing.category":options="categoryOptions":placeholder="$t('schema-template.form.unclassified')":disabled="readonly"@@ -27,7 +27,7 @@{{ $t("database.engine") }}</label><InstanceEngineRadioGrid- v-model:engine="state.engine"+ v-model:engine="editing.engine":engine-list="engineList":disabled="readonly"class="grid-cols-4 gap-2"@@ -40,13 +40,13 @@</label><div class="flex items-center gap-x-2 mt-1"><ClassificationLevelBadge- :classification="state.table?.config.classificationId"+ :classification="tableClassificationId":classification-config="classificationConfig"/><div v-if="!readonly" class="flex"><MiniActionButton- v-if="state.table?.config.classificationId"- @click.prevent="state.table!.config.classificationId = ''"+ v-if="tableClassificationId"+ @click.prevent="tableClassificationId = ''"><XIcon class="w-4 h-4" /></MiniActionButton>@@ -68,9 +68,10 @@<span class="text-red-600 mr-2">*</span></label><NInput- v-model:value="state.table!.name"- placeholder="table name"+ :value="editing.table.name":disabled="readonly"+ placeholder="table name"+ @update:value="handleUpdateTableName"/></div>@@ -80,7 +81,7 @@{{ $t("schema-template.form.comment") }}</label><NInput- v-model:value="state.table!.userComment"+ v-model:value="editing.table.userComment"type="textarea":autosize="{ minRows: 3, maxRows: 3 }":disabled="readonly"@@ -113,13 +114,16 @@<TableColumnEditor:readonly="!!readonly":show-foreign-key="false"- :table="state.table"- :engine="state.engine"+ :db="editing.db"+ :database="editing.database"+ :schema="editing.schema"+ :table="editing.table"+ :engine="editing.engine":classification-config-id="classificationConfig?.id":allow-change-primary-keys="true":allow-reorder-columns="allowReorderColumns":max-body-height="640"- @drop="onColumnDrop"+ @drop="handleDropColumn"@reorder="handleReorderColumn"@primary-key-set="setColumnPrimaryKey"/>@@ -154,7 +158,7 @@<DrawerContent :title="$t('schema-template.field-template.self')"><div class="w-[calc(100vw-36rem)] min-w-[64rem] max-w-[calc(100vw-8rem)]"><FieldTemplates- :engine="state.engine"+ :engine="editing.engine":readonly="false"@apply="handleApplyColumnTemplate"/>@@ -167,39 +171,59 @@:show="state.showClassificationDrawer":classification-config="classificationConfig"@dismiss="state.showClassificationDrawer = false"- @apply="onClassificationSelect"+ @apply="(id) => (tableClassificationId = id)"/></template><script lang="ts" setup>-import { isEqual, cloneDeep } from "lodash-es";+import { isEqual, cloneDeep, pull } from "lodash-es";import { PlusIcon, XIcon, PencilIcon } from "lucide-vue-next";import type { SelectOption } from "naive-ui";import { NButton, NInput } from "naive-ui";-import { computed, nextTick, reactive } from "vue";+import { computed, reactive, ref, toRef } from "vue";import { useI18n } from "vue-i18n";import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";-import TableColumnEditor from "@/components/SchemaEditorV1/Panels/TableColumnEditor";-import { transformTableEditToMetadata } from "@/components/SchemaEditorV1/utils";+import {+ TableColumnEditor,+ provideSchemaEditorContext,+ upsertColumnPrimaryKey,+ removeColumnPrimaryKey,+ removeColumnFromAllForeignKeys,+ type EditTarget,+ type EditStatus,+} from "@/components/SchemaEditorLite";import {Drawer,DrawerContent,InstanceEngineRadioGrid,} from "@/components/v2";-import { useSettingV1Store, useNotificationStore } from "@/store";-import type { Engine } from "@/types/proto/v1/common";-import { ColumnMetadata, TableConfig } from "@/types/proto/v1/database_service";-import type {- SchemaTemplateSetting_FieldTemplate,+import {+ useSettingV1Store,+ useNotificationStore,+ pushNotification,+} from "@/store";+import { unknownProject } from "@/types";+import {+ ColumnMetadata,+ SchemaConfig,+ TableConfig,+} from "@/types/proto/v1/database_service";+import {SchemaTemplateSetting_TableTemplate,+ type SchemaTemplateSetting_FieldTemplate,} from "@/types/proto/v1/setting_service";import { SchemaTemplateSetting } from "@/types/proto/v1/setting_service";-import { convertTableMetadataToTable } from "@/types/v1/schemaEditor";-import type { Column, Table } from "@/types/v1/schemaEditor";-import { convertColumnMetadataToColumn } from "@/types/v1/schemaEditor";import { arraySwap, instanceV1AllowsReorderColumns } from "@/utils";import FieldTemplates from "@/views/SchemaTemplate/FieldTemplates.vue";-import { engineList, categoryList, classificationConfig } from "./utils";+import ClassificationLevelBadge from "./ClassificationLevelBadge.vue";+import SelectClassificationDrawer from "./SelectClassificationDrawer.vue";+import {+ engineList,+ categoryList,+ classificationConfig,+ mockMetadataFromTableTemplate,+ rebuildTableTemplateFromMetadata,+} from "./utils";const props = defineProps<{create: boolean;@@ -210,29 +234,99 @@ const props = defineProps<{const emit = defineEmits(["dismiss"]);interface LocalState {- id: string;- engine: Engine;- category: string;- table: Table;showClassificationDrawer: boolean;showFieldTemplateDrawer: boolean;}+const editing = computed(() => {+ return mockMetadataFromTableTemplate(props.template);+});++const targets = computed(() => {+ const target: EditTarget = {+ database: editing.value.db,+ metadata: editing.value.database,+ baselineMetadata: editing.value.database,+ };+ return [target];+});++const context = provideSchemaEditorContext({+ targets,+ project: ref(unknownProject()),+ resourceType: ref("branch"),+ readonly: toRef(props, "readonly"),+ selectedRolloutObjects: ref(undefined),+ showLastUpdater: ref(false),+ disableDiffColoring: ref(true),+});+const state = reactive<LocalState>({- id: props.template.id,- engine: props.template.engine,- category: props.template.category,- table: convertTableMetadataToTable(- Object.assign({}, props.template.table),- "normal",- props.template.config- ),showClassificationDrawer: false,showFieldTemplateDrawer: false,});const { t } = useI18n();const settingStore = useSettingV1Store();+const tableConfig = computed(() => {+ const { database, schema, table } = editing.value;+ const schemaConfig = database.schemaConfigs.find(+ (sc) => sc.name === schema.name+ );+ if (!schemaConfig) return undefined;+ return schemaConfig.tableConfigs.find((tc) => tc.name === table.name);+});++const tableClassificationId = computed({+ get() {+ return tableConfig.value?.classificationId;+ },+ set(id) {+ const { database, schema, table } = editing.value;+ let schemaConfig = database.schemaConfigs.find(+ (sc) => sc.name === schema.name+ );+ if (!schemaConfig) {+ schemaConfig = SchemaConfig.fromPartial({+ name: schema.name,+ tableConfigs: [],+ });+ }+ if (!schemaConfig.tableConfigs) {+ schemaConfig.tableConfigs = [];+ }+ let tableConfig = schemaConfig.tableConfigs.find(+ (tc) => tc.name === table.name+ );+ if (!tableConfig) {+ tableConfig = TableConfig.fromPartial({+ name: table.name,+ classificationId: id,+ });+ schemaConfig.tableConfigs.push(tableConfig);+ }+ tableConfig.classificationId = id ?? "";+ },+});++const metadataForColumn = (column: ColumnMetadata) => {+ const { database, schema, table } = editing.value;+ return {+ database,+ schema,+ table,+ column,+ };+};++const statusForColumn = (column: ColumnMetadata) => {+ return context.getColumnStatus(editing.value.db, metadataForColumn(column));+};++const markColumnStatus = (column: ColumnMetadata, status: EditStatus) => {+ context.markEditStatus(editing.value.db, metadataForColumn(column), status);+};+const categoryOptions = computed(() => {return categoryList.value.map<SelectOption>((category) => ({label: category,@@ -241,26 +335,22 @@ const categoryOptions = computed(() => {});const allowReorderColumns = computed(() => {- return instanceV1AllowsReorderColumns(state.engine);+ return instanceV1AllowsReorderColumns(editing.value.engine);});const submitDisabled = computed(() => {- if (!state.table.name || state.table.columnList.length === 0) {+ const { table, category } = editing.value;+ if (!table.name || table.columns.length === 0) {return true;}- if (state.table.columnList.some((col) => !col.name || !col.type)) {+ if (table.columns.some((col) => !col.name || !col.type)) {return true;}if (!props.create &&- isEqual(- convertTableMetadataToTable(- props.template.table!,- "normal",- props.template.config- ),- state.table- )+ isEqual(props.template.table, table) &&+ isEqual(props.template.config, tableConfig.value) &&+ props.template.category === category) {return true;}@@ -268,20 +358,7 @@ const submitDisabled = computed(() => {});const onSubmit = async () => {- const template: SchemaTemplateSetting_TableTemplate = {- id: state.id,- engine: state.engine,- category: state.category,- table: transformTableEditToMetadata(state.table),- config: TableConfig.fromPartial({- ...state.table.config,- name: state.table.name,- columnConfigs: state.table.columnList.map((col) => ({- ...col.config,- name: col.name,- })),- }),- };+ const template = rebuildTableTemplateFromMetadata(editing.value);const setting = await settingStore.fetchSettingByName("bb.workspace.schema-template");@@ -320,69 +397,100 @@ const onSubmit = async () => {};const onColumnAdd = () => {- const column = convertColumnMetadataToColumn(- ColumnMetadata.fromPartial({}),- "created"- );- state.table.columnList.push(column);- nextTick(() => {- const container = document.querySelector("#table-editor-container");- (- container?.querySelector(- `.column-${column.id} .column-name-input`- ) as HTMLInputElement- )?.focus();+ const { db, database, schema, table } = editing.value;+ const column = ColumnMetadata.fromPartial({});+ table.columns.push(column);+ markColumnStatus(column, "created");++ context.queuePendingScrollToColumn({+ db,+ metadata: {+ database,+ schema,+ table,+ column,+ },});};-const onColumnDrop = (column: Column) => {- state.table.columnList = state.table.columnList.filter(- (item) => item.id !== column.id- );- state.table.primaryKey.columnIdList =- state.table.primaryKey.columnIdList.filter(- (columnId) => columnId !== column.id- );+const handleDropColumn = (column: ColumnMetadata) => {+ const { table } = editing.value;+ // Disallow to drop the last column.+ const nonDroppedColumns = table.columns.filter((column) => {+ return statusForColumn(column) !== "dropped";+ });+ if (nonDroppedColumns.length === 1) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("schema-editor.message.cannot-drop-the-last-column"),+ });+ return;+ }+ const status = statusForColumn(column);+ if (status === "created") {+ pull(table.columns, column);+ table.columns = table.columns.filter((col) => col !== column);++ removeColumnPrimaryKey(table, column.name);+ removeColumnFromAllForeignKeys(table, column.name);+ } else {+ markColumnStatus(column, "dropped");+ }};-const setColumnPrimaryKey = (column: Column, isPrimaryKey: boolean) => {+const setColumnPrimaryKey = (column: ColumnMetadata, isPrimaryKey: boolean) => {if (isPrimaryKey) {column.nullable = false;- state.table.primaryKey.columnIdList.push(column.id);+ upsertColumnPrimaryKey(editing.value.table, column.name);} else {- state.table.primaryKey.columnIdList =- state.table.primaryKey.columnIdList.filter(- (columnId) => columnId !== column.id- );+ removeColumnPrimaryKey(editing.value.table, column.name);}+ markColumnStatus(column, "updated");};const handleApplyColumnTemplate = (template: SchemaTemplateSetting_FieldTemplate) => {state.showFieldTemplateDrawer = false;-- if (template.engine !== state.engine || !template.column) {+ if (!template.column) {return;}- const column = convertColumnMetadataToColumn(- template.column,- "created",- template.config- );- state.table.columnList.push(column);-};--const onClassificationSelect = (id: string) => {- state.table.config.classificationId = id;+ const { db, table, engine } = editing.value;+ if (template.engine !== engine) {+ return;+ }+ const column = cloneDeep(template.column);+ table.columns.push(column);+ if (template.config) {+ context.upsertColumnConfig(db, metadataForColumn(column), (config) => {+ Object.assign(config, template.config);+ });+ }+ markColumnStatus(column, "created");+ context.queuePendingScrollToColumn({+ db: db,+ metadata: metadataForColumn(column),+ });};-const handleReorderColumn = (column: Column, index: number, delta: -1 | 1) => {+const handleReorderColumn = (+ column: ColumnMetadata,+ index: number,+ delta: -1 | 1+) => {const target = index + delta;- const { columnList } = state.table;+ const { columns } = editing.value.table;if (target < 0) return;- if (target >= columnList.length) return;+ if (target >= columns.length) return;+ arraySwap(columns, index, target);+};- arraySwap(columnList, index, target);+const handleUpdateTableName = (name: string) => {+ editing.value.table.name = name;+ const tc = tableConfig.value;+ if (tc) {+ tc.name = name;+ }};</script>diff --git a/frontend/src/components/SchemaTemplate/utils.ts b/frontend/src/components/SchemaTemplate/utils.tsindex 11c3897a0a..0ab439e1e0 100644--- a/frontend/src/components/SchemaTemplate/utils.ts+++ b/frontend/src/components/SchemaTemplate/utils.ts@@ -1,6 +1,16 @@-import { computed } from "vue";+import { cloneDeep } from "lodash-es";+import { computed, reactive } from "vue";import { useSettingV1Store } from "@/store";+import { unknownDatabase, type ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";+import {+ DatabaseMetadata,+ SchemaConfig,+ SchemaMetadata,+ TableConfig,+ TableMetadata,+} from "@/types/proto/v1/database_service";+import { SchemaTemplateSetting_TableTemplate } from "@/types/proto/v1/setting_service";export const engineList = [Engine.MYSQL, Engine.POSTGRES];@@ -30,3 +40,58 @@ export const classificationConfig = computed(() => {// TODO(ed): it's a temporary solutionreturn settingStore.classification[0];});++export const mockMetadataFromTableTemplate = (+ template: SchemaTemplateSetting_TableTemplate+) => {+ const db = {+ ...unknownDatabase(),+ };+ const table = cloneDeep(template.table) ?? TableMetadata.fromPartial({});+ const schema = SchemaMetadata.fromPartial({+ name: "",+ tables: [table],+ });+ const tableConfig =+ cloneDeep(template.config) ?? TableConfig.fromPartial({ name: "" });+ const database = DatabaseMetadata.fromPartial({+ schemas: [schema],+ schemaConfigs: [+ SchemaConfig.fromPartial({+ name: "",+ tableConfigs: [tableConfig],+ }),+ ],+ });+ return reactive({+ db,+ database,+ schema,+ table,+ id: template.id,+ category: template.category,+ engine: template.engine,+ });+};++export const rebuildTableTemplateFromMetadata = (params: {+ db: ComposedDatabase;+ database: DatabaseMetadata;+ schema: SchemaMetadata;+ table: TableMetadata;+ id: string;+ category: string;+ engine: Engine;+}) => {+ const { database, schema, table, id, category, engine } = params;+ const tableConfig = database.schemaConfigs+ .find((sc) => sc.name === schema.name)+ ?.tableConfigs.find((tc) => tc.name === table.name);+ return SchemaTemplateSetting_TableTemplate.fromPartial({+ table,+ config: tableConfig,+ id,+ category,+ engine,+ });+};diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vueindex a084230277..b9fca39973 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue@@ -116,7 +116,7 @@ import {import {isArchivedDatabaseV1,instanceV1HasAlterSchema,- allowUsingSchemaEditorV1,+ allowUsingSchemaEditor,generateIssueName,hasProjectPermissionV2,extractProjectResourceName,@@ -293,7 +293,7 @@ const generateMultiDb = async () => {if (type === "bb.issue.database.schema.update" &&- allowUsingSchemaEditorV1(props.databases) &&+ allowUsingSchemaEditor(props.databases) &&!isStandaloneMode.value) {schemaEditorContext.value.databaseIdList = [diff --git a/frontend/src/utils/schemaEditor/index.ts b/frontend/src/utils/schemaEditor/index.tsindex f80c88d984..d8d6e70946 100644--- a/frontend/src/utils/schemaEditor/index.ts+++ b/frontend/src/utils/schemaEditor/index.ts@@ -1,15 +1,8 @@-import type { ComposedDatabase, Database } from "@/types";+import type { ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";export * from "./filter";-// Only allow using Schema Editor with MySQL.-export const allowUsingSchemaEditor = (databaseList: Database[]): boolean => {- return databaseList.every((db) => {- return db.instance.engine === "MYSQL" || db.instance.engine === "POSTGRES";- });-};-export const engineSupportsSchemaEditor = (engine: Engine) => {if ([Engine.MYSQL, Engine.TIDB].includes(engine)) {return true;@@ -20,7 +13,7 @@ export const engineSupportsSchemaEditor = (engine: Engine) => {return false;};-export const allowUsingSchemaEditorV1 = (+export const allowUsingSchemaEditor = (databaseList: ComposedDatabase[]): boolean => {return databaseList.every((db) => {diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 4c606e05e8..769eb607d2 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -236,7 +236,7 @@ import { State } from "@/types/proto/v1/common";import {instanceV1HasAlterSchema,isDatabaseV1Queryable,- allowUsingSchemaEditorV1,+ allowUsingSchemaEditor,extractProjectResourceName,} from "@/utils";@@ -353,7 +353,7 @@ const createMigration = async (if (type === "bb.issue.database.schema.update") {if (database.value.syncState === State.ACTIVE &&- allowUsingSchemaEditorV1([database.value])+ allowUsingSchemaEditor([database.value])) {state.showSchemaEditorModal = true;return;diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ColumnInfo.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ColumnInfo.vueindex a46d2db465..ae0834abcb 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ColumnInfo.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/ColumnInfo.vue@@ -26,7 +26,7 @@<script setup lang="ts">import { computed } from "vue";-import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorV1/utils/columnDefaultValue";+import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite";import type { ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";import type {diff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vueindex cd763871de..04d64e3146 100644--- a/frontend/src/views/sql-editor/SQLEditorPage.vue+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue@@ -120,7 +120,7 @@ import {useSQLEditorTabStore,} from "@/store";import {- allowUsingSchemaEditorV1,+ allowUsingSchemaEditor,extractProjectResourceName,instanceV1HasReadonlyMode,} from "@/utils";@@ -180,7 +180,7 @@ useEmitteryEventListener("alter-schema",({ databaseUID, schema, table }) => {const database = databaseStore.getDatabaseByUID(databaseUID);- if (allowUsingSchemaEditorV1([database])) {+ if (allowUsingSchemaEditor([database])) {// TODO: support open selected database tab directly in Schema Editor.alterSchemaState.databaseIdList = [databaseUID];alterSchemaState.showModal = true;