diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-11-21 22:08:40 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-11-21 22:09:45 +0100 |
commit | 04968ab47717f0c90a3c05dc71fb24fc78599973 (patch) | |
tree | 96faea9e3c07f9c2334691592f8956dacde991d1 | |
parent | a86444089eeec4a4565e475d9a60830e9b0b24c0 (diff) | |
download | PeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.tar.gz PeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.tar.zst PeerTube-04968ab47717f0c90a3c05dc71fb24fc78599973.zip |
Fix migration script
-rw-r--r-- | server/initializers/migrations/0040-video-remote-id.js | 14 |
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 | ||
5 | const each = require('async/each') | ||
6 | const map = require('lodash/map') | 5 | const map = require('lodash/map') |
7 | const mongoose = require('mongoose') | 6 | const mongoose = require('mongoose') |
8 | const readline = require('readline') | 7 | const 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 | ||
54 | function setVideosRemoteId (callback) { | 53 | function 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 | } |