Server: fix migration at installation
This commit is contained in:
parent
da4971c11f
commit
f6a0754fda
3 changed files with 9 additions and 7 deletions
|
@ -7,9 +7,9 @@ const logger = require('../helpers/logger')
|
|||
|
||||
// Bootstrap models
|
||||
require('../models/application')
|
||||
require('../models/oauth-token')
|
||||
require('../models/user')
|
||||
require('../models/oauth-client')
|
||||
require('../models/oauth-token')
|
||||
require('../models/pods')
|
||||
require('../models/video')
|
||||
// Request model needs Video model
|
||||
|
|
|
@ -13,6 +13,7 @@ const constants = require('./constants')
|
|||
const logger = require('../helpers/logger')
|
||||
const peertubeCrypto = require('../helpers/peertube-crypto')
|
||||
|
||||
const Application = mongoose.model('Application')
|
||||
const Client = mongoose.model('OAuthClient')
|
||||
const User = mongoose.model('User')
|
||||
|
||||
|
@ -117,7 +118,9 @@ function createOAuthAdminIfNotExist (callback) {
|
|||
logger.info('Username: ' + username)
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Convert plain user password to encrypted user password.
|
||||
*/
|
||||
|
||||
const eachSeries = require('async/eachSeries')
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
const User = mongoose.model('User')
|
||||
|
@ -10,11 +11,9 @@ exports.up = function (callback) {
|
|||
User.list(function (err, users) {
|
||||
if (err) return callback(err)
|
||||
|
||||
users.forEach(function (user) {
|
||||
user.save()
|
||||
})
|
||||
|
||||
return callback(null)
|
||||
eachSeries(users, function (user, callbackEach) {
|
||||
user.save(callbackEach)
|
||||
}, callback)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue