diff --git a/lib/index.js b/lib/index.js index d2180479..abfee28b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -115,8 +115,9 @@ KnexMigrator.prototype.init = function init(options) { } }) .then(function () { - // CASE: re-run init and e.g. one migration was added to the init folder. - if (skippedTasks.length || skipInitCompletion) { + // CASE: you can disale init completion (that means, knex-migrator does not insert the existing + // migration scripts + if (skipInitCompletion) { return Promise.resolve(); } @@ -142,6 +143,7 @@ KnexMigrator.prototype.init = function init(options) { let filesToMigrateTo = utils.readTasks(versionPath) || []; return Promise.each(filesToMigrateTo, function (fileToMigrateTo) { + // CASE: check if migration exists, do not insert twice return transacting('migrations') .where('name', fileToMigrateTo.name) .then(function (migrationExists) {