From e8c829deab010c7a009a0ec010f4227489090f4a Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Thu, 23 Oct 2025 12:01:03 +0100 Subject: [PATCH] Clean up direct usages of db.docHistory Co-authored-by: Ilkin Ismailov GitOrigin-RevId: 63bc36f15d85f68770bbbff5a7f64d5bc167c7f0 --- services/web/scripts/history/clean_sl_history_data.mjs | 3 ++- .../20190912145005_create_docHistory_indexes.mjs | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/services/web/scripts/history/clean_sl_history_data.mjs b/services/web/scripts/history/clean_sl_history_data.mjs index 8f2bc1eab0..23fe136c4c 100644 --- a/services/web/scripts/history/clean_sl_history_data.mjs +++ b/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' diff --git a/tools/migrations/20190912145005_create_docHistory_indexes.mjs b/tools/migrations/20190912145005_create_docHistory_indexes.mjs index 22d9b4ef6c..6cd6609462 100644 --- a/tools/migrations/20190912145005_create_docHistory_indexes.mjs +++ b/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) }