mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add migration for token-based access indexes
This commit is contained in:
parent
d14d5002ab
commit
008d052862
1 changed files with 43 additions and 0 deletions
43
server-ce/migrations/7_add_token_indexes.coffee
Normal file
43
server-ce/migrations/7_add_token_indexes.coffee
Normal file
|
@ -0,0 +1,43 @@
|
|||
Settings = require "settings-sharelatex"
|
||||
fs = require("fs")
|
||||
mongojs = require("mongojs")
|
||||
ObjectId = mongojs.ObjectId
|
||||
db = mongojs(Settings.mongo.url, ['docs','docHistory', 'docHistoryStats'])
|
||||
_ = require("underscore")
|
||||
async = require("async")
|
||||
exec = require("child_process").exec
|
||||
bson = require('bson')
|
||||
BSON = new bson()
|
||||
|
||||
|
||||
handleExit = () ->
|
||||
console.log('Got signal. Shutting down.')
|
||||
|
||||
|
||||
exports.migrate = (client, done=()->) ->
|
||||
console.log ">> Adding indexes for token-based project access: "
|
||||
db.projects.ensureIndex {'tokens.readAndWrite': 1}, {
|
||||
partialFilterExpression: { 'tokens.readAndWrite': { $exists: true } },
|
||||
unique: true,
|
||||
background: true
|
||||
}, (err) ->
|
||||
if err?
|
||||
return done(err)
|
||||
db.projects.ensureIndex {'tokens.readOnly': 1}, {
|
||||
partialFilterExpression: { 'tokens.readOnly': { $exists: true } },
|
||||
unique: true,
|
||||
background: true
|
||||
}, (err) ->
|
||||
if err?
|
||||
return done(err)
|
||||
console.log ">> done adding indexes for token-based project access"
|
||||
done()
|
||||
|
||||
|
||||
exports.rollback = (client, done) ->
|
||||
done()
|
||||
|
||||
|
||||
process.on 'SIGINT', handleExit
|
||||
process.on 'SIGHUP', handleExit
|
||||
|
Loading…
Reference in a new issue