Skip to content

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

chore: update type definition for Schema Editor (#3842)

boojack58cbaed8224f
diff --git a/frontend/src/components/SchemaEditor/DatabaseTree.vue b/frontend/src/components/SchemaEditor/DatabaseTree.vue
index 2275b65c74..e01309ab4f 100644
--- a/frontend/src/components/SchemaEditor/DatabaseTree.vue
+++ b/frontend/src/components/SchemaEditor/DatabaseTree.vue
@@ -53,7 +53,7 @@ import { computed, onMounted, watch, ref, h, reactive, nextTick } from "vue";
import { useI18n } from "vue-i18n";
import scrollIntoView from "scroll-into-view-if-needed";
import { DatabaseId, InstanceId, SchemaEditorTabType } from "@/types";
-import { Table } from "@/types/schemaEditor";
+import { Table } from "@/types/schemaEditor/atomType";
import {
useSchemaEditorStore,
generateUniqueTabId,
diff --git a/frontend/src/components/SchemaEditor/Panels/DatabaseEditor.vue b/frontend/src/components/SchemaEditor/Panels/DatabaseEditor.vue
index 2d1e48d13f..94a940f097 100644
--- a/frontend/src/components/SchemaEditor/Panels/DatabaseEditor.vue
+++ b/frontend/src/components/SchemaEditor/Panels/DatabaseEditor.vue
@@ -163,7 +163,7 @@ import {
useSchemaEditorStore,
} from "@/store";
import { DatabaseId, DatabaseTabContext, SchemaEditorTabType } from "@/types";
-import { Table } from "@/types/schemaEditor";
+import { Table } from "@/types/schemaEditor/atomType";
import { bytesToString } from "@/utils";
import HighlightCodeBlock from "@/components/HighlightCodeBlock";
import TableNameModal from "../Modals/TableNameModal.vue";
diff --git a/frontend/src/components/SchemaEditor/Panels/TableEditor.vue b/frontend/src/components/SchemaEditor/Panels/TableEditor.vue
index 6bd6ab8363..9b923fe2d6 100644
--- a/frontend/src/components/SchemaEditor/Panels/TableEditor.vue
+++ b/frontend/src/components/SchemaEditor/Panels/TableEditor.vue
@@ -219,11 +219,12 @@ import {
} from "@/store/modules";
import { TableTabContext, unknown } from "@/types";
import { BBCheckbox, BBSpin } from "@/bbkit";
+import { DatabaseEdit } from "@/types/schemaEditor";
+import { Column, Table } from "@/types/schemaEditor/atomType";
import { getDataTypeSuggestionList } from "@/utils";
import { diffTableList } from "@/utils/schemaEditor/diffTable";
import { transformColumnDataToColumn } from "@/utils/schemaEditor/transform";
import HighlightCodeBlock from "@/components/HighlightCodeBlock";
-import { Column, DatabaseEdit, Table } from "@/types/schemaEditor";
type TabType = "column-list" | "raw-sql";
diff --git a/frontend/src/store/modules/schemaEditor.ts b/frontend/src/store/modules/schemaEditor.ts
index d0fd032e5c..50b873b0f9 100644
--- a/frontend/src/store/modules/schemaEditor.ts
+++ b/frontend/src/store/modules/schemaEditor.ts
@@ -11,7 +11,8 @@ import {
DatabaseEdit,
ResourceObject,
} from "@/types";
-import { DatabaseEditResult, Table } from "@/types/schemaEditor";
+import { DatabaseEditResult } from "@/types/schemaEditor";
+import { Table } from "@/types/schemaEditor/atomType";
import { useDatabaseStore, useTableStore } from ".";
import { transformTableDataToTable } from "@/utils/schemaEditor/transform";
diff --git a/frontend/src/types/schemaEditor/atomType.ts b/frontend/src/types/schemaEditor/atomType.ts
new file mode 100644
index 0000000000..f179b73c08
--- /dev/null
+++ b/frontend/src/types/schemaEditor/atomType.ts
@@ -0,0 +1,38 @@
+import { DatabaseId } from "../id";
+import { TableEngineType, TableType } from "../table";
+
+type TableOrColumnStatus = "normal" | "created" | "dropped";
+
+export interface Column {
+ // Related fields
+ databaseId: DatabaseId;
+
+ // Domain specific fields
+ oldName: string;
+ newName: string;
+ type: string;
+ nullable: boolean;
+ comment: string;
+ default: string | null;
+
+ status: TableOrColumnStatus;
+}
+
+export interface Table {
+ // Related fields
+ databaseId: DatabaseId;
+
+ // Domain specific fields
+ oldName: string;
+ newName: string;
+ type: TableType;
+ engine: TableEngineType;
+ collation: string;
+ rowCount: number;
+ dataSize: number;
+ comment: string;
+ columnList: Column[];
+ originColumnList: Column[];
+
+ status: TableOrColumnStatus;
+}
diff --git a/frontend/src/types/schemaEditor.ts b/frontend/src/types/schemaEditor/index.ts
similarity index 74%
rename from frontend/src/types/schemaEditor.ts
rename to frontend/src/types/schemaEditor/index.ts
index b479d2b627..572afeff19 100644
--- a/frontend/src/types/schemaEditor.ts
+++ b/frontend/src/types/schemaEditor/index.ts
@@ -1,40 +1,5 @@
-import { Database, DatabaseId, TableEngineType, TableType } from ".";
-
-type TableOrColumnStatus = "normal" | "created" | "dropped";
-
-export interface Column {
- // Related fields
- databaseId: DatabaseId;
-
- // Domain specific fields
- oldName: string;
- newName: string;
- type: string;
- nullable: boolean;
- comment: string;
- default: string | null;
-
- status: TableOrColumnStatus;
-}
-
-export interface Table {
- // Related fields
- databaseId: DatabaseId;
-
- // Domain specific fields
- oldName: string;
- newName: string;
- type: TableType;
- engine: TableEngineType;
- collation: string;
- rowCount: number;
- dataSize: number;
- comment: string;
- columnList: Column[];
- originColumnList: Column[];
-
- status: TableOrColumnStatus;
-}
+import { Database, DatabaseId } from "..";
+import { Table } from "./atomType";
export enum SchemaEditorTabType {
TabForDatabase = "database",
diff --git a/frontend/src/utils/schemaEditor/diffColumn.test.ts b/frontend/src/utils/schemaEditor/diffColumn.test.ts
index 6f8e54295c..4e986a83c9 100644
--- a/frontend/src/utils/schemaEditor/diffColumn.test.ts
+++ b/frontend/src/utils/schemaEditor/diffColumn.test.ts
@@ -4,7 +4,7 @@ import {
DropColumnContext,
ChangeColumnContext,
} from "@/types";
-import { Column } from "@/types/schemaEditor";
+import { Column } from "@/types/schemaEditor/atomType";
import { diffColumnList } from "./diffColumn";
it("diff add column list", () => {
diff --git a/frontend/src/utils/schemaEditor/diffColumn.ts b/frontend/src/utils/schemaEditor/diffColumn.ts
index a9d26a9847..4db83143bb 100644
--- a/frontend/src/utils/schemaEditor/diffColumn.ts
+++ b/frontend/src/utils/schemaEditor/diffColumn.ts
@@ -4,7 +4,7 @@ import type {
DropColumnContext,
ChangeColumnContext,
} from "@/types";
-import { Column } from "@/types/schemaEditor";
+import { Column } from "@/types/schemaEditor/atomType";
import {
transformColumnToAddColumnContext,
transformColumnToChangeColumnContext,
diff --git a/frontend/src/utils/schemaEditor/diffTable.test.ts b/frontend/src/utils/schemaEditor/diffTable.test.ts
index 5633b99fda..8c13fdb0a6 100644
--- a/frontend/src/utils/schemaEditor/diffTable.test.ts
+++ b/frontend/src/utils/schemaEditor/diffTable.test.ts
@@ -5,7 +5,7 @@ import {
AlterTableContext,
RenameTableContext,
} from "@/types";
-import { Table } from "@/types/schemaEditor";
+import { Table } from "@/types/schemaEditor/atomType";
import { UNKNOWN_ID } from "@/types/const";
import { diffTableList } from "./diffTable";
diff --git a/frontend/src/utils/schemaEditor/diffTable.ts b/frontend/src/utils/schemaEditor/diffTable.ts
index 928220dd91..b807998a6c 100644
--- a/frontend/src/utils/schemaEditor/diffTable.ts
+++ b/frontend/src/utils/schemaEditor/diffTable.ts
@@ -5,7 +5,7 @@ import type {
DropTableContext,
RenameTableContext,
} from "@/types";
-import { Table } from "@/types/schemaEditor";
+import { Table } from "@/types/schemaEditor/atomType";
import { transformTableToCreateTableContext } from "./transform";
import { diffColumnList } from "./diffColumn";
diff --git a/frontend/src/utils/schemaEditor/transform.ts b/frontend/src/utils/schemaEditor/transform.ts
index ae43c10a89..de077698b1 100644
--- a/frontend/src/utils/schemaEditor/transform.ts
+++ b/frontend/src/utils/schemaEditor/transform.ts
@@ -6,7 +6,7 @@ import {
Column as ColumnData,
Table as TableData,
} from "@/types";
-import { Column, Table } from "@/types/schemaEditor";
+import { Column, Table } from "@/types/schemaEditor/atomType";
export const transformTableDataToTable = (tableData: TableData): Table => {
const columnList = tableData.columnList.map((columnData) =>