From 3165315f84dac60a03ccb671734099f3fab5b435 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 17 Sep 2021 13:46:19 +0200 Subject: [PATCH] fixup! Refactored migration to run faster --- .../versions/4.14/02-fix-free-members-status-events.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/server/data/migrations/versions/4.14/02-fix-free-members-status-events.js b/core/server/data/migrations/versions/4.14/02-fix-free-members-status-events.js index 9efb9e8da4..68c4e4e62a 100644 --- a/core/server/data/migrations/versions/4.14/02-fix-free-members-status-events.js +++ b/core/server/data/migrations/versions/4.14/02-fix-free-members-status-events.js @@ -19,6 +19,11 @@ module.exports = createTransactionalMigration( ) .where('members.status', 'free'); + if (freeMemberEvents.length === 0) { + logging.info('No free members found - skipping migration'); + return; + } + const eventsByMember = _.groupBy(freeMemberEvents, 'member_id'); const eventsToUpdate = Object.keys(eventsByMember).reduce((incorrectEvents, memberId) => {