Permalink
Browse files

Respect column length attribute.

  • Loading branch information...
1 parent 9737378 commit 0cfd9e25d95581002b85f0190a6c27ac8a3b0cb2 @mhuggins mhuggins committed Jun 7, 2012
Showing with 10 additions and 2 deletions.
  1. +4 −1 lib/driver/base.js
  2. +6 −1 lib/driver/pg.js
View
5 lib/driver/base.js
@@ -36,7 +36,10 @@ module.exports = Base = Class.extend({
},
createColumnDef: function(name, spec, options) {
- return [name, this.mapDataType(spec.type), this.createColumnConstraint(spec, options)].join(' ');
+ var type = this.mapDataType(spec.type);
+ var len = spec.length ? util.format('(%s)', spec.length) : '';
+ var constraint = this.createColumnConstraint(spec, options);
+ return [name, type, len, constraint].join(' ');
},
createMigrationsTable: function(callback) {
View
7 lib/driver/pg.js
@@ -11,6 +11,7 @@ var PgDriver = Base.extend({
this.connection = connection;
this.connection.connect();
},
+
startMigration: function(cb){
this.runSql('BEGIN;', function() { cb()});
},
@@ -20,8 +21,12 @@ var PgDriver = Base.extend({
},
createColumnDef: function(name, spec, options) {
- return [name, spec.autoIncrement ? '' : this.mapDataType(spec.type), this.createColumnConstraint(spec, options)].join(' ');
+ var type = spec.autoIncrement ? '' : this.mapDataType(spec.type);
+ var len = spec.length ? util.format('(%s)', spec.length) : '';
+ var constraint = this.createColumnConstraint(spec, options);
+ return [name, type, len, constraint].join(' ');
},
+
mapDataType: function(str) {
switch(str) {
case type.STRING:

0 comments on commit 0cfd9e2

Please sign in to comment.