Skip to content

Conversation

@rahulbile
Copy link
Contributor

No description provided.

@rahulbile rahulbile requested a review from mrfelton December 29, 2016 11:51
* @param {String} [record] Record the migration runtime to database.
* @param {Function} [cb] Callback function.
*/
Migration.migrateByName = function(name, record, cb) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be removed @rahulbile as I don't think it makes sense to default the name to an empty string.

* @param {Function} [cb] Callback function.
*/
Migration.migrateByName = function(name, record, cb) {
name = name || '';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think record should be an optional property - you need to add something like this just above this line:

    if (typeof cb === 'undefined' && typeof record === 'function') {
      cb = record
      record = false
    }

try {
require(scriptPath).up(Migration.app, function(err) {
if (err) {
Migration.log.error(name, 'error:');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest combining these 2 lines so that only one error message is logged if there is an error. Perhaps make the error message a little more descriptive too:

Migration.log.error(`Error running migration script ${name}:`, err);

Migration.create({
name: name,
runDtTm: new Date()
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing a call to cb() after a successful migration.

}
});
} catch (err) {
Migration.log.error('Error running migration', name);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets combine these 2 lines into a single log message too @rahulbile

Migration.create({
name: name,
runDtTm: new Date()
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to move to below this if block since we want to call it regardless of the value of record

@mrfelton mrfelton merged commit 72bff5a into fullcube:master Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants