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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/migration/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ MigrationManager.prototype.create = function (config) {
* @return {String} The generated JavaScript source code.
*/
MigrationManager.prototype.generateMigration = function (config) {
var content = 'exports.name = ' + JSON.stringify(config.name) + ';\n\n';
content += 'exports.db = ' + JSON.stringify(config.db) + ';\n\n';
var content = '"use strict";\nexports.name = ' + JSON.stringify(config.name) + ';\n\n';
content += 'exports.up = function (db) {\n // @todo implementation\n};\n\n';
content += 'exports.down = function (db) {\n // @todo implementation\n};\n\n';
return content;
Expand All @@ -103,10 +102,8 @@ MigrationManager.prototype.list = function () {
this.listApplied()
]);
})
.then(function (args) {
var available = args[0],
applied = args[1],
pending = [],
.spread(function (available, applied) {
var pending = [],
totalAvailable = available.length,
totalApplied = applied.length,
item, other, i, j, found;
Expand All @@ -126,6 +123,10 @@ MigrationManager.prototype.list = function () {
}
}
return pending;
})
.then(function (migrations) {
migrations.sort();
return migrations;
});
};

Expand Down Expand Up @@ -226,6 +227,7 @@ MigrationManager.prototype.down = function (limit) {
return item.name;
})
.then(function (items) {
items.sort();
return items.reverse();
})
.filter(function (item, index) {
Expand Down Expand Up @@ -302,4 +304,5 @@ MigrationManager.prototype.revertMigration = function (name) {
})
.return(result);
});
};
};

4 changes: 4 additions & 0 deletions test/migration/manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ describe("Migration Manager", function () {
return this.manager.list()
.then(function (migrations) {
migrations.length.should.equal(2);
migrations.should.eql([
'm20140318_014253_my_test_migration',
'm20140318_014300_my_second_test_migration'
]);
});
})
});
Expand Down