Skip to content

Commit

Permalink
Merge pull request sequelize#2135 from dizlexik/patch-1
Browse files Browse the repository at this point in the history
Update migrator logging
  • Loading branch information
sdepold committed Aug 13, 2014
2 parents 9b7d9ae + 511ef06 commit 1d024ba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = (function() {
path: __dirname + '/../migrations',
from: null,
to: null,
logging: console.log,
logging: this.sequelize.log.bind(this.sequelize),
filesFilter: /\.js$/
}, options || {});
};
Expand Down Expand Up @@ -45,25 +45,25 @@ module.exports = (function() {
}

if (migrations.length === 0) {
self.sequelize.log('There are no pending migrations.');
self.options.logging('There are no pending migrations.');
} else {
self.sequelize.log('Running migrations...');
self.options.logging('Running migrations...');
}

migrations.forEach(function(migration) {
var migrationTime;

chainer.add(migration, 'execute', [options], {
before: function(migration) {
self.sequelize.log(migration.filename);
self.options.logging(migration.filename);
migrationTime = process.hrtime();
},

after: function(migration) {
migrationTime = process.hrtime(migrationTime);
migrationTime = Math.round((migrationTime[0] * 1000) + (migrationTime[1] / 1000000));

self.sequelize.log('Completed in ' + migrationTime + 'ms');
self.options.logging('Completed in ' + migrationTime + 'ms');
},

success: function(migration, callback) {
Expand Down Expand Up @@ -194,7 +194,7 @@ module.exports = (function() {
var addMigration = function(filename) {
var migration = new Migration(self, filename);

self.sequelize.log('Adding migration script at ' + filename);
self.options.logging('Adding migration script at ' + filename);

chainer.add(migration, 'execute', [{ method: 'up' }], {
before: function(migration) {
Expand Down

0 comments on commit 1d024ba

Please sign in to comment.