mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
[migrations] fix index creation (#871)
This commit is contained in:
parent
3f7f2d5ced
commit
507548d661
2 changed files with 14 additions and 14 deletions
|
@ -4,22 +4,21 @@ const Settings = require('settings-sharelatex')
|
|||
const mongojs = require('mongojs')
|
||||
const db = mongojs(Settings.mongo.url, ['deletedFiles'])
|
||||
|
||||
const INDEX_FILTER = { 'projectId_1': 1 }
|
||||
const INDEX_NAME = 'projectId_1'
|
||||
const INDEX_KEYS = { projectId: 1 }
|
||||
const INDEX_OPTIONS = {
|
||||
key: {
|
||||
projectId: 1
|
||||
},
|
||||
name: INDEX_NAME,
|
||||
background: 1
|
||||
}
|
||||
|
||||
exports.migrate = (client, done) => {
|
||||
db.deletedFiles.ensureIndex(
|
||||
INDEX_FILTER,
|
||||
INDEX_KEYS,
|
||||
INDEX_OPTIONS,
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
exports.rollback = (client, done) => {
|
||||
db.deletedFiles.dropIndex(INDEX_FILTER, done)
|
||||
db.deletedFiles.dropIndex(INDEX_NAME, done)
|
||||
}
|
||||
|
|
|
@ -4,24 +4,25 @@ const Settings = require('settings-sharelatex')
|
|||
const mongojs = require('mongojs')
|
||||
const db = mongojs(Settings.mongo.url, ['docs'])
|
||||
|
||||
const INDEX_FILTER = { 'project_id_deleted_deletedAt_1': 1 }
|
||||
const INDEX_NAME = 'project_id_deleted_deletedAt_1'
|
||||
const INDEX_KEYS = {
|
||||
project_id: 1,
|
||||
deleted: 1,
|
||||
deletedAt: -1
|
||||
}
|
||||
const INDEX_OPTIONS = {
|
||||
key: {
|
||||
project_id: 1,
|
||||
deleted: 1,
|
||||
deletedAt: -1
|
||||
},
|
||||
name: INDEX_NAME,
|
||||
background: 1
|
||||
}
|
||||
|
||||
exports.migrate = (client, done) => {
|
||||
db.docs.ensureIndex(
|
||||
INDEX_FILTER,
|
||||
INDEX_KEYS,
|
||||
INDEX_OPTIONS,
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
exports.rollback = (client, done) => {
|
||||
db.docs.dropIndex(INDEX_FILTER, done)
|
||||
db.docs.dropIndex(INDEX_NAME, done)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue