From cebaebc356c3ebe1b5e80c7d4cf6f9999ef71cb8 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 31 Jan 2025 11:23:39 +0000 Subject: [PATCH] [web] add migration for indexing onboardingDataCollection.updatedAt (#22918) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dr. Sasha Göbbels GitOrigin-RevId: 6dbd3e994dc3ebc3ef9afd6d3e3efe00606ba127 --- ...boardingDataCollection_updatedAt_index.mjs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 services/web/migrations/20250116090000_onboardingDataCollection_updatedAt_index.mjs diff --git a/services/web/migrations/20250116090000_onboardingDataCollection_updatedAt_index.mjs b/services/web/migrations/20250116090000_onboardingDataCollection_updatedAt_index.mjs new file mode 100644 index 0000000000..a22b2b39fd --- /dev/null +++ b/services/web/migrations/20250116090000_onboardingDataCollection_updatedAt_index.mjs @@ -0,0 +1,30 @@ +import Helpers from './lib/helpers.mjs' + +const tags = ['saas'] + +const index = { + key: { updatedAt: 1 }, + name: 'updatedAt_1', +} + +const migrate = async client => { + const { db } = client + await Helpers.addIndexesToCollection(db.onboardingDataCollection, [index]) +} + +const rollback = async client => { + const { db } = client + try { + await Helpers.dropIndexesFromCollection(db.onboardingDataCollection, [ + index, + ]) + } catch (err) { + console.error('Something went wrong rolling back the migrations', err) + } +} + +export default { + tags, + migrate, + rollback, +}