lib/archivist/migration.js
function migrateVaultToVersion(vault, targetVersion, cb) {
	var preventMigrate = mage.core.config.get(['archivist', 'vaults', vault.name, 'config', 'preventMigrate'], false);
	if (preventMigrate) {
		logger.warning(`Vault ${vault.name} has disabled migrate operation (skipping)`);
		return cb();
	}

	if (typeof vault.getMigrations !== 'function') {
		logger.warning('Cannot migrate on vault', vault.name, '(skipping).');
		return cb();
	}

	// load applied versions

	vault.getMigrations(function (error, appliedVersions) {
		if (error) {
			return cb(error);
		}

		getAvailableMigrations(vault.name, function (error, available) {
			if (error) {
				return cb(error);
			}

			logger.debug('Available versions with migration paths:', available);

			var migration = calculateMigration(targetVersion, available, appliedVersions);

			logger.debug('Calculated migration path:', migration);

			if (migration.versions.length === 0) {
				logger.notice('No migrations to apply on vault', vault.name);
				return cb();
			}

			if (migration.direction === 'down') {
				migrateDown(vault, migration.versions, cb);
			} else {
				migrateUp(vault, migration.versions, cb);
			}
		});
	});
}
function migrateVaultToVersion(vault, targetVersion, cb) {
	var preventMigrate = mage.core.config.get(['archivist', 'vaults', vault.name, 'config', 'preventMigrate'], false);
	if (preventMigrate) {
		logger.warning(`Vault ${vault.name} has disabled migrate operation (skipping)`);
		return cb();
	}

	if (typeof vault.getMigrations !== 'function') {
		logger.warning('Cannot migrate on vault', vault.name, '(skipping).');
		return cb();
	}

	// load applied versions

	vault.getMigrations(function (error, appliedVersions) {
		if (error) {
			return cb(error);
		}

		getAvailableMigrations(vault.name, function (error, available) {
			if (error) {
				return cb(error);
			}

			logger.debug('Available versions with migration paths:', available);

			var migration = calculateMigration(targetVersion, available, appliedVersions);

			logger.debug('Calculated migration path:', migration);

			if (migration.versions.length === 0) {
				logger.notice('No migrations to apply on vault', vault.name);
				return cb();
			}

			if (migration.direction === 'down') {
				migrateDown(vault, migration.versions, cb);
			} else {
				migrateUp(vault, migration.versions, cb);
			}
		});
	});
}
function migrateVaultToVersion ( vault , targetVersion , cb ) { var preventMigrate = mage . core . config . get ( [ 'archivist' , 'vaults' , vault . name , 'config' , 'preventMigrate' ] , false ) ; if ( preventMigrate ) { logger . warning ( ` ${ vault . name } ` ) ; return cb ( ) ; } if ( typeof vault . getMigrations !== 'function' ) { logger . warning ( 'Cannot migrate on vault' , vault . name , '(skipping).' ) ; return cb ( ) ; } // load applied versions vault . getMigrations ( function ( error , appliedVersions ) { if ( error ) { return cb ( error ) ; } getAvailableMigrations ( vault . name , function ( error , available ) { if ( error ) { return cb ( error ) ; } logger . debug ( 'Available versions with migration paths:' , available ) ; var migration = calculateMigration ( targetVersion , available , appliedVersions ) ; logger . debug ( 'Calculated migration path:' , migration ) ; if ( migration . versions . length === 0 ) { logger . notice ( 'No migrations to apply on vault' , vault . name ) ; return cb ( ) ; } if ( migration . direction === 'down' ) { migrateDown ( vault , migration . versions , cb ) ; } else { migrateUp ( vault , migration . versions , cb ) ; } } ) ; } ) ; }
This analyzes the strategy for migrating a single vault to a given version. Then executes that
strategy.

@param {Object}   vault         The vault to migrate
@param {string}   targetVersion The version to migrate to
@param {Function} cb            A callback to be called after migration of this vault completes
This analyzes the strategy for migrating a single vault to a given version . Then executes that strategy .