mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
data duplicator runs in transaction
This commit is contained in:
parent
5b6f90abc5
commit
bb2f1399ba
@ -207,11 +207,18 @@ export class DataDuplicator {
|
|||||||
async run() {
|
async run() {
|
||||||
this.createPlan();
|
this.createPlan();
|
||||||
|
|
||||||
for (const item of this.itemPlan) {
|
await runCommandOnDriver(this.pool, this.driver, dmp => dmp.beginTransaction());
|
||||||
const stats = await item.runImport();
|
try {
|
||||||
logger.info(
|
for (const item of this.itemPlan) {
|
||||||
`Duplicated ${item.name}, inserted ${stats.inserted} rows, mapped ${stats.mapped} rows, missing ${stats.missing} rows`
|
const stats = await item.runImport();
|
||||||
);
|
logger.info(
|
||||||
|
`Duplicated ${item.name}, inserted ${stats.inserted} rows, mapped ${stats.mapped} rows, missing ${stats.missing} rows`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error({ err }, 'Failed duplicator job, rollbacking');
|
||||||
|
await runCommandOnDriver(this.pool, this.driver, dmp => dmp.rollbackTransaction());
|
||||||
}
|
}
|
||||||
|
await runCommandOnDriver(this.pool, this.driver, dmp => dmp.commitTransaction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user