Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / migrations / 2.0.49.js
index 7002bab..16a38af 100644 (file)
@@ -10,201 +10,201 @@ var logger = require('../config/logger')('migration');
 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 SMS
-            migration.addColumn('sms_accounts', 'smsMethod', {
-                type: Sequelize.ENUM('basic', 'classic', 'classic+')
-            });
-            migration.addColumn('sms_accounts', 'username', {
-                type: Sequelize.STRING
-            });
-            migration.addColumn('sms_accounts', 'password', {
-                type: Sequelize.STRING
-            });
-            migration.addColumn('sms_accounts', 'senderString', {
-                type: Sequelize.STRING
-            });
-            migration.addColumn('sms_accounts', 'deliveryReport', {
-              type: Sequelize.BOOLEAN,
-              defaultValue: false
-            });
-            // END SMS
-
-            // START USERS
-            migration.addColumn('users', 'allowmessenger', {
-                type: Sequelize.BOOLEAN,
-                defaultValue: true
-            });
-
-            migration.addColumn('users', 'phoneBarOutboundProxy', {
-                type: Sequelize.STRING
-            });
-            //END USERS
-
-            // START CHATWEBSITE
-            migration.addColumn('chat_websites', 'offlineMessageSubject', {
-              type: Sequelize.STRING,
-              defaultValue: 'New offline message from websiteName'
-            });
-
-            migration.addColumn('chat_websites', 'offlineMessageBody', {
-              type: Sequelize.STRING,
-              defaultValue: 'You received a new offline message from websiteName. Here you can find the details of the request:'
-            });
-            // END CHATWEBSITE
-
-            // START AGI AFTER
-            migration.addColumn('voice_queues', 'dialQueueProject2', {
-                type: Sequelize.STRING
-            });
-
-            migration.addColumn('voice_queues', 'dialAgiAfterHangupClient', {
-                type: Sequelize.BOOLEAN,
-                defaultValue: false
-            });
-
-            migration.addColumn('voice_queues', 'dialAgiAfterHangupAgent', {
-                type: Sequelize.BOOLEAN,
-                defaultValue: false
-            });
-
-            migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-dialer' AND `priority`= 11");
-
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '11', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '12', 'Hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-
-            migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 4");
-
-            migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 5");
-
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '4', 'Execif', '$[\"${XMD-AGI}\" != \"NONE\" ]?AGI(${XMD-AGI})', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '5', 'dial', '${XMD-DIALCHANNEL},${XMD-DIALTIMEOUT},${XMD-DIALOPTIONS},${XMD-DIALURL}', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '6', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-
-            migration.addColumn('cm_hopper_final', 'agiafterat', {
-                type: Sequelize.DATE
-            });
-
-            // END AGI AFTER
-
-            // 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 SMS
+      migration.addColumn('sms_accounts', 'smsMethod', {
+        type: Sequelize.ENUM('basic', 'classic', 'classic+')
+      });
+      migration.addColumn('sms_accounts', 'username', {
+        type: Sequelize.STRING
+      });
+      migration.addColumn('sms_accounts', 'password', {
+        type: Sequelize.STRING
+      });
+      migration.addColumn('sms_accounts', 'senderString', {
+        type: Sequelize.STRING
+      });
+      migration.addColumn('sms_accounts', 'deliveryReport', {
+        type: Sequelize.BOOLEAN,
+        defaultValue: false
+      });
+      // END SMS
+
+      // START USERS
+      migration.addColumn('users', 'allowmessenger', {
+        type: Sequelize.BOOLEAN,
+        defaultValue: true
+      });
+
+      migration.addColumn('users', 'phoneBarOutboundProxy', {
+        type: Sequelize.STRING
+      });
+      //END USERS
+
+      // START CHATWEBSITE
+      migration.addColumn('chat_websites', 'offlineMessageSubject', {
+        type: Sequelize.STRING,
+        defaultValue: 'New offline message from websiteName'
+      });
+
+      migration.addColumn('chat_websites', 'offlineMessageBody', {
+        type: Sequelize.STRING,
+        defaultValue: 'You received a new offline message from websiteName. Here you can find the details of the request:'
+      });
+      // END CHATWEBSITE
+
+      // START AGI AFTER
+      migration.addColumn('voice_queues', 'dialQueueProject2', {
+        type: Sequelize.STRING
+      });
+
+      migration.addColumn('voice_queues', 'dialAgiAfterHangupClient', {
+        type: Sequelize.BOOLEAN,
+        defaultValue: false
+      });
+
+      migration.addColumn('voice_queues', 'dialAgiAfterHangupAgent', {
+        type: Sequelize.BOOLEAN,
+        defaultValue: false
+      });
+
+      migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-dialer' AND `priority`= 11");
+
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '11', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '12', 'Hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+
+      migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 4");
+
+      migration.query("DELETE FROM `voice_extensions` WHERE `exten`='xcally-motion-preview' AND `priority`= 5");
+
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '4', 'Execif', '$[\"${XMD-AGI}\" != \"NONE\" ]?AGI(${XMD-AGI})', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '5', 'dial', '${XMD-DIALCHANNEL},${XMD-DIALTIMEOUT},${XMD-DIALOPTIONS},${XMD-DIALURL}', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-preview', '6', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+
+      migration.addColumn('cm_hopper_final', 'agiafterat', {
+        type: Sequelize.DATE
+      });
+
+      // END AGI AFTER
+
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
+
+  down: function(queryInterface, Sequelize) {
+    var migration = new Migration(queryInterface);
+  }
+};
\ No newline at end of file