mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 16:26:00 +00:00
delete part of restore script
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import _, { cond } from 'lodash';
|
||||
import { Condition, dumpSqlInsert, dumpSqlUpdate, Insert, Update } from 'dbgate-sqltree';
|
||||
import _ from 'lodash';
|
||||
import { Condition, dumpSqlInsert, dumpSqlUpdate, Insert, Update, Delete, dumpSqlDelete } from 'dbgate-sqltree';
|
||||
import { TableInfo, SqlDumper } from 'dbgate-types';
|
||||
|
||||
export function createTableRestoreScript(backupTable: TableInfo, originalTable: TableInfo, dmp: SqlDumper) {
|
||||
@@ -74,6 +74,25 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
|
||||
dumpSqlUpdate(dmp, update);
|
||||
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 = {
|
||||
commandType: 'insert',
|
||||
targetTable: originalTable,
|
||||
|
||||
Reference in New Issue
Block a user