Skip to content

Commit 67a0f61

Browse files
committed
fix(api): fix race condition on create migration
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
1 parent baabd7e commit 67a0f61

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

api.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -584,18 +584,16 @@ function executeCreateMigration(internals, config, callback) {
584584
if (_assert(err, callback)) {
585585

586586
log.info(util.format('Created migration at %s', migration.path));
587+
if (shouldCreateSqlFiles(internals, config)) {
588+
createSqlFiles(internals, config, callback);
589+
} else {
590+
if (typeof(callback) === 'function') {
591+
callback();
592+
}
593+
}
587594
}
588595
});
589596
});
590-
591-
if (shouldCreateSqlFiles(internals, config)) {
592-
createSqlFiles(internals, config, callback);
593-
} else {
594-
if (typeof(callback) === 'function') {
595-
596-
callback();
597-
}
598-
}
599597
}
600598

601599
function shouldCreateSqlFiles( internals, config ) {

0 commit comments

Comments
 (0)