Skip to content

Commit

Permalink
fix(api): fix race condition on create migration
Browse files Browse the repository at this point in the history
A callback was placed not inside but after the callback which it belongs to. This
resulted in a very rarely occuring race condition when creating migrations without
an existing migration directory.

Fixes #376
  • Loading branch information
wzrdtales committed May 17, 2016
1 parent baabd7e commit 67a0f61
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,18 +584,16 @@ function executeCreateMigration(internals, config, callback) {
if (_assert(err, callback)) {

log.info(util.format('Created migration at %s', migration.path));
if (shouldCreateSqlFiles(internals, config)) {
createSqlFiles(internals, config, callback);
} else {
if (typeof(callback) === 'function') {
callback();
}
}
}
});
});

if (shouldCreateSqlFiles(internals, config)) {
createSqlFiles(internals, config, callback);
} else {
if (typeof(callback) === 'function') {

callback();
}
}
}

function shouldCreateSqlFiles( internals, config ) {
Expand Down

0 comments on commit 67a0f61

Please sign in to comment.