From 3efcd3e52b5e281171cb76f24d84e8dae4ae414a Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Mon, 28 Nov 2022 10:05:30 -0500 Subject: [PATCH] Merge pull request #10644 from overleaf/em-chunk-store-mongo Mongo backend for the history chunk store GitOrigin-RevId: 8dcfc7e62065785616b7894009368b6acbb4428a --- .../web/app/src/infrastructure/mongodb.js | 1 + ...22191857_project_history_chunks_indexes.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 services/web/migrations/20221122191857_project_history_chunks_indexes.js diff --git a/services/web/app/src/infrastructure/mongodb.js b/services/web/app/src/infrastructure/mongodb.js index 124d109e39..1912584980 100644 --- a/services/web/app/src/infrastructure/mongodb.js +++ b/services/web/app/src/infrastructure/mongodb.js @@ -61,6 +61,7 @@ async function setupDb() { db.oauthApplications = internalDb.collection('oauthApplications') db.oauthAuthorizationCodes = internalDb.collection('oauthAuthorizationCodes') db.projectAuditLogEntries = internalDb.collection('projectAuditLogEntries') + db.projectHistoryChunks = internalDb.collection('projectHistoryChunks') db.projectHistoryFailures = internalDb.collection('projectHistoryFailures') db.projectHistoryLabels = internalDb.collection('projectHistoryLabels') db.projectHistoryMetaData = internalDb.collection('projectHistoryMetaData') diff --git a/services/web/migrations/20221122191857_project_history_chunks_indexes.js b/services/web/migrations/20221122191857_project_history_chunks_indexes.js new file mode 100644 index 0000000000..d4528a0f51 --- /dev/null +++ b/services/web/migrations/20221122191857_project_history_chunks_indexes.js @@ -0,0 +1,27 @@ +/* eslint-disable no-unused-vars */ + +const Helpers = require('./lib/helpers') + +exports.tags = ['server-ce', 'server-pro', 'saas'] + +const indexes = [ + { + key: { projectId: 1, startVersion: 1 }, + name: 'projectId_1_startVersion_1', + partialFilterExpression: { state: 'active' }, + unique: true, + }, + { + key: { state: 1 }, + name: 'state_1', + partialFilterExpression: { state: 'deleted' }, + }, +] + +exports.migrate = async ({ db }) => { + await Helpers.addIndexesToCollection(db.projectHistoryChunks, indexes) +} + +exports.rollback = async ({ db }) => { + await Helpers.dropIndexesFromCollection(db.projectHistoryChunks, indexes) +}