From 235685aa61c594dfad9bd043bcb71b49a898f7b6 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Tue, 14 Jul 2026 08:42:18 -0400 Subject: [PATCH] Merge pull request #35432 from overleaf/em-change-library-mongo-cluster-migration-script Copy library collections to the auxiliary Mongo cluster GitOrigin-RevId: 87c0433b4345fdaa3fe3c141af888eaa0106ea45 --- services/web/app/src/infrastructure/mongodb.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/web/app/src/infrastructure/mongodb.mjs b/services/web/app/src/infrastructure/mongodb.mjs index e467327e82..3f828c669f 100644 --- a/services/web/app/src/infrastructure/mongodb.mjs +++ b/services/web/app/src/infrastructure/mongodb.mjs @@ -254,6 +254,18 @@ export async function getCollectionInternal(name) { return internalDb.collection(name) } +/** + * Direct access to a collection on the auxiliary Mongo cluster, bypassing + * the dual-write mirror in `db`. For use by data-migration scripts that need + * to write to the auxiliary cluster without also writing to the primary one. + */ +export async function getAuxCollectionInternal(name) { + if (!auxInternalDb) { + throw new OError('no auxiliary Mongo cluster configured') + } + return auxInternalDb.collection(name) +} + export async function waitForDb() { await connectionPromise await auxConnectionPromise