Built motion from commit db94841.|2.5.3
[motion2.git] / server / migrations / 2.5.0.js
index ed8c1c4..5f4bd45 100644 (file)
@@ -155,163 +155,152 @@ module.exports = {
 
                        var migration = new Migration(queryInterface);
 
-                       //START voice_queues
-                       migration.addColumn('voice_queues', 'dialNoSuchNumberMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialNoSuchNumberRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+                       // START whatsapp
+                       migration.query('CREATE TABLE `whatsapp_accounts` (' +
+                               ' `id` int(11) NOT NULL AUTO_INCREMENT,' +
+                               ' `name` varchar(255) NOT NULL,' +
+                               ' `key` varchar(255) NOT NULL,' +
+                               ' `remote` varchar(255) NOT NULL,' +
+                               ' `token` varchar(255) DEFAULT NULL,' +
+                               ' `phone` varchar(255) DEFAULT NULL,' +
+                               ' `type` enum(\'twilio\') DEFAULT NULL,' +
+                               ' `accountSid` varchar(255) DEFAULT NULL,' +
+                               ' `authToken` varchar(255) DEFAULT NULL,' +
+                               ' `notificationTemplate` text,' +
+                               ' `notificationSound` tinyint(1) DEFAULT \'0\',' +
+                               ' `notificationShake` tinyint(1) DEFAULT \'0\',' +
+                               ' `waitForTheAssignedAgent` int(11) DEFAULT \'10\',' +
+                               ' `queueTransfer` tinyint(1) DEFAULT \'0\',' +
+                               ' `queueTransferTimeout` int(11) DEFAULT \'300\',' +
+                               ' `agentTransfer` tinyint(1) DEFAULT \'0\',' +
+                               ' `agentTransferTimeout` int(11) DEFAULT \'300\',' +
+                               ' `mandatoryDispositionPauseId` int(11) DEFAULT NULL,' +
+                               ' `mandatoryDisposition` tinyint(1) DEFAULT \'0\',' +
+                               ' `description` varchar(255) DEFAULT NULL,' +
+                               ' `createdAt` datetime NOT NULL,' +
+                               ' `updatedAt` datetime NOT NULL,' +
+                               ' `ListId` int(11) DEFAULT NULL,' +
+                               ' PRIMARY KEY (`id`),' +
+                               ' UNIQUE KEY `name` (`name`),' +
+                               ' KEY `mandatoryDispositionPauseId` (`mandatoryDispositionPauseId`),' +
+                               ' KEY `ListId` (`ListId`),' +
+                               ' CONSTRAINT `whatsapp_accounts_ibfk_1` FOREIGN KEY (`mandatoryDispositionPauseId`) REFERENCES `tools_pauses` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,' +
+                               ' CONSTRAINT `whatsapp_accounts_ibfk_2` FOREIGN KEY (`ListId`) REFERENCES `cm_lists` (`id`) ON DELETE SET NULL ON UPDATE CASCADE' +
+                               ') ENGINE=InnoDB DEFAULT CHARSET=utf8;');
+                         
+            migration.addColumn('tools_dispositions', 'WhatsappAccountId', {
+                type: Sequelize.INTEGER
+            });
 
-                       migration.addColumn('voice_queues', 'dialDropMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialDropRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+            migration.addColumn('tools_canned_answers', 'WhatsappAccountId', {
+                type: Sequelize.INTEGER
+                       });
+                       
+                       migration.addColumn('users', 'whatsappPause', {
+                type: Sequelize.BOOLEAN,
+                       defaultValue: false
+            });
 
-                       migration.addColumn('voice_queues', 'dialAbandonedMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialAbandonedRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
-                       });
+            migration.addColumn('users', 'whatsappCapacity', {
+                type: Sequelize.BOOLEAN,
+                       defaultValue: false
+                       });
+                      
+                       migration.query('ALTER TABLE tools_dispositions ADD CONSTRAINT `tools_dispositions_ibfk_7` FOREIGN KEY (`WhatsappAccountId`) REFERENCES `whatsapp_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE');                      
+                       migration.query('ALTER TABLE tools_dispositions ADD CONSTRAINT `name_whatsapp` UNIQUE KEY (`name`,`WhatsappAccountId`)');
+            migration.query('ALTER TABLE tools_canned_answers ADD CONSTRAINT `tools_canned_answers_ibfk_6` FOREIGN KEY (`WhatsappAccountId`) REFERENCES `whatsapp_accounts` (`id`) ON DELETE SET NULL ON UPDATE CASCADE');
+                                               
+                       migration.query('UPDATE users SET permissions=\'101,102,103,113,110,104,105,106,107,108,109,100,111,114\' WHERE role=\'agent\' AND permissions=\'101,102,103,110,104,105,106,107,108,109,100,111\'');
+                       // END whatsapp
 
-                       migration.addColumn('voice_queues', 'dialMachineMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
-                       });
-                       migration.addColumn('voice_queues', 'dialMachineRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
+                       // START chat_interactions
+                       migration.addColumn('chat_interactions', 'vidaooSessionId', {
+                               type: Sequelize.TEXT
                        });
 
-                       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
+                       // START chat_websites
+            migration.addColumn('chat_websites', 'vidaooEscalation', {
+                type: Sequelize.BOOLEAN,
+                defaultValue: false
+            });
+            
+            migration.addColumn('chat_websites', 'vidaooApiKey', {
+                type: Sequelize.STRING
+            });
+                       // END chat_websites
+
+                       // START voice_recordings
+                       migration.addColumn('voice_recordings', 'location', {
+                               type: Sequelize.TEXT
                        });
-                       migration.addColumn('campaigns', 'dialAbandonedMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
+                       migration.addColumn('voice_recordings', 'transcribeName', {
+                               type: Sequelize.STRING
                        });
-                       migration.addColumn('campaigns', 'dialAbandonedRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
+                       migration.addColumn('voice_recordings', 'transcribeStatus', {
+                               type: Sequelize.STRING,
+                               defaultValue: 'NEW'
                        });
-                       migration.addColumn('campaigns', 'dialMachineMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
+                       migration.addColumn('voice_recordings', 'fileUri', {
+                               type: Sequelize.TEXT
                        });
-                       migration.addColumn('campaigns', 'dialMachineRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
+                       migration.addColumn('voice_recordings', 'fileText', {
+                               type: Sequelize.TEXT
                        });
-                       migration.addColumn('campaigns', 'dialAgentRejectMaxRetry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 3
+                       migration.addColumn('voice_recordings', 'failureReason', {
+                               type: Sequelize.TEXT
                        });
-                       migration.addColumn('campaigns', 'dialAgentRejectRetryFrequency', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 150
+                       migration.addColumn('voice_recordings', 'sentiment', {
+                               type: Sequelize.STRING
                        });
-                       //END campaigns            
-
-                       //START cm_hopper
-                       migration.addColumn('cm_hopper', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('voice_recordings', 'sPositive', {
+                               type: Sequelize.FLOAT
                        });
-                       migration.addColumn('cm_hopper', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('voice_recordings', 'sNegative', {
+                               type: Sequelize.FLOAT
                        });
-                       migration.addColumn('cm_hopper', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('voice_recordings', 'sNeutral', {
+                               type: Sequelize.FLOAT
                        });
-                       migration.addColumn('cm_hopper', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('voice_recordings', 'sMixed', {
+                               type: Sequelize.FLOAT
                        });
-                       migration.addColumn('cm_hopper', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('voice_recordings', 'tempSentiment', {
+                               type: Sequelize.BOOLEAN
                        });
-                       //END cm_hopper
+                       // END voice_recordings
 
-                       //START cm_hopper_final
-                       migration.addColumn('cm_hopper_final', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       // START settings
+                       migration.addColumn('settings', 'transcribe', {
+                               type: Sequelize.BOOLEAN
                        });
-                       migration.addColumn('cm_hopper_final', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'automaticTranscribe', {
+                               type: Sequelize.BOOLEAN
                        });
-                       migration.addColumn('cm_hopper_final', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'transcribeAccountId', {
+                               type: Sequelize.INTEGER
                        });
-                       migration.addColumn('cm_hopper_final', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'transcribeRegion', {
+                               type: Sequelize.STRING
                        });
-                       migration.addColumn('cm_hopper_final', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'sentiment', {
+                               type: Sequelize.BOOLEAN
                        });
-                       //END cm_hopper_final
-
-                       //START cm_hopper_history
-                       migration.addColumn('cm_hopper_history', 'countnosuchnumberretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'automaticSentiment', {
+                               type: Sequelize.BOOLEAN
                        });
-                       migration.addColumn('cm_hopper_history', 'countdropretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'sentimentAccountId', {
+                               type: Sequelize.INTEGER
                        });
-                       migration.addColumn('cm_hopper_history', 'countabandonedretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'sentimentRegion', {
+                               type: Sequelize.STRING
                        });
-                       migration.addColumn('cm_hopper_history', 'countmachineretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'language', {
+                               type: Sequelize.STRING
                        });
-                       migration.addColumn('cm_hopper_history', 'countagentrejectretry', {
-                               type: Sequelize.INTEGER,
-                               defaultValue: 0
+                       migration.addColumn('settings', 'bucket', {
+                               type: Sequelize.STRING
                        });
-                       //END cm_hopper_history
+                       // END settings
 
                        // START FINAL
                        migration.final(resolve);