Browse files

Merge pull request #78 from milyoni/master

Lazily require migration
  • Loading branch information...
2 parents adb4e8c + 7c22dbc commit 0c52bae55d3030b744a7c4de75030d25fa1dfa24 @kunklejr kunklejr committed Feb 27, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/migration.js
View
12 lib/migration.js
@@ -75,13 +75,17 @@ Migration = function() {
this.name = Migration.parseName(this.path);
this.date = parseDate(this.name);
this.title = parseTitle(this.name);
-
- var migrationFile = require(this.path);
- this._up = migrationFile.up;
- this._down = migrationFile.down;
}
};
+Migration.prototype._up = function() {
+ return require(this.path).up.apply(this, arguments);
+};
+
+Migration.prototype._down = function() {
+ return require(this.path).down.apply(this, arguments);
+};
+
Migration.prototype.write = function(callback) {
fs.writeFile(this.path, migrationTemplate, callback);
};

0 comments on commit 0c52bae

Please sign in to comment.