diff --git a/lib/migrate.js b/lib/migrate.js index 1fc776b..0406cb6 100644 --- a/lib/migrate.js +++ b/lib/migrate.js @@ -115,12 +115,8 @@ function downMigrations (set, lastRunIndex, toIndex) { */ function positionOfMigration (migrations, title) { - let lastTimestamp - for (let i = 0; i < migrations.length; ++i) { - lastTimestamp = migrations[i].timestamp ? i : lastTimestamp - if (migrations[i].title === title) return i - } + const requestedMigration = migrations.find((migration) => migration.title.includes(title)); + const indexOfRequestedMigration = migrations.indexOf(requestedMigration); - // If titled migration was missing use last timestamped - return lastTimestamp + return indexOfRequestedMigration; }