Przeglądaj źródła

Clean up direct usages of db.docHistory

Co-authored-by: Ilkin Ismailov <ilkin.ismailov@overleaf.com>
GitOrigin-RevId: 63bc36f15d85f68770bbbff5a7f64d5bc167c7f0
Andrew Rumble 9 miesięcy temu
rodzic
commit
e8c829deab

+ 2 - 1
services/web/scripts/history/clean_sl_history_data.mjs

@@ -48,7 +48,8 @@ async function setAllowDowngradeToFalse() {
 }
 
 async function deleteHistoryCollections() {
-  await gracefullyDropCollection(db.docHistory)
+  const docHistory = await getCollectionInternal('docHistory')
+  await gracefullyDropCollection(docHistory)
   await gracefullyDropCollection(db.docHistoryIndex)
   const projectHistoryMetaData = await getCollectionInternal(
     'projectHistoryMetaData'

+ 5 - 4
tools/migrations/20190912145005_create_docHistory_indexes.mjs

@@ -1,6 +1,7 @@
 /* eslint-disable no-unused-vars */
 
 import Helpers from './lib/helpers.mjs'
+import { getCollectionInternal } from './lib/mongodb.mjs'
 
 const tags = ['server-ce', 'server-pro', 'saas']
 
@@ -42,16 +43,16 @@ const indexes = [
 ]
 
 const migrate = async client => {
-  const { db } = client
+  const docHistory = await getCollectionInternal('docHistory')
 
-  await Helpers.addIndexesToCollection(db.docHistory, indexes)
+  await Helpers.addIndexesToCollection(docHistory, indexes)
 }
 
 const rollback = async client => {
-  const { db } = client
+  const docHistory = await getCollectionInternal('docHistory')
 
   try {
-    await Helpers.dropIndexesFromCollection(db.docHistory, indexes)
+    await Helpers.dropIndexesFromCollection(docHistory, indexes)
   } catch (err) {
     console.error('Something went wrong rolling back the migrations', err)
   }