Server: fix migration at installation

pull/10/head
Chocobozzz 2016-09-26 23:10:32 +02:00
parent da4971c11f
commit f6a0754fda
3 changed files with 9 additions and 7 deletions

View File

@ -7,9 +7,9 @@ const logger = require('../helpers/logger')
// Bootstrap models // Bootstrap models
require('../models/application') require('../models/application')
require('../models/oauth-token')
require('../models/user') require('../models/user')
require('../models/oauth-client') require('../models/oauth-client')
require('../models/oauth-token')
require('../models/pods') require('../models/pods')
require('../models/video') require('../models/video')
// Request model needs Video model // Request model needs Video model

View File

@ -13,6 +13,7 @@ const constants = require('./constants')
const logger = require('../helpers/logger') const logger = require('../helpers/logger')
const peertubeCrypto = require('../helpers/peertube-crypto') const peertubeCrypto = require('../helpers/peertube-crypto')
const Application = mongoose.model('Application')
const Client = mongoose.model('OAuthClient') const Client = mongoose.model('OAuthClient')
const User = mongoose.model('User') const User = mongoose.model('User')
@ -117,7 +118,9 @@ function createOAuthAdminIfNotExist (callback) {
logger.info('Username: ' + username) logger.info('Username: ' + username)
logger.info('User password: ' + password) logger.info('User password: ' + password)
return callback(null) logger.info('Creating Application collection.')
const application = new Application({ mongoSchemaVersion: constants.LAST_MONGO_SCHEMA_VERSION })
application.save(callback)
}) })
}) })
} }

View File

@ -2,6 +2,7 @@
Convert plain user password to encrypted user password. Convert plain user password to encrypted user password.
*/ */
const eachSeries = require('async/eachSeries')
const mongoose = require('mongoose') const mongoose = require('mongoose')
const User = mongoose.model('User') const User = mongoose.model('User')
@ -10,11 +11,9 @@ exports.up = function (callback) {
User.list(function (err, users) { User.list(function (err, users) {
if (err) return callback(err) if (err) return callback(err)
users.forEach(function (user) { eachSeries(users, function (user, callbackEach) {
user.save() user.save(callbackEach)
}) }, callback)
return callback(null)
}) })
} }