mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs #6301 - Replace builder & automated database upgrade with a set of explicit tasks - Ensure the tasks can only happen if they need to - Remove some duplicate code between fixture & db upgrades (more to do) - Add tests
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
// # Update Fixtures
|
|
// This module handles updating fixtures.
|
|
// This is done manually, through a series of files stored in an adjacent folder
|
|
// E.g. if we update to version 004, all the tasks in /004/ are executed
|
|
|
|
var sequence = require('../../../utils/sequence'),
|
|
versioning = require('../../schema').versioning,
|
|
|
|
// Private
|
|
modelOptions = {context: {internal: true}},
|
|
|
|
// Public
|
|
update;
|
|
|
|
/**
|
|
* ## Update
|
|
* Handles doing subsequent updates for versions
|
|
*
|
|
* @param {Array} versions
|
|
* @param {Function} logInfo
|
|
* @returns {Promise<*>}
|
|
*/
|
|
update = function update(versions, logInfo) {
|
|
logInfo('Updating fixtures');
|
|
|
|
var ops = versions.reduce(function updateToVersion(ops, version) {
|
|
var tasks = versioning.getUpdateFixturesTasks(version, logInfo);
|
|
|
|
if (tasks && tasks.length > 0) {
|
|
ops.push(function runVersionTasks() {
|
|
logInfo('Updating fixtures to ', version);
|
|
return sequence(tasks, modelOptions, logInfo);
|
|
});
|
|
}
|
|
|
|
return ops;
|
|
}, []);
|
|
|
|
return sequence(ops, modelOptions, logInfo);
|
|
};
|
|
|
|
module.exports = update;
|