diff --git a/src/migrate/index.js b/src/migrate/index.js index fa4c016e..d02d7e1b 100644 --- a/src/migrate/index.js +++ b/src/migrate/index.js @@ -169,10 +169,12 @@ export default class Migrator { return this._isLocked(trx) .then(isLocked => { if (isLocked) { - throw new Error("Migration table is are already locked"); + throw new Error("Migration table is already locked"); } }) .then(() => this._lockMigrations(trx)); + }).catch(err => { + throw new LockError(err.message); }); } @@ -185,9 +187,6 @@ export default class Migrator { // Run a batch of current migrations, in sequence. _runBatch(migrations, direction) { return this._getLock() - .catch(err => { - throw new LockError(err.message); - }) .then(() => Promise.all(_.map(migrations, this._validateMigrationStructure, this))) .then(() => this._latestBatchNumber()) .then(batchNo => { diff --git a/test/integration/migrate/index.js b/test/integration/migrate/index.js index ab2ac9c6..4ed924ad 100644 --- a/test/integration/migrate/index.js +++ b/test/integration/migrate/index.js @@ -153,7 +153,7 @@ module.exports = function(knex) { }); }) .catch(function(error) { - expect(error).to.have.property('message', 'Migration table is are already locked'); + expect(error).to.have.property('message', 'Migration table is already locked'); return knex('knex_migrations_lock').select('*'); }) .then(function(data) {