aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-11-21 22:08:40 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-11-21 22:09:45 +0100
commit04968ab47717f0c90a3c05dc71fb24fc78599973 (patch)
tree96faea9e3c07f9c2334691592f8956dacde991d1 /server/initializers
parenta86444089eeec4a4565e475d9a60830e9b0b24c0 (diff)
downloadPeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.tar.gz
PeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.tar.zst
PeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.zip
Fix migration script
Diffstat (limited to 'server/initializers')
-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}