mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-18 04:05:14 -05:00
353813ce23
GitOrigin-RevId: bce6060c597ae9b51a01b849f405c8f7a23b6747
29 lines
737 B
JavaScript
29 lines
737 B
JavaScript
const Settings = require('settings-sharelatex')
|
|
const mongojs = require('mongojs')
|
|
const db = mongojs(Settings.mongo.url, ['tokens'])
|
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
const async = require('async')
|
|
|
|
exports.migrate = (client, done) => {
|
|
console.log(`>> Updating 'data.email' to lower case in tokens`)
|
|
|
|
db.tokens.find({}, { 'data.email': 1 }, (err, tokens) => {
|
|
if (err) {
|
|
return done(err)
|
|
}
|
|
|
|
async.eachSeries(
|
|
tokens,
|
|
(token, callback) => {
|
|
db.tokens.update(
|
|
{ _id: token._id },
|
|
{ $set: { 'data.email': token.data.email.toLowerCase() } },
|
|
callback
|
|
)
|
|
},
|
|
done
|
|
)
|
|
})
|
|
}
|
|
|
|
exports.rollback = (client, done) => done()
|