Skip to content

Feature: down all migrations one command and allow use db-migrate as module #281

@rkmax

Description

@rkmax

I have many migrations that represents all my database, when I run tests I use the migrations to recreate a test database in a known state usualy I pass something like

var exec = require('child_process').exec;
var Promise = require('bluebird');

function execAsync(cmd) {
  return new Promise(function(resolve, reject) {
    exec(cmd, function(err, stdout, stderr) {
      if (err) { reject(err); } else { resolve({stdout: stdout, stderr: stderr}); }
    });
  }
}
module.exports = {
  down: function() {
    return execAsync('db-migrate down -c 100');
  },
  up: function(down) {
     return Promise.resolve()
       .then(function() {
         if (down) { return this.down() }  else {
           return Promise.resolve();
         }
       }.bind(this))
       .then(function() {
          return execAsync('db-migrate up');
       });
  }
}

would be great if I can pass something like --all to the down command and if I can use db-migrate as module

  var migrate = require('db-migrate');

  ...
  return migrate.down({all: true}).then(function() { return migrate.up(); });

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions