From 5895facb7ee09d6d56ddf180225e40822318956d Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 28 Aug 2025 15:05:54 +0200 Subject: [PATCH] Merge pull request #28175 from overleaf/tm-subscription-v1-id-index Add migration to create sparse v1_id index on subscriptions collection GitOrigin-RevId: 2c251c8958328a94bdca80712839d8e695f169d7 --- ...095305_create_subscription_v1_id_index.mjs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 services/web/migrations/20250828095305_create_subscription_v1_id_index.mjs diff --git a/services/web/migrations/20250828095305_create_subscription_v1_id_index.mjs b/services/web/migrations/20250828095305_create_subscription_v1_id_index.mjs new file mode 100644 index 0000000000..064ae10069 --- /dev/null +++ b/services/web/migrations/20250828095305_create_subscription_v1_id_index.mjs @@ -0,0 +1,27 @@ +import Helpers from './lib/helpers.mjs' + +const tags = ['saas'] + +const indexes = [ + { + key: { v1_id: 1 }, + name: 'v1_id_1', + sparse: true, + }, +] + +const migrate = async client => { + const { db } = client + await Helpers.addIndexesToCollection(db.subscriptions, indexes) +} + +const rollback = async client => { + const { db } = client + await Helpers.dropIndexesFromCollection(db.subscriptions, indexes) +} + +export default { + tags, + migrate, + rollback, +}