Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 2ae3f02cab37ec304e2ee0d6cce8ecd2441d26d5 1 parent 22bae59
@aprobus aprobus authored
View
4 lib/driver/base.js
@@ -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
6 lib/driver/mysql.js
@@ -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
2  lib/migrator.js
@@ -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
3  package.json
@@ -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",
Please sign in to comment.
Something went wrong with that request. Please try again.