How to use the migrate/lib/set.prototype function in migrate

To help you get started, we’ve selected a few migrate 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 locomote / node-migrate-orm2 / lib / migrate-patch.js View on Github external
module.exports = function (dsl, record, resume) {
  var Set = require('migrate/lib/set')
    , _ = require('lodash');

//Override node-migrate's Set.prototype.save to write to the Migrations table instead.
  Set.prototype.save = function(fn){
    this.emit('save');
    fn && fn();
  };

  //copied from Set in node-migrate
  /**
   * Get index of given migration in list of migrations
   *
   * @api private
   */

  function positionOfMigration(migrations, filename) {
    for(var i=0; i < migrations.length; ++i) {
      if (migrations[i].title == filename) return i;
    }
    return -1;
github locomote / node-migrate-orm2 / lib / migrate-patch.js View on Github external
//copied from Set in node-migrate
  /**
   * Get index of given migration in list of migrations
   *
   * @api private
   */

  function positionOfMigration(migrations, filename) {
    for(var i=0; i < migrations.length; ++i) {
      if (migrations[i].title == filename) return i;
    }
    return -1;
  }

  Set.prototype._migrate = function(direction, fn, migrationName){
    var self = this
      , migrations
      , migrationPos =  positionOfMigration(this.migrations, migrationName);

    resume.cursor(function(err, priorPosition){
      self.pos = (priorPosition || 0)

      if (!migrationName) {
        migrationPos = ((direction == 'up') ? self.migrations.length : 0);
      } else if (migrationPos == -1) {
        console.error("Could not find migration: " + migrationName);
        return;
      } else {
        self.pos = migrationPos;
      }

migrate

Abstract migration framework for node

MIT
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis