-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes behavior when last run migration file is missing
- Loading branch information
1 parent
dbcf228
commit a3766db
Showing
1 changed file
with
6 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ function migrate (set, direction, migrationName, fn) { | |
} | ||
|
||
lastRunIndex = positionOfMigration(set.migrations, set.lastRun) | ||
|
||
migrations = (direction === 'up' ? upMigrations : downMigrations)(set, lastRunIndex, toIndex) | ||
|
||
function next (migration) { | ||
|
@@ -114,8 +115,12 @@ function downMigrations (set, lastRunIndex, toIndex) { | |
*/ | ||
|
||
function positionOfMigration (migrations, title) { | ||
var lastTimestamp | ||
for (var i = 0; i < migrations.length; ++i) { | ||
lastTimestamp = migrations[i].timestamp ? i : lastTimestamp | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wesleytodd
Author
Collaborator
|
||
if (migrations[i].title === title) return i | ||
} | ||
return -1 | ||
|
||
// If titled migration was missing use last timestamped | ||
return lastTimestamp | ||
} |
Now this function never returns "-1" and line 12 in this file relies on it... Basically that change completely broke the function that suppose to return position of migration for given title but it always fails to do so.