diff --git a/src/main/ipc-handlers/tables.js b/src/main/ipc-handlers/tables.js index feb6f76f..56705fb0 100644 --- a/src/main/ipc-handlers/tables.js +++ b/src/main/ipc-handlers/tables.js @@ -424,6 +424,16 @@ export default (connections) => { } }); + ipcMain.handle('duplicate-table', async (event, params) => { + try { + await connections[params.uid].duplicateTable(params); + return { status: 'success' }; + } + catch (err) { + return { status: 'error', response: err.toString() }; + } + }); + ipcMain.handle('truncate-table', async (event, params) => { try { await connections[params.uid].truncateTable(params); diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index 6f2e86ba..3ecc7ef7 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -1243,6 +1243,17 @@ export class MySQLClient extends AntaresCore { return await this.raw(sql); } + /** + * DUPLICATE TABLE + * + * @returns {Array.} parameters + * @memberof MySQLClient + */ + async duplicateTable (params) { + const sql = `CREATE TABLE \`${this._schema}\`.\`${params.table}_copy\` LIKE \`${this._schema}\`.\`${params.table}\``; + return await this.raw(sql); + } + /** * TRUNCATE TABLE * diff --git a/src/main/libs/clients/PostgreSQLClient.js b/src/main/libs/clients/PostgreSQLClient.js index acf3d620..a3a05c78 100644 --- a/src/main/libs/clients/PostgreSQLClient.js +++ b/src/main/libs/clients/PostgreSQLClient.js @@ -1126,6 +1126,17 @@ export class PostgreSQLClient extends AntaresCore { return await this.raw(sql); } + /** + * DUPLICATE TABLE + * + * @returns {Array.} parameters + * @memberof PostgreSQLClient + */ + async duplicateTable (params) { + const sql = `CREATE TABLE ${this._schema}.${params.table}_copy (LIKE ${this._schema}.${params.table} INCLUDING ALL)`; + return await this.raw(sql); + } + /** * TRUNCATE TABLE * diff --git a/src/renderer/components/QueryEditor.vue b/src/renderer/components/QueryEditor.vue index bd7c3bf0..1a52ba03 100644 --- a/src/renderer/components/QueryEditor.vue +++ b/src/renderer/components/QueryEditor.vue @@ -187,8 +187,15 @@ export default { } }, isSelected () { - if (this.isSelected) + if (this.isSelected) { this.lastSchema = this.schema; + this.editor.resize(); + } + }, + height () { + setTimeout(() => { + this.editor.resize(); + }, 20); }, lastSchema () { if (this.editor) { diff --git a/src/renderer/components/WorkspaceExploreBarTableContext.vue b/src/renderer/components/WorkspaceExploreBarTableContext.vue index bf82b6b2..a9df53fb 100644 --- a/src/renderer/components/WorkspaceExploreBarTableContext.vue +++ b/src/renderer/components/WorkspaceExploreBarTableContext.vue @@ -3,6 +3,13 @@ :context-event="contextEvent" @close-context="closeContext" > +
+ {{ $t('message.duplicateTable') }} +