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 @@ + + +
+ ({ ...x, ordinal: index + 1 }))} + title="Columns" + columns={[ + { + fieldName: 'notNull', + header: 'Not NULL', + sortable: true, + slot: 0, + }, + { + fieldName: 'dataType', + header: 'Data Type', + sortable: true, + }, + { + fieldName: 'defaultValue', + header: 'Default value', + sortable: true, + }, + { + fieldName: 'isSparse', + header: 'Is Sparse', + sortable: true, + slot: 1, + }, + { + fieldName: 'computedExpression', + header: 'Computed Expression', + sortable: true, + }, + { + fieldName: 'isPersisted', + header: 'Is Persisted', + sortable: true, + slot: 2, + }, + ]} + > + {row?.notNull ? 'YES' : 'NO'} + {row?.isSparse ? 'YES' : 'NO'} + {row?.isPersisted ? 'YES' : 'NO'} + + + + + + {row?.columns.map(x => x.columnName).join(', ')} + + + + +
+ + diff --git a/packages/web/src/tabs/TableStructureTab.svelte b/packages/web/src/tabs/TableStructureTab.svelte index ccd33604..e15b321f 100644 --- a/packages/web/src/tabs/TableStructureTab.svelte +++ b/packages/web/src/tabs/TableStructureTab.svelte @@ -1,6 +1,7 @@ -
- ({ ...x, ordinal: index + 1 }))} - title="Columns" - columns={[ - { - fieldName: 'notNull', - header: 'Not NULL', - sortable: true, - slot: 0, - }, - { - fieldName: 'dataType', - header: 'Data Type', - sortable: true, - }, - { - fieldName: 'defaultValue', - header: 'Default value', - sortable: true, - }, - { - fieldName: 'isSparse', - header: 'Is Sparse', - sortable: true, - slot: 1, - }, - { - fieldName: 'computedExpression', - header: 'Computed Expression', - sortable: true, - }, - { - fieldName: 'isPersisted', - header: 'Is Persisted', - sortable: true, - slot: 2, - }, - ]} - > - {row?.notNull ? 'YES' : 'NO'} - {row?.isSparse ? 'YES' : 'NO'} - {row?.isPersisted ? 'YES' : 'NO'} - - - - - - {row?.columns.map(x => x.columnName).join(', ')} - - - - -
- - + diff --git a/yarn.lock b/yarn.lock index 27759e55..06163657 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10723,6 +10723,11 @@ uuid@^3.1.0, uuid@^3.3.2, uuid@^3.4.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + v8-compile-cache@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe"