overleaf/services/web/scripts/project-tokens/add_readAndWritePrefix_index.js
Shane Kilkelly 25a0ea8752 Merge pull request #1495 from sharelatex/sk-migrate-read-and-write-token-prefix
Add migrations for new project property: `tokens.readAndWritePrefix`

GitOrigin-RevId: 276a9e53533ae76e04e20fd94234f65999874662
2019-02-14 10:27:02 +00:00

23 lines
485 B
JavaScript

const mongojs = require('../../app/js/infrastructure/mongojs')
const { db } = mongojs
const keys = { 'tokens.readAndWritePrefix': 1 }
const opts = {
unique: true,
partialFilterExpression: {
'tokens.readAndWritePrefix': { $exists: true }
},
background: true
}
console.log(
`>> Creating index on ${JSON.stringify(keys)}, ${JSON.stringify(opts)}`
)
db.projects.createIndex(keys, opts, err => {
if (err) {
throw err
}
console.log('>> done')
process.exit(0)
})