Moved members migrations to one off job

refs https://github.com/TryGhost/Toolbox/issues/358

- The execution of members migration only ever has to be done once in the lifetime of the Ghost instance. It is slightly slow and blocking process, which slows down instance boot time considerably. Putting the execution into one off job allows to execute migrations only once and save boot time on each consequent instance restart - less resource usage, save the planet!
This commit is contained in:
Naz 2022-07-27 18:07:24 +01:00
parent 6d5a5e90b1
commit 1606a10ff8

View File

@ -148,7 +148,16 @@ module.exports = {
}
})();
await stripeService.migrations.execute();
const membersMigrationJobName = 'members-migrations';
if (!(await jobsService.hasExecuted(membersMigrationJobName))) {
jobsService.addOneOffJob({
name: membersMigrationJobName,
offloaded: false,
job: stripeService.migrations.execute.bind(stripeService.migrations)
});
await jobsService.awaitCompletion(membersMigrationJobName);
}
},
contentGating: require('./content-gating'),