From c82704c9a0b612cb6971737bd6dcb0680d9e18a3 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 5 Sep 2025 11:37:16 +0100 Subject: [PATCH] Merge pull request #28171 from overleaf/bg-drop-old-lastbackedupversion-index add migration to drop old lastBackedUpVersion index GitOrigin-RevId: bfdf88ba9e94f3603df5415bc384e31c5f365709 --- ...935_drop_old_lastBackedUpVersion_index.mjs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 services/web/migrations/20250828100935_drop_old_lastBackedUpVersion_index.mjs diff --git a/services/web/migrations/20250828100935_drop_old_lastBackedUpVersion_index.mjs b/services/web/migrations/20250828100935_drop_old_lastBackedUpVersion_index.mjs new file mode 100644 index 0000000000..45662cc037 --- /dev/null +++ b/services/web/migrations/20250828100935_drop_old_lastBackedUpVersion_index.mjs @@ -0,0 +1,36 @@ +/* eslint-disable no-unused-vars */ + +import Helpers from './lib/helpers.mjs' + +const tags = ['saas'] + +const indexes = [ + { + key: { 'overleaf.backup.lastBackedUpVersion': 1 }, + name: 'overleaf.backup.lastBackedUpVersion_1', + partialFilterExpression: { + 'overleaf.backup.lastBackedUpVersion': { $in: [null] }, + }, + }, +] + +const migrate = async client => { + const { db } = client + // Ensure the optimisation migration has run first to create the new index + await Helpers.assertDependency( + '20250827155732_optimise_lastBackedUpVersion_index' + ) + // Drop the old index from 20250307120446_create_project_lastBackedUpVersion_index + await Helpers.dropIndexesFromCollection(db.projects, indexes) +} + +const rollback = async client => { + const { db } = client + await Helpers.addIndexesToCollection(db.projects, indexes) +} + +export default { + tags, + migrate, + rollback, +}