How to use umzug - 5 common examples

To help you get started, we’ve selected a few umzug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nylas-mail-lives / nylas-mail / packages / cloud-core / scripts / migrate-db.es6 View on Github external
async function activate() {
  // Perform migrations before starting sync
  const db = await DatabaseConnector.forShared();

  const umzug = new Umzug({
    storage: 'sequelize',
    storageOptions: {
      sequelize: db.sequelize,
      modelName: 'migration',
      tableName: 'migrations',
    },
    migrations: {
      path: `../migrations`,
      params: [db.sequelize.getQueryInterface(), db.sequelize],
      pattern: /^\d+[\w-]+\.es6$/,
    },
    logging: console.log,
  });

  return umzug;
}
github staticdeploy / staticdeploy / storage / src / migrate.ts View on Github external
extname(__filename)
                    );
                },
                set(this: SequelizeMeta, name: string) {
                    this.setDataValue("name", name.replace(".ts", ".js"));
                }
            }
        },
        {
            sequelize: sequelize,
            tableName: "SequelizeMeta",
            timestamps: false
        }
    );

    const umzug = new Umzug({
        storage: "sequelize",
        storageOptions: { model: SequelizeMeta },
        migrations: {
            params: [sequelize.getQueryInterface()],
            path: join(__dirname, "./migrations"),
            // Migration source files are named DD.ts, where D is a digit. When
            // they're compiled, they become DD.js. We want to only load those
            // files, and not other files such as *.d.ts ones
            pattern: /^\d{2}\.(js|ts)$/
        },
        logging: false
    });

    // Perform 'up' migrations
    await umzug.up();
}
github zalando / zappr / server / server.js View on Github external
async function start(port = nconf.get('APP_PORT'), opts = {
  metricsEnabled: nconf.get('METRICS_ENABLED'),
  metricsPort: nconf.get('METRICS_PORT')
}) {
  const umzug = new Umzug({
    storage: 'sequelize',
    logging: logger('migration', 'info'),
    migrations: {
      path: './migrations',
      pattern: /^\d+[\w-]+\.js$/,
      params: [db.queryInterface, Sequelize]
    },
    storageOptions: {
      // The configured instance of Sequelize.
      sequelize: db,
      // this one is actually undocumented
      schema: 'zappr_meta',
      // The name of the to be used model.
      // (not sure if we need this actually)
      modelName: 'SequelizeMeta',
      // The name of table to create if `model` option is not supplied
github sequelize / cli / src / core / migrator.js View on Github external
return Bluebird.try(() => {
    if (!(helpers.config.configFileExists() || args.url)) {
      helpers.view.error(
        'Cannot find "' + helpers.config.getConfigFile() +
        '". Have you run "sequelize init"?'
      );
      process.exit(1);
    }

    const sequelize = getSequelizeInstance();
    const migrator = new Umzug({
      storage: helpers.umzug.getStorage(type),
      storageOptions: helpers.umzug.getStorageOptions(type, { sequelize }),
      logging: helpers.view.log,
      migrations: {
        params: [sequelize.getQueryInterface(), Sequelize],
        path: helpers.path.getPath(type),
        pattern: /\.js$/,
        wrap: fun => {
          if (fun.length === 3) {
            return Bluebird.promisify(fun);
          } else {
            return fun;
          }
        }
      }
    });
github WhiteMinds / LiveAutoRecord / src / renderer / db / migrate.js View on Github external
class MigrationHack extends Migration {
    constructor (uniqueName, module, options = {}) {
      super(uniqueName + '.js', Object.assign({}, DefaultOptions, options))
      this.module = module
    }

    migration () {
      if (typeof this.options.migrations.customResolver === 'function') {
        return this.options.migrations.customResolver(this.path)
      }

      return this.module.default
    }
  }

  const umzug = new Umzug({
    storage: 'json',
    storageOptions: {
      path: path.join(UserDataPath, 'lar_umzug.json')
    },
    migrations: [
      new MigrationHack('00_Initial', require('./migrations/00_Initial')),
      new MigrationHack('01_ChangeColumn_Platform', require('./migrations/01_ChangeColumn_Platform')),
      new MigrationHack('02_ChangeColumns', require('./migrations/02_ChangeColumns')),
      new MigrationHack('03_RenameColumns_Timestamps', require('./migrations/03_RenameColumns_Timestamps')),
      new MigrationHack('04_CreateTable_RecordLog', require('./migrations/04_CreateTable_RecordLog')),
      new MigrationHack('05_AddColumn_File', require('./migrations/05_AddColumn_File'))
    ]
  })

  const logUmzugEvent = eventName => {
    return (name, migration) => {

umzug

Framework-agnostic migration tool for Node

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis

Popular umzug functions