aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0040-video-remote-id.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
commit99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch)
treec9e04ccfcc5496d2300d7c26db5833e494b4cdad /server/initializers/migrations/0040-video-remote-id.js
parentfcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff)
parent91cc839af88730ba55f84997c56b85ea100070a7 (diff)
downloadPeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.gz
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.zst
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.zip
Merge branch 'postgresql'
Diffstat (limited to 'server/initializers/migrations/0040-video-remote-id.js')
-rw-r--r--server/initializers/migrations/0040-video-remote-id.js59
1 files changed, 0 insertions, 59 deletions
diff --git a/server/initializers/migrations/0040-video-remote-id.js b/server/initializers/migrations/0040-video-remote-id.js
deleted file mode 100644
index 46a14a689..000000000
--- a/server/initializers/migrations/0040-video-remote-id.js
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 Use remote id as identifier
3*/
4
5const map = require('lodash/map')
6const mongoose = require('mongoose')
7const readline = require('readline')
8
9const rl = readline.createInterface({
10 input: process.stdin,
11 output: process.stdout
12})
13
14const logger = require('../../helpers/logger')
15const friends = require('../../lib/friends')
16
17const Pod = mongoose.model('Pod')
18const Video = mongoose.model('Video')
19
20exports.up = function (callback) {
21 Pod.find({}).lean().exec(function (err, pods) {
22 if (err) return callback(err)
23
24 // We need to quit friends first
25 if (pods.length === 0) {
26 return setVideosRemoteId(callback)
27 }
28
29 const timeout = setTimeout(function () {
30 throw new Error('You need to enter a value!')
31 }, 10000)
32
33 rl.question('I am sorry but I need to quit friends for upgrading. Do you want to continue? (yes/*)', function (answer) {
34 if (answer !== 'yes') throw new Error('I cannot continue.')
35
36 clearTimeout(timeout)
37 rl.close()
38
39 const urls = map(pods, 'url')
40 logger.info('Saying goodbye to: ' + urls.join(', '))
41
42 setVideosRemoteId(function () {
43 friends.quitFriends(callback)
44 })
45 })
46 })
47}
48
49exports.down = function (callback) {
50 throw new Error('Not implemented.')
51}
52
53function setVideosRemoteId (callback) {
54 Video.update({ filename: { $ne: null } }, { remoteId: null }, function (err) {
55 if (err) throw err
56
57 Video.update({ filename: null }, { remoteId: mongoose.Types.ObjectId() }, callback)
58 })
59}