Migrator

core/migrate~ Migrator

Configuration upgrade utility class.

This class load a series of Migration classes following the 'head' property of the head migration. It is used to run the migrations that are before or equal to a given target version on a configuration object.

Constructor

new Migrator(head)

Source:
Parameters:
Name Type Description
head module:core/migrate~Migration The latest migration class to be loaded.

Methods

getLatestVersion() → {string}

Get the latest target version among all loaded migrations.
Source:
Returns:
Type:
string
The latest target version.

isOudated(version) → {boolean}

Check if the given version is the latest target version.
Source:
Parameters:
Name Type Description
version string A version number to be checked.
Returns:
Type:
boolean
true if the given version is the latest version.

migrate(config, toVersion, callback) → {Object}

Upgrade a given configuration to a given target version.
Source:
Parameters:
Name Type Default Description
config Object The configuration object to be upgraded.
toVersion string null Target version number.
callback function null An optional callback function called when each migration is done. It takes the original version of the configuration object and the current migration version as parameters.
Returns:
Type:
Object
The upgrade configuration object.