Skip to content

Commit

Permalink
feat: Migrate up/down with cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ivesdebruycker authored and mrfelton committed Jan 10, 2018
1 parent d0c26e6 commit ceeffd4
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,19 @@ program
.alias('up')
.description('Migrate to the given migration')
.action(function(to, options){
console.log('Migrating up to: "%s" [TODO]', to);
console.log('Migrating up to: "%s"', to);
var server = program.server || process.cwd() + '/server/server.js';
var app = require(path.resolve(process.cwd(), server));
app.models.Migration.migrate('up', to)
.then(function (res) {
console.log('Done.');
})
.catch(function (err) {
console.log(err);
})
.finally(function () {
process.exit();
});
}).on('--help', function() {
console.log(' Examples:');
console.log();
Expand All @@ -92,9 +102,19 @@ program
.alias('down')
.description('Rollback to the given migration')
.action(function(to, options){
console.log('Rolling back to: "%s" [TODO]', to);
console.log('Rolling back to: "%s"', to);
var server = program.server || process.cwd() + '/server/server.js';
var app = require(path.resolve(process.cwd(), server));
app.models.Migration.migrate('down', to)
.then(function (res) {
console.log('Done.');
})
.catch(function (err) {
console.log(err);
})
.finally(function () {
process.exit();
});
}).on('--help', function() {
console.log(' Examples:');
console.log();
Expand Down

0 comments on commit ceeffd4

Please sign in to comment.