restore table - comments

This commit is contained in:
SPRINX0\prochazka
2025-12-01 12:17:00 +01:00
parent b912190c5e
commit 6bd81cbff5
2 changed files with 19 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ export interface SqlDumper extends AlterProcessor {
transform(type: TransformType, dumpExpr: () => void); transform(type: TransformType, dumpExpr: () => void);
createDatabase(name: string); createDatabase(name: string);
dropDatabase(name: string); dropDatabase(name: string);
comment(value: string);
callableTemplate(func: CallableObjectInfo); callableTemplate(func: CallableObjectInfo);

View File

@@ -30,6 +30,21 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
}; };
} }
function putTitle(title: string) {
dmp.putRaw('\n\n');
dmp.comment(`******************** ${title} ********************`);
dmp.putRaw('\n');
}
dmp.comment(`Restoring data into table ${originalTable.pureName} from backup table ${backupTable.pureName}`);
dmp.putRaw('\n');
dmp.comment(`Key columns: ${keyColumns.join(', ')}`);
dmp.putRaw('\n');
dmp.comment(`Value columns: ${valueColumns.join(', ')}`);
dmp.putRaw('\n');
dmp.comment(`Follows UPDATE, DELETE, INSERT statements to restore data`);
dmp.putRaw('\n');
const update: Update = { const update: Update = {
commandType: 'update', commandType: 'update',
from: { name: originalTable }, from: { name: originalTable },
@@ -71,6 +86,7 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
}, },
}, },
}; };
putTitle('UPDATE');
dumpSqlUpdate(dmp, update); dumpSqlUpdate(dmp, update);
dmp.endCommand(); dmp.endCommand();
@@ -90,6 +106,7 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
}, },
}, },
}; };
putTitle('DELETE');
dumpSqlDelete(dmp, delcmd); dumpSqlDelete(dmp, delcmd);
dmp.endCommand(); dmp.endCommand();
@@ -109,6 +126,7 @@ export function createTableRestoreScript(backupTable: TableInfo, originalTable:
}, },
}; };
putTitle('INSERT');
dumpSqlInsert(dmp, insert); dumpSqlInsert(dmp, insert);
dmp.endCommand(); dmp.endCommand();
} }