overleaf/server-ce/migrations/12_add_deletedFiles_indexes.js
2021-04-14 12:54:46 +02:00

24 lines
548 B
JavaScript

// Internal ticket: https://github.com/overleaf/issues/issues/4094
const Settings = require('settings-sharelatex')
const mongojs = require('mongojs')
const db = mongojs(Settings.mongo.url, ['deletedFiles'])
const INDEX_NAME = 'projectId_1'
const INDEX_KEYS = { projectId: 1 }
const INDEX_OPTIONS = {
name: INDEX_NAME,
background: 1
}
exports.migrate = (client, done) => {
db.deletedFiles.ensureIndex(
INDEX_KEYS,
INDEX_OPTIONS,
done
)
}
exports.rollback = (client, done) => {
db.deletedFiles.dropIndex(INDEX_NAME, done)
}