From 04968ab47717f0c90a3c05dc71fb24fc78599973 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 21 Nov 2016 22:08:40 +0100 Subject: [PATCH] Fix migration script --- .../migrations/0040-video-remote-id.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/server/initializers/migrations/0040-video-remote-id.js b/server/initializers/migrations/0040-video-remote-id.js index 5cf856b2e..46a14a689 100644 --- a/server/initializers/migrations/0040-video-remote-id.js +++ b/server/initializers/migrations/0040-video-remote-id.js @@ -2,7 +2,6 @@ Use remote id as identifier */ -const each = require('async/each') const map = require('lodash/map') const mongoose = require('mongoose') const readline = require('readline') @@ -40,8 +39,8 @@ exports.up = function (callback) { const urls = map(pods, 'url') logger.info('Saying goodbye to: ' + urls.join(', ')) - friends.quitFriends(function () { - setVideosRemoteId(callback) + setVideosRemoteId(function () { + friends.quitFriends(callback) }) }) }) @@ -52,12 +51,9 @@ exports.down = function (callback) { } function setVideosRemoteId (callback) { - Video.find({}, function (err, videos) { - if (err) return callback(err) + Video.update({ filename: { $ne: null } }, { remoteId: null }, function (err) { + if (err) throw err - each(videos, function (video, callbackEach) { - video.remoteId = null - video.save(callbackEach) - }, callback) + Video.update({ filename: null }, { remoteId: mongoose.Types.ObjectId() }, callback) }) } -- 2.41.0