diff --git a/lib/utils.js b/lib/utils.js index 77e21a2..94a02a8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -51,7 +51,7 @@ utils.buildSchema = function(obj) { attribute.type = val; } - var type = utils.sqlTypeCast(attribute.autoIncrement ? 'SERIAL' : attribute.type); + var type = utils.sqlTypeCast(attribute.autoIncrement ? 'SERIAL' : attribute.type, attribute.size ? attribute.size : null); var nullable = attribute.notNull && 'NOT NULL'; var unique = attribute.unique && 'UNIQUE'; @@ -198,7 +198,7 @@ utils.toSqlDate = function(date) { * Cast waterline types to Postgresql data types */ -utils.sqlTypeCast = function(type) { +utils.sqlTypeCast = function(type, size) { switch (type.toLowerCase()) { case 'serial': return 'SERIAL'; @@ -208,6 +208,7 @@ utils.sqlTypeCast = function(type) { return 'BIGSERIAL'; case 'string': + return 'character varying(' + (size ? size : 255) + ')'; // sets the character-varying limit case 'text': case 'mediumtext': case 'longtext':