diff --git a/v1Tov2Migrations/migrate_approved_captures.js b/v1Tov2Migrations/migrate_approved_captures.js index 6bf3df0..e975fbf 100644 --- a/v1Tov2Migrations/migrate_approved_captures.js +++ b/v1Tov2Migrations/migrate_approved_captures.js @@ -46,8 +46,9 @@ async function migrate() { { width: 40, total: recordCount }, ); - const trx = await knex.transaction(); ws._write = async (rawCapture, enc, next) => { + console.log('processing ', rawCapture.id); + const trx = await knex.transaction(); try { const tree = await trx .select() @@ -61,12 +62,13 @@ async function migrate() { [+tree.id], ); - console.log('migrating ', tree.id) + console.log('migrating ', tree.id); await createCapture(rawCapture, tree, trx, treeTags.rows); + await trx.commit(); + console.log('processed ', rawCapture.id); bar.tick(); if (bar.complete) { - await trx.commit(); console.log('Migration Complete'); process.exit(); } diff --git a/v1Tov2Migrations/migrate_raw_captures.js b/v1Tov2Migrations/migrate_raw_captures.js index 51de259..b25259e 100644 --- a/v1Tov2Migrations/migrate_raw_captures.js +++ b/v1Tov2Migrations/migrate_raw_captures.js @@ -61,10 +61,10 @@ async function migrate() { { width: 40, total: recordCount }, ); - const trx = await knex.transaction(); ws._write = async (tree, enc, next) => { + console.log('processing ', tree.id); + const trx = await knex.transaction(); try { - console.log('processing ', tree.id); const planter = await trx .select() .table('public.planter') @@ -137,9 +137,10 @@ async function migrate() { await createRawCapture(tree, treeAttributes, sessionId, trx); + await trx.commit(); + console.log('processed ', tree.id); bar.tick(); if (bar.complete) { - await trx.commit(); console.log('Migration Complete'); process.exit(); } diff --git a/v1Tov2Migrations/migrate_trees.js b/v1Tov2Migrations/migrate_trees.js index 5c61c0c..cd37168 100644 --- a/v1Tov2Migrations/migrate_trees.js +++ b/v1Tov2Migrations/migrate_trees.js @@ -27,13 +27,17 @@ async function migrate() { } console.log(`Migrating ${recordCount} records`); - const bar = new ProgressBar('Migrating [:bar] :percent :etas :current/:total (:rate)', { - width: 40, - total: recordCount, - }); + const bar = new ProgressBar( + 'Migrating [:bar] :percent :etas :current/:total (:rate)', + { + width: 40, + total: recordCount, + }, + ); - const trx = await knex.transaction(); ws._write = async (capture, enc, next) => { + console.log('processing ', capture.id); + const trx = await knex.transaction(); try { // migrate capture_tags as well, do we want to? const captureTags = await trx.raw( @@ -43,9 +47,10 @@ async function migrate() { await createTree(capture, trx, captureTags.rows); + await trx.commit(); + console.log('processed ', capture.id); bar.tick(); if (bar.complete) { - await trx.commit(); console.log('Migration Complete'); process.exit(); }