Skip to content
Browse files

fix ordering error on empty db. closes #51

  • Loading branch information...
1 parent be393aa commit 20340287c24776c67fef2becfff8cb2c409282da @kunklejr kunklejr committed
Showing with 10 additions and 2 deletions.
  1. +4 −0 CHANGELOG.md
  2. +5 −1 lib/migrator.js
  3. +1 −1 package.json
View
4 CHANGELOG.md
@@ -70,3 +70,7 @@ Fix:
- Use --migrations-dir option when specified #47
- Handle unique constraints in changeColumn() for postgres #46 (via @ryanmeador)
+## 0.2.5
+
+Fix:
+ - Fix randomly occuring migration sorting error on empty db #51
View
6 lib/migrator.js
@@ -22,7 +22,11 @@ function isIncludedInDown(migration, destination) {
}
function filterUp(allMigrations, completedMigrations, destination, count) {
- return allMigrations.sort()
+ var sortFn = function(a, b) {
+ return a.name.slice(0, a.name.indexOf('-')) - b.name.slice(0, b.name.indexOf('-'));
+ };
+
+ return allMigrations.sort(sortFn)
.filter(function(migration) {
var hasRun = completedMigrations.some(function(completedMigration) {
return completedMigration.name === migration.name;
View
2 package.json
@@ -11,7 +11,7 @@
"sqlite",
"mysql"
],
- "version": "0.2.4",
+ "version": "0.2.5",
"engines": {
"node": ">=0.6.0"
},

0 comments on commit 2034028

Please sign in to comment.
Something went wrong with that request. Please try again.