mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #12861 from overleaf/em-ds-delete-chunk-migration
Better indexes for history chunks deletion GitOrigin-RevId: 1404f5a0535bc94cb1e9d7fc2ea66fd90f584fea
This commit is contained in:
parent
cc604376c5
commit
66d29940c3
1 changed files with 58 additions and 0 deletions
|
@ -0,0 +1,58 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
|
||||
const Helpers = require('./lib/helpers')
|
||||
|
||||
exports.tags = ['server-ce', 'server-pro', 'saas']
|
||||
|
||||
const oldIndexes = [
|
||||
{
|
||||
key: {
|
||||
state: 1,
|
||||
},
|
||||
name: 'state_1',
|
||||
partialFilterExpression: {
|
||||
state: 'deleted',
|
||||
},
|
||||
},
|
||||
{
|
||||
key: {
|
||||
state: -1,
|
||||
},
|
||||
name: 'state_pending',
|
||||
partialFilterExpression: {
|
||||
state: 'pending',
|
||||
},
|
||||
},
|
||||
]
|
||||
const newIndexes = [
|
||||
{
|
||||
key: {
|
||||
updatedAt: 1,
|
||||
},
|
||||
name: 'deleted_updated_at',
|
||||
partialFilterExpression: {
|
||||
state: 'deleted',
|
||||
},
|
||||
},
|
||||
{
|
||||
key: {
|
||||
updatedAt: -1,
|
||||
},
|
||||
name: 'pending_updated_at',
|
||||
partialFilterExpression: {
|
||||
state: 'pending',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
exports.migrate = async client => {
|
||||
const { db } = client
|
||||
await Helpers.addIndexesToCollection(db.projectHistoryChunks, newIndexes)
|
||||
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, oldIndexes)
|
||||
}
|
||||
|
||||
exports.rollback = async client => {
|
||||
const { db } = client
|
||||
await Helpers.addIndexesToCollection(db.projectHistoryChunks, oldIndexes)
|
||||
await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, newIndexes)
|
||||
}
|
Loading…
Reference in a new issue