From 3f7f2d5cedc32e64415285efdc644750c7e336ce Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 13 Apr 2021 21:50:32 +0200 Subject: [PATCH] [migrations] open source newly added indexes (#870) --- .../migrations/12_add_deletedFiles_indexes.js | 25 +++++++++++++++++ .../migrations/13_add_deleted_docs_index.js | 27 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 server-ce/migrations/12_add_deletedFiles_indexes.js create mode 100644 server-ce/migrations/13_add_deleted_docs_index.js diff --git a/server-ce/migrations/12_add_deletedFiles_indexes.js b/server-ce/migrations/12_add_deletedFiles_indexes.js new file mode 100644 index 0000000000..e16c77e7e5 --- /dev/null +++ b/server-ce/migrations/12_add_deletedFiles_indexes.js @@ -0,0 +1,25 @@ +// Internal ticket: https://github.com/overleaf/issues/issues/4094 + +const Settings = require('settings-sharelatex') +const mongojs = require('mongojs') +const db = mongojs(Settings.mongo.url, ['deletedFiles']) + +const INDEX_FILTER = { 'projectId_1': 1 } +const INDEX_OPTIONS = { + key: { + projectId: 1 + }, + background: 1 +} + +exports.migrate = (client, done) => { + db.deletedFiles.ensureIndex( + INDEX_FILTER, + INDEX_OPTIONS, + done + ) +} + +exports.rollback = (client, done) => { + db.deletedFiles.dropIndex(INDEX_FILTER, done) +} diff --git a/server-ce/migrations/13_add_deleted_docs_index.js b/server-ce/migrations/13_add_deleted_docs_index.js new file mode 100644 index 0000000000..be8f86c0d3 --- /dev/null +++ b/server-ce/migrations/13_add_deleted_docs_index.js @@ -0,0 +1,27 @@ +// Internal ticket: https://github.com/overleaf/issues/issues/4211 + +const Settings = require('settings-sharelatex') +const mongojs = require('mongojs') +const db = mongojs(Settings.mongo.url, ['docs']) + +const INDEX_FILTER = { 'project_id_deleted_deletedAt_1': 1 } +const INDEX_OPTIONS = { + key: { + project_id: 1, + deleted: 1, + deletedAt: -1 + }, + background: 1 +} + +exports.migrate = (client, done) => { + db.docs.ensureIndex( + INDEX_FILTER, + INDEX_OPTIONS, + done + ) +} + +exports.rollback = (client, done) => { + db.docs.dropIndex(INDEX_FILTER, done) +}