mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 10:36:00 +00:00
drop all objects
This commit is contained in:
@@ -281,6 +281,36 @@
|
|||||||
saveScriptToDatabase({ conid: connection._id, database: name }, sql, false);
|
saveScriptToDatabase({ conid: connection._id, database: name }, sql, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleGenerateDropAllObjectsScript = () => {
|
||||||
|
showModal(ConfirmModal, {
|
||||||
|
message: `This will generate script, after executing this script all objects in ${name} will be dropped. Continue?`,
|
||||||
|
|
||||||
|
onConfirm: () => {
|
||||||
|
openNewTab(
|
||||||
|
{
|
||||||
|
title: 'Shell #',
|
||||||
|
icon: 'img shell',
|
||||||
|
tabComponent: 'ShellTab',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
editor: `// @require ${extractPackageName(connection.engine)}
|
||||||
|
|
||||||
|
await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||||
|
{
|
||||||
|
connection: {
|
||||||
|
..._.omit(connection, '_id', 'displayName'),
|
||||||
|
database: name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
2
|
||||||
|
)})`,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const driver = findEngineDriver(connection, getExtensions());
|
const driver = findEngineDriver(connection, getExtensions());
|
||||||
|
|
||||||
const commands = _.flatten((apps || []).map(x => x.commands || []));
|
const commands = _.flatten((apps || []).map(x => x.commands || []));
|
||||||
@@ -352,8 +382,15 @@
|
|||||||
(_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
|
(_.get($currentDatabase, 'connection._id') == _.get(connection, '_id') &&
|
||||||
_.get($currentDatabase, 'name') == name)) && { onClick: handleDisconnect, text: 'Disconnect' },
|
_.get($currentDatabase, 'name') == name)) && { onClick: handleDisconnect, text: 'Disconnect' },
|
||||||
|
|
||||||
|
{ divider: true },
|
||||||
|
|
||||||
|
driver?.databaseEngineTypes?.includes('sql') &&
|
||||||
|
hasPermission(`dbops/dropdb`) && {
|
||||||
|
onClick: handleGenerateDropAllObjectsScript,
|
||||||
|
text: 'Shell: Drop all objects',
|
||||||
|
},
|
||||||
|
|
||||||
commands.length > 0 && [
|
commands.length > 0 && [
|
||||||
{ divider: true },
|
|
||||||
commands.map((cmd: any) => ({
|
commands.map((cmd: any) => ({
|
||||||
text: cmd.name,
|
text: cmd.name,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
@@ -394,7 +431,7 @@
|
|||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import AppObjectCore from './AppObjectCore.svelte';
|
import AppObjectCore from './AppObjectCore.svelte';
|
||||||
import { showSnackbarError, showSnackbarSuccess } from '../utility/snackbar';
|
import { showSnackbarError, showSnackbarSuccess } from '../utility/snackbar';
|
||||||
import { extractDbNameFromComposite, findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
import { extractDbNameFromComposite, extractPackageName, findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { getDatabaseInfo, useUsedApps } from '../utility/metadataLoaders';
|
import { getDatabaseInfo, useUsedApps } from '../utility/metadataLoaders';
|
||||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||||
|
|||||||
Reference in New Issue
Block a user