From 9afcd88a483280eaed1ac683df82224dabffa112 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Wed, 17 Sep 2025 11:22:01 +0100 Subject: [PATCH] Merge pull request #28469 from overleaf/td-improve-project-audit-log-index Improve project audit log entries Mongo index GitOrigin-RevId: a4343523af6fad85957876bd3c0cb04bf1e87f63 --- ...estamp_to_projectAuditLogEntries_index.mjs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 services/web/migrations/20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs diff --git a/services/web/migrations/20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs b/services/web/migrations/20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs new file mode 100644 index 0000000000..dc3a2195d3 --- /dev/null +++ b/services/web/migrations/20250912102601_add_timestamp_to_projectAuditLogEntries_index.mjs @@ -0,0 +1,36 @@ +import Helpers from './lib/helpers.mjs' + +const oldIndex = { + key: { + projectId: 1, + }, + name: 'project_id_1', +} + +const newIndex = { + key: { + projectId: 1, + timestamp: -1, + }, + name: 'projectId_1_timestamp_-1', +} + +const tags = ['server-ce', 'server-pro', 'saas'] + +const migrate = async client => { + const { db } = client + await Helpers.addIndexesToCollection(db.projectAuditLogEntries, [newIndex]) + await Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, [oldIndex]) +} + +const rollback = async client => { + const { db } = client + await Helpers.addIndexesToCollection(db.projectAuditLogEntries, [oldIndex]) + await Helpers.dropIndexesFromCollection(db.projectAuditLogEntries, [newIndex]) +} + +export default { + tags, + migrate, + rollback, +}