From: Chocobozzz Date: Thu, 12 Jan 2017 16:01:10 +0000 (+0100) Subject: Server: fix mongo to postgresql script X-Git-Tag: v0.0.1-alpha~572 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=acf0ae9c730c19be6447d1d140e2bc04186b4fe4;p=oweals%2Fpeertube.git Server: fix mongo to postgresql script --- diff --git a/scripts/mongo-to-postgre.js b/scripts/mongo-to-postgre.js index 4a581b46a..6cd1ef3b4 100755 --- a/scripts/mongo-to-postgre.js +++ b/scripts/mongo-to-postgre.js @@ -126,7 +126,8 @@ function migrateVideos (videoMongo, dbSequelize, finalCallback) { dbSequelize.Pod.findOrCreate(query).asCallback(function (err, result) { // [ instance, wasCreated ] - return callback(err, t, result[0]) + const res = result ? result[0] : null + return callback(err, t, res) }) }, @@ -148,7 +149,8 @@ function migrateVideos (videoMongo, dbSequelize, finalCallback) { dbSequelize.Author.findOrCreate(query).asCallback(function (err, result) { // [ instance, wasCreated ] - return callback(err, t, result[0]) + const res = result ? result[0] : null + return callback(err, t, res) }) }, @@ -235,9 +237,7 @@ function migrateVideos (videoMongo, dbSequelize, finalCallback) { } // Commit transaction - t.commit() - - return callbackEach() + return t.commit().asCallback(callbackEach) }) }, finalCallback) })