overleaf/migrations/13_add_deleted_docs_index.js

29 lines
577 B
JavaScript
Raw Normal View History

// Internal ticket: https://github.com/overleaf/issues/issues/4211
const Settings = require('settings-sharelatex')
const mongojs = require('mongojs')
const db = mongojs(Settings.mongo.url, ['docs'])
2021-04-14 06:54:46 -04:00
const INDEX_NAME = 'project_id_deleted_deletedAt_1'
const INDEX_KEYS = {
project_id: 1,
deleted: 1,
deletedAt: -1
}
const INDEX_OPTIONS = {
2021-04-14 06:54:46 -04:00
name: INDEX_NAME,
background: 1
}
exports.migrate = (client, done) => {
db.docs.ensureIndex(
2021-04-14 06:54:46 -04:00
INDEX_KEYS,
INDEX_OPTIONS,
done
)
}
exports.rollback = (client, done) => {
2021-04-14 06:54:46 -04:00
db.docs.dropIndex(INDEX_NAME, done)
}