Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration Errors - Display filename of of failed migration #2272

Merged
merged 1 commit into from Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/migrate/index.js
Expand Up @@ -35,6 +35,10 @@ export default class Migrator {
constructor(knex) {
this.knex = knex
this.config = this.setConfig(knex.client.config.migrations);

this._activeMigration = {
fileName: null
}
}

// Migrators to the latest configuration.
Expand Down Expand Up @@ -225,6 +229,7 @@ export default class Migrator {
.tap(() => this._freeLock(trx))
.catch(error => {
let cleanupReady = Promise.resolve();
helpers.warn(`migration file "${this._activeMigration.fileName}" failed`)

if (error instanceof LockError) {
// If locking error do not free the lock.
Expand All @@ -235,7 +240,7 @@ export default class Migrator {
'table: ' + this._getLockTableName()
);
} else {
helpers.warn(`migrations failed with error: ${error.message}`)
helpers.warn(`migration failed with error: ${error.message}`)
// If the error was not due to a locking issue, then remove the lock.
cleanupReady = this._freeLock(trx);
}
Expand Down Expand Up @@ -336,6 +341,7 @@ export default class Migrator {
const log = [];
each(migrations, (migration) => {
const name = migration;
this._activeMigration.fileName = name;
migration = require(directory + '/' + name);

// We're going to run each of the migrations in the current "up".
Expand Down