Merge pull request #15870 from overleaf/em-revert-docops-migration

Revert docOps migration to the docs collection

GitOrigin-RevId: cdb46321c5aa349bead0990dcd270e703e3debc7
This commit is contained in:
Eric Mc Sween 2023-11-21 09:08:42 -05:00 committed by Copybot
parent 9e090992f1
commit 7029a0822b

View file

@ -1,33 +0,0 @@
const { ReadPreference } = require('mongodb')
exports.tags = ['server-ce', 'server-pro', 'saas']
exports.migrate = async ({ db }) => {
const records = db.docOps.find(
{},
{ readPreference: ReadPreference.secondaryPreferred }
)
let docsProcessed = 0
for await (const record of records) {
const docId = record.doc_id
const version = record.version
await db.docs.updateOne(
{
_id: docId,
version: { $exists: false },
},
{ $set: { version } }
)
docsProcessed += 1
if (docsProcessed % 100000 === 0) {
console.log(`${docsProcessed} docs processed`)
}
}
}
exports.rollback = async ({ db }) => {
// Nothing to do on rollback. We don't want to remove versions from the docs
// collection because they might be more current than the ones in the docOps
// collection.
}