Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / migrations / 2.0.44.js
index c24c95d..09546ae 100644 (file)
@@ -8,240 +8,240 @@ var util = require('util');
 var Sequence = function() {};
 
 Sequence.prototype.enqueue = function(fn) {
-    this.tail = this.tail ? this.tail.finally(fn) : fn();
+  this.tail = this.tail ? this.tail.finally(fn) : fn();
 };
 
 var Migration = function(queryInterface) {
-    this.queryInterface = queryInterface;
-    this.sequence = new Sequence();
+  this.queryInterface = queryInterface;
+  this.sequence = new Sequence();
 };
 
 Migration.prototype.changeColumn = function(table, column, type) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .changeColumn(table, column, type)
-            .then(function(res) {
-                logger.info('Changed column %s in table %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .changeColumn(table, column, type)
+      .then(function(res) {
+        logger.info('Changed column %s in table %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.addColumn = function(table, column, type) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .addColumn(table, column, type)
-            .then(function(res) {
-                logger.info('Added column %s to %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .addColumn(table, column, type)
+      .then(function(res) {
+        logger.info('Added column %s to %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.dropTable = function(table) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface
-            .dropTable(table, {
-                force: true
-            })
-            .then(function(res) {
-                logger.info('table dropped %s', table);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .dropTable(table, {
+        force: true
+      })
+      .then(function(res) {
+        logger.info('table dropped %s', table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.addIndex = function(table, column, indexName) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.addIndex(table, column, {
-                indexName: indexName
-            })
-            .then(function(res) {
-                logger.info('addIndex %s %s %s', table, column.join(','), indexName);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.addIndex(table, column, {
+        indexName: indexName
+      })
+      .then(function(res) {
+        logger.info('addIndex %s %s %s', table, column.join(','), indexName);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.query = function(sql) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.sequelize.query(sql)
-            .then(function(res) {
-                logger.info('query %s', sql);
-            })
-            .catch(function(err) {
-                logger.info(JSON.stringify(err));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.sequelize.query(sql)
+      .then(function(res) {
+        logger.info('query %s', sql);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
 Migration.prototype.removeColumn = function(table, column) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return _this.queryInterface.removeColumn(table, column)
-            .then(function(res) {
-                logger.info('Removed column %s from %s', column, table);
-            })
-            .catch(function(err) {
-                logger.info(util.inspect(err, {
-                    showHidden: false,
-                    depth: null
-                }));
-            });
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface.removeColumn(table, column)
+      .then(function(res) {
+        logger.info('Removed column %s from %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(util.inspect(err, {
+          showHidden: false,
+          depth: null
+        }));
+      });
+  });
 };
 
 Migration.prototype.final = function(resolve) {
-    var _this = this;
-    this.sequence.enqueue(function() {
-        return resolve();
-    });
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return resolve();
+  });
 };
 
 module.exports = {
-    up: function(queryInterface, Sequelize) {
-        return new BPromise(function(resolve, reject) {
-            var migration = new Migration(queryInterface);
-
-            // START CHATWEBSITE
-            migration.addColumn('chat_websites', 'closingQuestion', {
-              type: Sequelize.STRING,
-              defaultValue: 'Do you want to close the interaction?'
-            });
-            // END CHATWEBSITE
-
-            // START CHAT INTERACTIONS
-            migration.addColumn('chat_interactions', 'read1stAt', {
-              type: Sequelize.DATE
-            });
-            // END CHAT INTERACTIONS
-
-            // START CHAT MESSAGES
-            migration.addColumn('chat_messages', 'readAt', {
-              type: Sequelize.DATE
-            });
-            // END CHAT MESSAGES
-
-            // START FAX INTERACTIONS
-            migration.addColumn('fax_interactions', 'read1stAt', {
-              type: Sequelize.DATE
-            });
-            // END FAX INTERACTIONS
-
-            // START FAX MESSAGES
-            migration.addColumn('fax_messages', 'readAt', {
-              type: Sequelize.DATE
-            });
-            // END FAX MESSAGES
-
-            // START OPENCHANNEL INTERACTIONS
-            migration.addColumn('openchannel_interactions', 'read1stAt', {
-              type: Sequelize.DATE
-            });
-            migration.addColumn('openchannel_interactions', 'threadId', {
-              type: Sequelize.STRING
-            });
-            migration.addColumn('openchannel_interactions', 'externalUrl', {
-              type: Sequelize.STRING
-            });
-            // END OPENCHANNEL INTERACTIONS
-
-            // START OPENCHANNEL MESSAGES
-            migration.addColumn('openchannel_messages', 'readAt', {
-              type: Sequelize.DATE
-            });
-            // END OPENCHANNEL MESSAGES
-
-            // START MAIL INTERACTIONS
-            migration.addColumn('mail_interactions', 'read1stAt', {
-              type: Sequelize.DATE
-            });
-            migration.addColumn('mail_interactions', 'substatus', {
-              type: Sequelize.STRING(60)
-            });
-            migration.addColumn('mail_interactions', 'substatusAt', {
-              type: Sequelize.DATE
-            });
-            // END MAIL INTERACTIONS
-
-            // START MAIL MESSAGES
-            migration.addColumn('mail_messages', 'readAt', {
-              type: Sequelize.DATE
-            });
-            // END MAIL MESSAGES
-
-            // START SMS INTERACTIONS
-            migration.addColumn('sms_interactions', 'read1stAt', {
-              type: Sequelize.DATE
-            });
-            // END SMS INTERACTIONS
-
-            // START SMS MESSAGES
-            migration.addColumn('sms_messages', 'readAt', {
-              type: Sequelize.DATE
-            });
-            // END SMS MESSAGES
-
-            // START DISPOSITIONS
-            migration.changeColumn('chat_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.changeColumn('fax_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.changeColumn('openchannel_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.changeColumn('sms_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.changeColumn('voice_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.query('ALTER TABLE chat_dispositions add UNIQUE INDEX nameAndAccount (name, ChatAccountId)');
-            migration.query('ALTER TABLE fax_dispositions add UNIQUE INDEX nameAndAccount (name, FaxAccountId)');
-            migration.query('ALTER TABLE openchannel_dispositions add UNIQUE INDEX nameAndAccount (name, OpenchannelAccountId)');
-            migration.query('ALTER TABLE sms_dispositions add UNIQUE INDEX nameAndAccount (name, SmsAccountId)');
-            migration.query('ALTER TABLE voice_dispositions add UNIQUE INDEX nameAndAccount (name, ListId)');
-            migration.changeColumn('mail_dispositions', 'name', {
-              type: Sequelize.STRING,
-              unique: 'nameAndAccount',
-              allowNull: false
-            });
-            migration.query('ALTER TABLE mail_dispositions DROP INDEX name');
-            migration.query('ALTER TABLE mail_dispositions add UNIQUE INDEX nameAndAccount (name, MailAccountId)');
-            // END DISPOSITIONS
-
-            // START FINAL
-            migration.final(resolve);
-            // END FINAL
-        });
-    },
-
-    down: function(queryInterface, Sequelize) {
-        var migration = new Migration(queryInterface);
-    }
-};
+  up: function(queryInterface, Sequelize) {
+    return new BPromise(function(resolve, reject) {
+      var migration = new Migration(queryInterface);
+
+      // START CHATWEBSITE
+      migration.addColumn('chat_websites', 'closingQuestion', {
+        type: Sequelize.STRING,
+        defaultValue: 'Do you want to close the interaction?'
+      });
+      // END CHATWEBSITE
+
+      // START CHAT INTERACTIONS
+      migration.addColumn('chat_interactions', 'read1stAt', {
+        type: Sequelize.DATE
+      });
+      // END CHAT INTERACTIONS
+
+      // START CHAT MESSAGES
+      migration.addColumn('chat_messages', 'readAt', {
+        type: Sequelize.DATE
+      });
+      // END CHAT MESSAGES
+
+      // START FAX INTERACTIONS
+      migration.addColumn('fax_interactions', 'read1stAt', {
+        type: Sequelize.DATE
+      });
+      // END FAX INTERACTIONS
+
+      // START FAX MESSAGES
+      migration.addColumn('fax_messages', 'readAt', {
+        type: Sequelize.DATE
+      });
+      // END FAX MESSAGES
+
+      // START OPENCHANNEL INTERACTIONS
+      migration.addColumn('openchannel_interactions', 'read1stAt', {
+        type: Sequelize.DATE
+      });
+      migration.addColumn('openchannel_interactions', 'threadId', {
+        type: Sequelize.STRING
+      });
+      migration.addColumn('openchannel_interactions', 'externalUrl', {
+        type: Sequelize.STRING
+      });
+      // END OPENCHANNEL INTERACTIONS
+
+      // START OPENCHANNEL MESSAGES
+      migration.addColumn('openchannel_messages', 'readAt', {
+        type: Sequelize.DATE
+      });
+      // END OPENCHANNEL MESSAGES
+
+      // START MAIL INTERACTIONS
+      migration.addColumn('mail_interactions', 'read1stAt', {
+        type: Sequelize.DATE
+      });
+      migration.addColumn('mail_interactions', 'substatus', {
+        type: Sequelize.STRING(60)
+      });
+      migration.addColumn('mail_interactions', 'substatusAt', {
+        type: Sequelize.DATE
+      });
+      // END MAIL INTERACTIONS
+
+      // START MAIL MESSAGES
+      migration.addColumn('mail_messages', 'readAt', {
+        type: Sequelize.DATE
+      });
+      // END MAIL MESSAGES
+
+      // START SMS INTERACTIONS
+      migration.addColumn('sms_interactions', 'read1stAt', {
+        type: Sequelize.DATE
+      });
+      // END SMS INTERACTIONS
+
+      // START SMS MESSAGES
+      migration.addColumn('sms_messages', 'readAt', {
+        type: Sequelize.DATE
+      });
+      // END SMS MESSAGES
+
+      // START DISPOSITIONS
+      migration.changeColumn('chat_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.changeColumn('fax_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.changeColumn('openchannel_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.changeColumn('sms_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.changeColumn('voice_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.query('ALTER TABLE chat_dispositions add UNIQUE INDEX nameAndAccount (name, ChatAccountId)');
+      migration.query('ALTER TABLE fax_dispositions add UNIQUE INDEX nameAndAccount (name, FaxAccountId)');
+      migration.query('ALTER TABLE openchannel_dispositions add UNIQUE INDEX nameAndAccount (name, OpenchannelAccountId)');
+      migration.query('ALTER TABLE sms_dispositions add UNIQUE INDEX nameAndAccount (name, SmsAccountId)');
+      migration.query('ALTER TABLE voice_dispositions add UNIQUE INDEX nameAndAccount (name, ListId)');
+      migration.changeColumn('mail_dispositions', 'name', {
+        type: Sequelize.STRING,
+        unique: 'nameAndAccount',
+        allowNull: false
+      });
+      migration.query('ALTER TABLE mail_dispositions DROP INDEX name');
+      migration.query('ALTER TABLE mail_dispositions add UNIQUE INDEX nameAndAccount (name, MailAccountId)');
+      // END DISPOSITIONS
+
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
+
+  down: function(queryInterface, Sequelize) {
+    var migration = new Migration(queryInterface);
+  }
+};
\ No newline at end of file