Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / migrations / 2.5.2.js
index 0ec5ab4..af4a0b1 100644 (file)
@@ -5,339 +5,339 @@ var util = require('util');
 
 var logger = require('../config/logger')('migration');
 
-var Sequence = function () {};
+var Sequence = function() {};
 
-Sequence.prototype.enqueue = function (fn) {
-       this.tail = this.tail ? this.tail.finally(fn) : fn();
+Sequence.prototype.enqueue = function(fn) {
+  this.tail = this.tail ? this.tail.finally(fn) : fn();
 };
 
-var Migration = function (queryInterface) {
-       this.queryInterface = queryInterface;
-       this.sequence = new Sequence();
+var Migration = function(queryInterface) {
+  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 () {
-                               logger.info('Changed column %s in table %s', column, table);
-                       })
-                       .catch(function (err) {
-                               logger.info(JSON.stringify(err));
-                       });
-       });
+Migration.prototype.changeColumn = function(table, column, type) {
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .changeColumn(table, column, type)
+      .then(function() {
+        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 () {
-                               logger.info('Added column %s to %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() {
+        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 () {
-                               logger.info('table dropped %s', 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() {
+        logger.info('table dropped %s', table);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
-Migration.prototype.addIndex = function (table, column, options) {
-       var _this = this;
-       this.sequence.enqueue(function () {
-               return _this.queryInterface
-                       .addIndex(table, column, {
-                               indexName: options.indexName,
-                               indicesType: options.indicesType
-                       })
-                       .then(function () {
-                               logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType);
-                       })
-                       .catch(function (err) {
-                               logger.info(JSON.stringify(err));
-                       });
-       });
+Migration.prototype.addIndex = function(table, column, options) {
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .addIndex(table, column, {
+        indexName: options.indexName,
+        indicesType: options.indicesType
+      })
+      .then(function() {
+        logger.info('addIndex %s %s %s [%s]', table, column.join(','), options.indexName, options.indicesType);
+      })
+      .catch(function(err) {
+        logger.info(JSON.stringify(err));
+      });
+  });
 };
 
-Migration.prototype.removeIndex = function (table, indexName) {
-       var _this = this;
-       this.sequence.enqueue(function () {
-               return _this.queryInterface
-                       .removeIndex(table, indexName)
-                       .then(function () {
-                               logger.info('removeIndex %s %s', table, indexName);
-                       })
-                       .catch(function (err) {
-                               logger.info(JSON.stringify(err));
-                       });
-       });
+Migration.prototype.removeIndex = function(table, indexName) {
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .removeIndex(table, indexName)
+      .then(function() {
+        logger.info('removeIndex %s %s', table, 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 () {
-                               logger.info('query %s', sql);
-                       })
-                       .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() {
+        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 () {
-                               logger.info('Removed column %s from %s', column, table);
-                       })
-                       .catch(function (err) {
-                               logger.info(
-                                       util.inspect(err, {
-                                               showHidden: false,
-                                               depth: null
-                                       })
-                               );
-                       });
-       });
+Migration.prototype.removeColumn = function(table, column) {
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .removeColumn(table, column)
+      .then(function() {
+        logger.info('Removed column %s from %s', column, table);
+      })
+      .catch(function(err) {
+        logger.info(
+          util.inspect(err, {
+            showHidden: false,
+            depth: null
+          })
+        );
+      });
+  });
 };
 
-Migration.prototype.renameColumn = function (table, oldColumn, newColumn) {
-       var _this = this;
-       this.sequence.enqueue(function () {
-               return _this.queryInterface
-                       .renameColumn(table, oldColumn, newColumn)
-                       .then(function () {
-                               logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
-                       })
-                       .catch(function (err) {
-                               logger.info(
-                                       util.inspect(err, {
-                                               showHidden: false,
-                                               depth: null
-                                       })
-                               );
-                       });
-       });
+Migration.prototype.renameColumn = function(table, oldColumn, newColumn) {
+  var _this = this;
+  this.sequence.enqueue(function() {
+    return _this.queryInterface
+      .renameColumn(table, oldColumn, newColumn)
+      .then(function() {
+        logger.info('Renamed column from %s to %s on %s', oldColumn, newColumn, table);
+      })
+      .catch(function(err) {
+        logger.info(
+          util.inspect(err, {
+            showHidden: false,
+            depth: null
+          })
+        );
+      });
+  });
 };
 
-Migration.prototype.final = function (resolve) {
-       this.sequence.enqueue(function () {
-               return resolve();
-       });
+Migration.prototype.final = function(resolve) {
+  this.sequence.enqueue(function() {
+    return resolve();
+  });
 };
 
 module.exports = {
-       up: function (queryInterface, Sequelize) {
-               return new BPromise(function (resolve) {
-                       
-                       var migration = new Migration(queryInterface);  
+  up: function(queryInterface, Sequelize) {
+    return new BPromise(function(resolve) {
 
-                       // START whatsapp
-                       migration.query('ALTER TABLE whatsapp_accounts ENCRYPTION=\'Y\';');
-                       migration.query('ALTER TABLE whatsapp_interactions ENCRYPTION=\'Y\';');
-                       migration.query('ALTER TABLE whatsapp_messages ENCRYPTION=\'Y\';');
-                       migration.query('ALTER TABLE report_whatsapp_queue ENCRYPTION=\'Y\';');
-                       // END whatsapp
+      var migration = new Migration(queryInterface);
 
-                       // START cloud_providers
-                       migration.query('ALTER TABLE cloud_providers ENCRYPTION=\'Y\';');
-                       // END cloud_providers
+      // START whatsapp
+      migration.query('ALTER TABLE whatsapp_accounts ENCRYPTION=\'Y\';');
+      migration.query('ALTER TABLE whatsapp_interactions ENCRYPTION=\'Y\';');
+      migration.query('ALTER TABLE whatsapp_messages ENCRYPTION=\'Y\';');
+      migration.query('ALTER TABLE report_whatsapp_queue ENCRYPTION=\'Y\';');
+      // END whatsapp
 
-                       // START voice_extensions
-            migration.query('ALTER TABLE voice_extensions DROP FOREIGN KEY voice_extensions_ibfk_7');
-            migration.query('ALTER TABLE voice_extensions DROP INDEX voice_extensions_ibfk_7');
-            migration.query('ALTER TABLE voice_extensions ADD CONSTRAINT voice_extensions_ibfk_7 FOREIGN KEY (VoicePrefixId) REFERENCES voice_prefixes(id) ON UPDATE CASCADE ON DELETE CASCADE');
-                       // END  voice_extensions
-                       
-                       //START voice_queues
-                       migration.addColumn('voice_queues', 'dialNoSuchNumberMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialNoSuchNumberRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+      // START cloud_providers
+      migration.query('ALTER TABLE cloud_providers ENCRYPTION=\'Y\';');
+      // END cloud_providers
 
-                       migration.addColumn('voice_queues', 'dialDropMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialDropRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+      // START voice_extensions
+      migration.query('ALTER TABLE voice_extensions DROP FOREIGN KEY voice_extensions_ibfk_7');
+      migration.query('ALTER TABLE voice_extensions DROP INDEX voice_extensions_ibfk_7');
+      migration.query('ALTER TABLE voice_extensions ADD CONSTRAINT voice_extensions_ibfk_7 FOREIGN KEY (VoicePrefixId) REFERENCES voice_prefixes(id) ON UPDATE CASCADE ON DELETE CASCADE');
+      // END  voice_extensions
 
-                       migration.addColumn('voice_queues', 'dialAbandonedMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialAbandonedRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+      //START voice_queues
+      migration.addColumn('voice_queues', 'dialNoSuchNumberMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('voice_queues', 'dialNoSuchNumberRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
 
-                       migration.addColumn('voice_queues', 'dialMachineMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialMachineRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+      migration.addColumn('voice_queues', 'dialDropMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('voice_queues', 'dialDropRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
 
-                       migration.addColumn('voice_queues', 'dialAgentRejectMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialAgentRejectRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       //END voice_queues
-                       
-                       //START campaigns
-                       migration.addColumn('campaigns', 'dialNoSuchNumberMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('campaigns', 'dialNoSuchNumberRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       migration.addColumn('campaigns', 'dialDropMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('campaigns', 'dialDropRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       migration.addColumn('campaigns', 'dialAbandonedMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('campaigns', 'dialAbandonedRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       migration.addColumn('campaigns', 'dialMachineMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('campaigns', 'dialMachineRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       migration.addColumn('campaigns', 'dialAgentRejectMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('campaigns', 'dialAgentRejectRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
-                       //END campaigns            
+      migration.addColumn('voice_queues', 'dialAbandonedMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('voice_queues', 'dialAbandonedRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
 
-                       //START cm_hopper
-                       migration.addColumn('cm_hopper', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       //END cm_hopper
+      migration.addColumn('voice_queues', 'dialMachineMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('voice_queues', 'dialMachineRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
 
-                       //START cm_hopper_final
-                       migration.addColumn('cm_hopper_final', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_final', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_final', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_final', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_final', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       //END cm_hopper_final
+      migration.addColumn('voice_queues', 'dialAgentRejectMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('voice_queues', 'dialAgentRejectRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      //END voice_queues
 
-                       //START cm_hopper_history
-                       migration.addColumn('cm_hopper_history', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_history', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_history', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_history', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       migration.addColumn('cm_hopper_history', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
-                       });
-                       //END cm_hopper_history
+      //START campaigns
+      migration.addColumn('campaigns', 'dialNoSuchNumberMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('campaigns', 'dialNoSuchNumberRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      migration.addColumn('campaigns', 'dialDropMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('campaigns', 'dialDropRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      migration.addColumn('campaigns', 'dialAbandonedMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('campaigns', 'dialAbandonedRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      migration.addColumn('campaigns', 'dialMachineMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('campaigns', 'dialMachineRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      migration.addColumn('campaigns', 'dialAgentRejectMaxRetry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 3
+      });
+      migration.addColumn('campaigns', 'dialAgentRejectRetryFrequency', {
+        type: Sequelize.INTEGER,
+        defaultValue: 150
+      });
+      //END campaigns            
 
-                       // START FINAL
-                       migration.final(resolve);
-                       // END FINAL
-               });
-       },
+      //START cm_hopper
+      migration.addColumn('cm_hopper', 'countnosuchnumberretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper', 'countdropretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper', 'countabandonedretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper', 'countmachineretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper', 'countagentrejectretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      //END cm_hopper
 
-       down: function (queryInterface, Sequelize) {
-               // var migration = new Migration(queryInterface);
-       }
+      //START cm_hopper_final
+      migration.addColumn('cm_hopper_final', 'countnosuchnumberretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_final', 'countdropretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_final', 'countabandonedretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_final', 'countmachineretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_final', 'countagentrejectretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      //END cm_hopper_final
+
+      //START cm_hopper_history
+      migration.addColumn('cm_hopper_history', 'countnosuchnumberretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_history', 'countdropretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_history', 'countabandonedretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_history', 'countmachineretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      migration.addColumn('cm_hopper_history', 'countagentrejectretry', {
+        type: Sequelize.INTEGER,
+        defaultValue: 0
+      });
+      //END cm_hopper_history
+
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
+
+  down: function(queryInterface, Sequelize) {
+    // var migration = new Migration(queryInterface);
+  }
 };
\ No newline at end of file