Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / migrations / 2.0.51.js
index 7e94be9..0be8b1a 100644 (file)
@@ -10,267 +10,267 @@ 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 CHAT INTERNAL MESSAGES
-            migration.addColumn('chat_internal_messages', 'ChatInternalMessageId', {
-                type: Sequelize.INTEGER
-            });
-            migration.addColumn('chat_internal_messages', 'ChatGroupId', {
-                type: Sequelize.INTEGER
-            });
-            migration.query('ALTER TABLE `chat_internal_messages` \
+  up: function(queryInterface, Sequelize) {
+    return new BPromise(function(resolve, reject) {
+
+      var migration = new Migration(queryInterface);
+
+      //START CHAT INTERNAL MESSAGES
+      migration.addColumn('chat_internal_messages', 'ChatInternalMessageId', {
+        type: Sequelize.INTEGER
+      });
+      migration.addColumn('chat_internal_messages', 'ChatGroupId', {
+        type: Sequelize.INTEGER
+      });
+      migration.query('ALTER TABLE `chat_internal_messages` \
                 ADD CONSTRAINT `chat_internal_messages_ibfk_3` \
                 FOREIGN KEY (`ChatGroupId`) \
                 REFERENCES chat_groups(`id`) \
                 ON UPDATE CASCADE \
                 ON DELETE CASCADE');
-            //END CHAT INTERNAL MESSAGES
-
-            // START CHAT INTERACTIONS
-            migration.addColumn('chat_interactions', 'lastMsgDirection', {
-                type: Sequelize.ENUM('in', 'out'),
-                defaultValue: 'in',
-                allowNull: false
-            });
-            migration.addColumn('chat_interactions', 'lastMsgAt', {
-                type: Sequelize.DATE
-            });
-            // END CHAT INTERACTIONS
-
-            // START MAIL INTERACTIONS
-            migration.addColumn('mail_interactions', 'lastMsgDirection', {
-                type: Sequelize.ENUM('in', 'out'),
-                defaultValue: 'in',
-                allowNull: false
-            });
-            migration.addColumn('mail_interactions', 'lastMsgAt', {
-                type: Sequelize.DATE
-            });
-            // END MAIL INTERACTIONS
-
-            // START SMS INTERACTIONS
-            migration.addColumn('sms_interactions', 'lastMsgDirection', {
-                type: Sequelize.ENUM('in', 'out'),
-                defaultValue: 'in',
-                allowNull: false
-            });
-            migration.addColumn('sms_interactions', 'lastMsgAt', {
-                type: Sequelize.DATE
-            });
-            // END SMS INTERACTIONS
-
-            // START OPENCHANNEL INTERACTIONS
-            migration.addColumn('openchannel_interactions', 'lastMsgDirection', {
-                type: Sequelize.ENUM('in', 'out'),
-                defaultValue: 'in',
-                allowNull: false
-            });
-            migration.addColumn('openchannel_interactions', 'lastMsgAt', {
-                type: Sequelize.DATE
-            });
-            // END OPENCHANNEL INTERACTIONS
-
-            // START FAX INTERACTIONS
-            migration.addColumn('fax_interactions', 'lastMsgDirection', {
-                type: Sequelize.ENUM('in', 'out'),
-                defaultValue: 'in',
-                allowNull: false
-            });
-            migration.addColumn('fax_interactions', 'lastMsgAt', {
-                type: Sequelize.DATE
-            });
-            // END FAX INTERACTIONS
-
-            var channels = ['Chat', 'Mail', 'Sms', 'Openchannel'];
-            for (var i = 0; i < channels.length; i++) {
-              migration.query('UPDATE '+channels[i].toLowerCase()+'_interactions t1, (SELECT '+channels[i]+'InteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \
-                  FROM '+channels[i].toLowerCase()+'_messages \
-                  WHERE '+channels[i]+'InteractionId IS NOT NULL AND (direction=\'in\' OR (direction=\'out\' AND secret=0 AND UserId IS NOT NULL)) \
-                  GROUP BY '+channels[i]+'InteractionId) t2 SET t1.lastMsgDirection = t2.direction, t1.lastMsgAt = t2.createdAt WHERE t1.id = t2.'+channels[i]+'InteractionId;');
-            }
-
-            migration.query('UPDATE fax_interactions t1, (SELECT FaxInteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \
+      //END CHAT INTERNAL MESSAGES
+
+      // START CHAT INTERACTIONS
+      migration.addColumn('chat_interactions', 'lastMsgDirection', {
+        type: Sequelize.ENUM('in', 'out'),
+        defaultValue: 'in',
+        allowNull: false
+      });
+      migration.addColumn('chat_interactions', 'lastMsgAt', {
+        type: Sequelize.DATE
+      });
+      // END CHAT INTERACTIONS
+
+      // START MAIL INTERACTIONS
+      migration.addColumn('mail_interactions', 'lastMsgDirection', {
+        type: Sequelize.ENUM('in', 'out'),
+        defaultValue: 'in',
+        allowNull: false
+      });
+      migration.addColumn('mail_interactions', 'lastMsgAt', {
+        type: Sequelize.DATE
+      });
+      // END MAIL INTERACTIONS
+
+      // START SMS INTERACTIONS
+      migration.addColumn('sms_interactions', 'lastMsgDirection', {
+        type: Sequelize.ENUM('in', 'out'),
+        defaultValue: 'in',
+        allowNull: false
+      });
+      migration.addColumn('sms_interactions', 'lastMsgAt', {
+        type: Sequelize.DATE
+      });
+      // END SMS INTERACTIONS
+
+      // START OPENCHANNEL INTERACTIONS
+      migration.addColumn('openchannel_interactions', 'lastMsgDirection', {
+        type: Sequelize.ENUM('in', 'out'),
+        defaultValue: 'in',
+        allowNull: false
+      });
+      migration.addColumn('openchannel_interactions', 'lastMsgAt', {
+        type: Sequelize.DATE
+      });
+      // END OPENCHANNEL INTERACTIONS
+
+      // START FAX INTERACTIONS
+      migration.addColumn('fax_interactions', 'lastMsgDirection', {
+        type: Sequelize.ENUM('in', 'out'),
+        defaultValue: 'in',
+        allowNull: false
+      });
+      migration.addColumn('fax_interactions', 'lastMsgAt', {
+        type: Sequelize.DATE
+      });
+      // END FAX INTERACTIONS
+
+      var channels = ['Chat', 'Mail', 'Sms', 'Openchannel'];
+      for (var i = 0; i < channels.length; i++) {
+        migration.query('UPDATE ' + channels[i].toLowerCase() + '_interactions t1, (SELECT ' + channels[i] + 'InteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \
+                  FROM ' + channels[i].toLowerCase() + '_messages \
+                  WHERE ' + channels[i] + 'InteractionId IS NOT NULL AND (direction=\'in\' OR (direction=\'out\' AND secret=0 AND UserId IS NOT NULL)) \
+                  GROUP BY ' + channels[i] + 'InteractionId) t2 SET t1.lastMsgDirection = t2.direction, t1.lastMsgAt = t2.createdAt WHERE t1.id = t2.' + channels[i] + 'InteractionId;');
+      }
+
+      migration.query('UPDATE fax_interactions t1, (SELECT FaxInteractionId, MAX(id) AS messageid, ANY_VALUE(direction) AS direction, ANY_VALUE(createdAt) AS createdAt \
                 FROM fax_messages \
                 WHERE FaxInteractionId IS NOT NULL \
                 GROUP BY FaxInteractionId) t2 SET t1.lastMsgDirection = t2.direction, t1.lastMsgAt = t2.createdAt WHERE t1.id = t2.FaxInteractionId;');
 
-            // START SMS
-            migration.changeColumn('sms_accounts', 'type', {
-              type: Sequelize.ENUM('twilio', 'skebby', 'connectel')
-            });
-            // END SMS
+      // START SMS
+      migration.changeColumn('sms_accounts', 'type', {
+        type: Sequelize.ENUM('twilio', 'skebby', 'connectel')
+      });
+      // END SMS
 
-            // START VOICECALLREPORT
-            migration.addColumn('report_call', 'note', {
-                type: Sequelize.STRING
-            });
-            // END VOICECALLREPORT
+      // START VOICECALLREPORT
+      migration.addColumn('report_call', 'note', {
+        type: Sequelize.STRING
+      });
+      // END VOICECALLREPORT
 
-            // START CM
-            migration.addIndex('cm_contacts', ['phone'], 'phone');
-            migration.addIndex('cm_hopper_final', ['uniqueid'], 'uniqueid');
-            migration.addIndex('cm_hopper_history', ['uniqueid'], 'uniqueid');
-            // END CM
+      // START CM
+      migration.addIndex('cm_contacts', ['phone'], 'phone');
+      migration.addIndex('cm_hopper_final', ['uniqueid'], 'uniqueid');
+      migration.addIndex('cm_hopper_history', ['uniqueid'], 'uniqueid');
+      // END CM
 
-            //START VOICERECORDINGS
-            migration.addIndex('voice_recordings', ['uniqueid'], 'uniqueid');
-            //END VOICERECORDINGS
+      //START VOICERECORDINGS
+      migration.addIndex('voice_recordings', ['uniqueid'], 'uniqueid');
+      //END VOICERECORDINGS
 
-            //START REPORTMEMBER
-            migration.addIndex('report_member', ['membername', 'interface'], 'membername_interface');
-            //END REPORTMEMBER
+      //START REPORTMEMBER
+      migration.addIndex('report_member', ['membername', 'interface'], 'membername_interface');
+      //END REPORTMEMBER
 
-            //START USERS
-            migration.query('UPDATE users SET permissions=\'101,102,103,110,104,105,106,107,108,109,100\' WHERE permissions=\'101,102,103,104,105,106,107,108,109,100\'');
-            //END USERS
+      //START USERS
+      migration.query('UPDATE users SET permissions=\'101,102,103,110,104,105,106,107,108,109,100\' WHERE permissions=\'101,102,103,104,105,106,107,108,109,100\'');
+      //END USERS
 
-            // START DIALER
-            migration.query("DELETE FROM `voice_extensions` WHERE exten = 'xcally-motion-dialer';");
+      // START DIALER
+      migration.query("DELETE FROM `voice_extensions` WHERE exten = 'xcally-motion-dialer';");
 
-            migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `appdata`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '1', 'NoOp', '', '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-dialer', '1', 'NoOp', '', '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-dialer', '2', 'set', 'CDR(type)=dialer', '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-dialer', '2', 'set', 'CDR(type)=dialer', '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-dialer', '3', 'set', 'CALLERID(all)=${XMD-CALLERID}', '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-dialer', '3', 'set', 'CALLERID(all)=${XMD-CALLERID}', '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-dialer', '4', 'gotoif', '$[\"${XMD-AMD}\" != \"NONE\" ]?5:11', '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-dialer', '4', 'gotoif', '$[\"${XMD-AMD}\" != \"NONE\" ]?5:11', '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', '5', 'answer', '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', '5', 'answer', '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-dialer', '6', 'background', 'silence/1', '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-dialer', '6', 'background', 'silence/1', '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-dialer', '7', 'amd', '${XMD-AMDINITIALSILENCE},${XMD-AMDGREETING},${XMD-AMDAFTERGREETINGSILENCE},${XMD-AMDTOTALANALYSISTIME},${XMD-AMDMINWORDLENGTH},${XMD-AMDBETWEENWORDSSILENCE},${XMD-AMDMAXIMUMNUMBEROFWORDS},${XMD-AMDSILENCETHRESHOLD},${XMD-AMDMAXIMUMWORDLENGTH}', '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-dialer', '7', 'amd', '${XMD-AMDINITIALSILENCE},${XMD-AMDGREETING},${XMD-AMDAFTERGREETINGSILENCE},${XMD-AMDTOTALANALYSISTIME},${XMD-AMDMINWORDLENGTH},${XMD-AMDBETWEENWORDSSILENCE},${XMD-AMDMAXIMUMNUMBEROFWORDS},${XMD-AMDSILENCETHRESHOLD},${XMD-AMDMAXIMUMWORDLENGTH}', '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-dialer', '8', 'gotoif', '$[\"${AMDSTATUS}\" == \"HUMAN\" ]?11:9', '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-dialer', '8', 'gotoif', '$[\"${AMDSTATUS}\" == \"HUMAN\" ]?11:9', '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-dialer', '9', 'gotoif', '$[\"${AMDSTATUS}\" == \"NOTSURE\" ]?11:10', '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-dialer', '9', 'gotoif', '$[\"${AMDSTATUS}\" == \"NOTSURE\" ]?11:10', '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-dialer', '10', 'gotoif', '$[\"${AMDSTATUS}\" == \"MACHINE\" ]?14:11', '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-dialer', '10', 'gotoif', '$[\"${AMDSTATUS}\" == \"MACHINE\" ]?14:11', '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-dialer', '11', '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-dialer', '11', '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-dialer', '12', 'execif', '$[\"${XMD-QUEUE}\" != \"NONE\" ]?QUEUE(${XMD-QUEUE})', '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-dialer', '12', 'execif', '$[\"${XMD-QUEUE}\" != \"NONE\" ]?QUEUE(${XMD-QUEUE})', '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-dialer', '13', 'Execif', '$[\"${XMD-AGIAFTER}\" != \"NONE\" ]?AGI(${XMD-AGIAFTER})', '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-dialer', '13', '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', '14', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
-            //END DIALER
+      migration.query("INSERT INTO `voice_extensions` (`context`, `exten`, `priority`, `app`, `type`, `description`, `createdAt`, `updatedAt`) VALUES ('from-sip', 'xcally-motion-dialer', '14', 'hangup', 'system', 'dialer extensions auto generated', NOW(), NOW());");
+      //END DIALER
 
-            // START FINAL
-            migration.final(resolve);
-            // END FINAL
-        });
-    },
+      // START FINAL
+      migration.final(resolve);
+      // END FINAL
+    });
+  },
 
-    down: function(queryInterface, Sequelize) {
-        var migration = new Migration(queryInterface);
-    }
-};
+  down: function(queryInterface, Sequelize) {
+    var migration = new Migration(queryInterface);
+  }
+};
\ No newline at end of file