Migration module

The migration module allows to run controlled database initialization scrips. The default implementation is based on umzug.

Usage

Every file that follows the ^${services:name}-${env}-\\d+[\\w-]+\\.js$ pattern will be executed and a database record will be created to log the execution.

The locations to look for that pattern are the same as the configPaths use to start the application, take a look at the config module and the extension example.

Migration file format

module.exports = {
  up: base => new Promise((resolve, reject) => {
    base.impex
      .addHelpers(helpers)
      .import(helpers.insertCategory, 'migrations/dataCategories.json')
      .then(() => {
        resolve();
      })
      .catch(error => reject(error));
  }),
  down: base => new Promise((resolve, reject) => {
    base.logger.error('[migration] not implemented');
    reject(new Error('not implemented'));
  })
};