Skip to content

Commit

Permalink
Implemented renameColumn.
Browse files Browse the repository at this point in the history
  • Loading branch information
akinnunen committed Feb 27, 2013
1 parent 18bdffd commit 88b8326
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/driver/mysql.js
Expand Up @@ -134,14 +134,12 @@ var MysqlDriver = Base.extend({
},

renameColumn: function(tableName, oldColumnName, newColumnName, callback) {

var sql = "select column_type from information_schema.columns where table_name = 'files' and column_name = 'otsikko';"

this.runSql(sql, function(foo) {
console.log(foo);
var self = this, columnTypeSql = util.format("SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '%s' AND COLUMN_NAME = '%s'", tableName, oldColumnName);
this.all(columnTypeSql, function(err, result) {
var columnType = result[0].COLUMN_TYPE;
var alterSql = util.format("ALTER TABLE %s CHANGE %s %s %s", tableName, oldColumnName, newColumnName, columnType);
self.runSql(alterSql, callback);
});


},

changeColumn: function(tableName, columnName, columnSpec, callback) {
Expand Down

0 comments on commit 88b8326

Please sign in to comment.