aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0040-video-remote-id.js14
1 files 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 @@
2 Use remote id as identifier 2 Use remote id as identifier
3*/ 3*/
4 4
5const each = require('async/each')
6const map = require('lodash/map') 5const map = require('lodash/map')
7const mongoose = require('mongoose') 6const mongoose = require('mongoose')
8const readline = require('readline') 7const readline = require('readline')
@@ -40,8 +39,8 @@ exports.up = function (callback) {
40 const urls = map(pods, 'url') 39 const urls = map(pods, 'url')
41 logger.info('Saying goodbye to: ' + urls.join(', ')) 40 logger.info('Saying goodbye to: ' + urls.join(', '))
42 41
43 friends.quitFriends(function () { 42 setVideosRemoteId(function () {
44 setVideosRemoteId(callback) 43 friends.quitFriends(callback)
45 }) 44 })
46 }) 45 })
47 }) 46 })
@@ -52,12 +51,9 @@ exports.down = function (callback) {
52} 51}
53 52
54function setVideosRemoteId (callback) { 53function setVideosRemoteId (callback) {
55 Video.find({}, function (err, videos) { 54 Video.update({ filename: { $ne: null } }, { remoteId: null }, function (err) {
56 if (err) return callback(err) 55 if (err) throw err
57 56
58 each(videos, function (video, callbackEach) { 57 Video.update({ filename: null }, { remoteId: mongoose.Types.ObjectId() }, callback)
59 video.remoteId = null
60 video.save(callbackEach)
61 }, callback)
62 }) 58 })
63} 59}