mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 16:13:58 +00:00
delete part of restore script
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import _, { cond } from 'lodash';
|
import _ from 'lodash';
|
||||||
import { Condition, dumpSqlInsert, dumpSqlUpdate, Insert, Update } from 'dbgate-sqltree';
|
import { Condition, dumpSqlInsert, dumpSqlUpdate, Insert, Update, Delete, dumpSqlDelete } from 'dbgate-sqltree';
|
||||||
import { TableInfo, SqlDumper } from 'dbgate-types';
|
import { TableInfo, SqlDumper } from 'dbgate-types';
|
||||||
|
|
||||||
export function createTableRestoreScript(backupTable: TableInfo, originalTable: TableInfo, dmp: SqlDumper) {
|
export function createTableRestoreScript(backupTable: TableInfo, originalTable: TableInfo, dmp: SqlDumper) {
|
||||||
@@ -74,6 +74,25 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
|
|||||||
dumpSqlUpdate(dmp, update);
|
dumpSqlUpdate(dmp, update);
|
||||||
dmp.endCommand();
|
dmp.endCommand();
|
||||||
|
|
||||||
|
const delcmd: Delete = {
|
||||||
|
commandType: 'delete',
|
||||||
|
from: { name: originalTable },
|
||||||
|
where: {
|
||||||
|
conditionType: 'notExists',
|
||||||
|
subQuery: {
|
||||||
|
commandType: 'select',
|
||||||
|
from: { name: backupTable, alias: 'bak' },
|
||||||
|
selectAll: true,
|
||||||
|
where: {
|
||||||
|
conditionType: 'and',
|
||||||
|
conditions: keyColumns.map(colName => makeColumnCond(colName)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
dumpSqlDelete(dmp, delcmd);
|
||||||
|
dmp.endCommand();
|
||||||
|
|
||||||
const insert: Insert = {
|
const insert: Insert = {
|
||||||
commandType: 'insert',
|
commandType: 'insert',
|
||||||
targetTable: originalTable,
|
targetTable: originalTable,
|
||||||
|
|||||||
Reference in New Issue
Block a user