diff --git a/packages/tools/package.json b/packages/tools/package.json index 3293f483..e374f03f 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -31,6 +31,7 @@ "typescript": "^3.7.5" }, "dependencies": { - "lodash": "^4.17.21" + "lodash": "^4.17.21", + "uuid": "^8.3.2" } -} \ No newline at end of file +} diff --git a/packages/tools/src/diffTools.ts b/packages/tools/src/diffTools.ts new file mode 100644 index 00000000..f3295203 --- /dev/null +++ b/packages/tools/src/diffTools.ts @@ -0,0 +1,17 @@ +import { TableInfo } from 'dbgate-types'; +import uuidv1 from 'uuid/v1'; + +export function generateTableGroupId(table: TableInfo): TableInfo { + if (!table) return table; + if (!table.groupId) { + return { + ...table, + columns: table.columns.map(col => ({ + ...col, + groupid: uuidv1(), + })), + groupId: uuidv1(), + }; + } + return table; +} diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index 0418719e..515df9fc 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -11,3 +11,4 @@ export * from './SqlGenerator'; export * from './structureTools'; export * from './settingsExtractors'; export * from './filterName'; +export * from './diffTools'; diff --git a/packages/types/dbinfo.d.ts b/packages/types/dbinfo.d.ts index faa33f8a..1640cd99 100644 --- a/packages/types/dbinfo.d.ts +++ b/packages/types/dbinfo.d.ts @@ -9,6 +9,7 @@ export interface ColumnReference { } export interface ConstraintInfo extends NamedObjectInfo { + groupId?: string; constraintName: string; constraintType: 'primaryKey' | 'foreignKey' | 'index' | 'check' | 'unique'; } @@ -38,6 +39,7 @@ export interface CheckInfo extends ConstraintInfo { } export interface ColumnInfo extends NamedObjectInfo { + groupId?: string; columnName: string; notNull: boolean; autoIncrement: boolean; @@ -53,6 +55,7 @@ export interface ColumnInfo extends NamedObjectInfo { } export interface DatabaseObjectInfo extends NamedObjectInfo { + groupId?: string; objectId?: string; createDate?: string; modifyDate?: string; diff --git a/packages/web/src/elements/ObjectListControl.svelte b/packages/web/src/elements/ObjectListControl.svelte index 4dcaad58..41366ea2 100644 --- a/packages/web/src/elements/ObjectListControl.svelte +++ b/packages/web/src/elements/ObjectListControl.svelte @@ -2,7 +2,6 @@ import TableControl from './TableControl.svelte'; export let title; - export let nameComponent; export let collection; export let columns; export let showIfEmpty = false; diff --git a/packages/web/src/tableeditor/TableEditor.svelte b/packages/web/src/tableeditor/TableEditor.svelte new file mode 100644 index 00000000..45f27cfb --- /dev/null +++ b/packages/web/src/tableeditor/TableEditor.svelte @@ -0,0 +1,100 @@ + + +