Browse files

added "migration" event

  • Loading branch information...
1 parent 491c432 commit 54b0b798a15602bf28463d3bc6e8c07f114d667c @tj committed Apr 22, 2011
Showing with 18 additions and 0 deletions.
  1. +1 −0 lib/set.js
  2. +17 −0 test/test.migrate.js
View
1 lib/set.js
@@ -146,6 +146,7 @@ Set.prototype._migrate = function(direction, fn){
return;
}
+ self.emit('migration', migration, direction);
migration[direction](function(err){
next(err, migrations.shift());
});
View
17 test/test.migrate.js
@@ -120,9 +120,26 @@ function testMigrationEvents() {
next();
});
+ var migrations = []
+ , expectedMigrations = [
+ 'add guy ferrets'
+ , 'add girl ferrets'
+ , 'add emails'
+ , 'add dogs'
+ , 'adjust emails'];
+
+ set.on('migration', function(migration, direction){
+ migrations.push(migration.title);
+ direction.should.be.a('string');
+ });
+
set.up(function(){
db.pets[0].email.should.equal('tobi@lb.com');
+ migrations.should.eql(expectedMigrations);
+
+ migrations = [];
set.down(function(){
+ migrations.should.eql(expectedMigrations.reverse());
assertNoPets();
});
});

0 comments on commit 54b0b79

Please sign in to comment.