Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,22 @@ program
});

program
.command('migrate <to>')
.command('migrate [to]')
.alias('up')
.description('Migrate to the given migration')
.action(function(to, options){
console.log('Migrating up to: "%s"', to);
console.log('Migrating up to: "%s"', to || 'all');
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.');
process.exit();
})
.catch(function (err) {
console.log(err);
})
.finally(function () {
process.exit();
});
})
}).on('--help', function() {
console.log(' Examples:');
console.log();
Expand All @@ -98,23 +97,22 @@ program
});

program
.command('rollback <to>')
.command('rollback [to]')
.alias('down')
.description('Rollback to the given migration')
.action(function(to, options){
console.log('Rolling back to: "%s"', to);
console.log('Rolling back to: "%s"', to || 'all');
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.');
process.exit();
})
.catch(function (err) {
console.log(err);
})
.finally(function () {
process.exit();
});
})
}).on('--help', function() {
console.log(' Examples:');
console.log();
Expand Down
4 changes: 3 additions & 1 deletion lib/models/migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
},
"indexes": {
"name_index": {
"name": 1
"keys": {
"name": 1
}
}
},
"methods": {
Expand Down