Built motion from commit b33b832.|1.0.17
[motion.git] / server / models / square_project.js
index 7c28c70..4179c7f 100644 (file)
@@ -1,11 +1,13 @@
 'use strict';
 
+var _ = require('lodash');
+
 module.exports = function(sequelize, DataTypes) {
 
   var SquareProject = sequelize.define('SquareProject', {
     name: {
       type: DataTypes.STRING,
-      unique: true,
+      unique: 'name',
       allowNull: false,
       validate: {
         notEmpty: true
@@ -14,15 +16,23 @@ module.exports = function(sequelize, DataTypes) {
     description: DataTypes.STRING,
     notes: DataTypes.TEXT,
     preproduction: {
-      type: DataTypes.TEXT,
-      length: 'long'
+      type: DataTypes.BLOB('long'),
+      get: function() {
+        if (this.getDataValue('preproduction')) {
+          return _.toString(this.getDataValue('preproduction'));
+        }
+      }
     },
     production: {
-      type: DataTypes.TEXT,
-      length: 'long'
+      type: DataTypes.BLOB('long'),
+      get: function() {
+        if (this.getDataValue('production')) {
+          return _.toString(this.getDataValue('production'));
+        }
+      }
     }
   }, {
-    tableName: 'square_projects',
+    tableName: 'square_projects'
   });
 
   return SquareProject;