Permalink
Browse files

Added fix so migration records are being added in the correct format

  • Loading branch information...
1 parent 22bae59 commit 2ae3f02cab37ec304e2ee0d6cce8ecd2441d26d5 @aprobus aprobus committed Oct 30, 2012
Showing with 13 additions and 2 deletions.
  1. +4 −0 lib/driver/base.js
  2. +6 −0 lib/driver/mysql.js
  3. +1 −1 lib/migrator.js
  4. +2 −1 package.json
View
@@ -193,6 +193,10 @@ module.exports = Base = Class.extend({
}
},
+ addMigrationRecord: function (name, callback) {
+ this.runSql('INSERT INTO migrations (name, run_on) VALUES (?, ?)', [name, new Date()], callback);
+ },
+
startMigration: function(cb){cb()},
endMigration: function(cb){cb()},
// sql, params, callback
View
@@ -1,4 +1,5 @@
var util = require('util');
+var moment = require('moment');
var mysql = require('mysql');
var Base = require('./base');
var type = require('../data_type');
@@ -101,6 +102,11 @@ var MysqlDriver = Base.extend({
this.runSql(sql, callback);
},
+ addMigrationRecord: function (name, callback) {
+ var formattedDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
+ this.runSql('INSERT INTO migrations (name, run_on) VALUES (?, ?)', [name, formattedDate], callback);
+ },
+
runSql: function() {
this.connection.query.apply(this.connection, arguments);
},
View
@@ -67,7 +67,7 @@ Migrator.prototype = {
}
callback(err);
}
- this.driver.runSql('INSERT INTO migrations (name, run_on) VALUES (?, ?)', [migration.name, new Date()], onComplete);
+ this.driver.addMigrationRecord(migration.name, onComplete);
},
deleteMigrationRecord: function(migration, callback) {
View
@@ -37,7 +37,8 @@
"optimist": "~0.3.0",
"async": "~0.1.15",
"semver": "~1.0.14",
- "mkdirp": "~0.3.4"
+ "mkdirp": "~0.3.4",
+ "moment": "~1.7.2"
},
"devDependencies": {
"vows": "~0.6.2",

0 comments on commit 2ae3f02

Please sign in to comment.