Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented renameColumn.

  • Loading branch information...
commit 88b8326339a596031db45edb3c105fea55448f26 1 parent 18bdffd
@akinnunen akinnunen authored
Showing with 5 additions and 7 deletions.
  1. +5 −7 lib/driver/mysql.js
View
12 lib/driver/mysql.js
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.