Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
//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;
}