This commit is contained in:
parent
85f8b6fd20
commit
48f6d0fccc
|
@ -2039,13 +2039,6 @@ INSERT INTO `pbx`.`prefix` (country, prefix)
|
|||
('fr', '0033'),
|
||||
('pt', '00351');
|
||||
|
||||
INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
|
||||
VALUES
|
||||
(1, 1010),
|
||||
(3, 1101),
|
||||
(5, 1102),
|
||||
(9, 1201);
|
||||
|
||||
INSERT INTO `vn`.`professionalCategory` (`id`, `description`)
|
||||
VALUES
|
||||
(1, 'employee'),
|
||||
|
@ -4005,9 +3998,7 @@ INSERT INTO pbx.queue (description, name, config)
|
|||
|
||||
INSERT IGNORE INTO pbx.queueMember
|
||||
SET queue = '1000',
|
||||
extension = '1010';
|
||||
extension = '1111';
|
||||
|
||||
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
|
||||
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
||||
|
||||
|
||||
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
|
|
@ -1,21 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `pbx`.`sip_isValid`(vExtension VARCHAR(255))
|
||||
BEGIN
|
||||
/**
|
||||
* Check if an extension has the correct format and
|
||||
* throws an exception if it hasn't.
|
||||
*
|
||||
* @param vExtension The extension
|
||||
*/
|
||||
DECLARE vIsValid BOOL;
|
||||
|
||||
SET vIsValid = vExtension IS NULL
|
||||
OR (vExtension REGEXP '^[0-9]{4}$'
|
||||
AND MOD(vExtension, 100) != 0);
|
||||
|
||||
IF NOT vIsValid THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'Extension format is invalid';
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,8 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_beforeInsert`
|
||||
BEFORE INSERT ON `sip`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL sip_isValid(NEW.extension);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,8 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `pbx`.`sip_beforeUpdate`
|
||||
BEFORE UPDATE ON `sip`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL sip_isValid(NEW.extension);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -23,7 +23,10 @@ BEGIN
|
|||
DELETE FROM pbx.queueMember
|
||||
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
|
||||
IF vNewQueue IS NOT NULL THEN
|
||||
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||
VALUES (vNewQueue, vExtension);
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -4,5 +4,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`worker_beforeInsert`
|
|||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
INSERT INTO pbx.sip
|
||||
SET user_id = NEW.id,
|
||||
extension = NEW.id;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
ALTER TABLE pbx.followme DROP FOREIGN KEY followme_ibfk_1;
|
||||
ALTER TABLE pbx.queueMember DROP FOREIGN KEY queueMember_ibfk_2;
|
||||
ALTER TABLE pbx.sipReg DROP FOREIGN KEY sipReg_ibfk_1;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tSipReg
|
||||
SELECT * FROM pbx.sipReg;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tOldSip
|
||||
SELECT * FROM pbx.sip;
|
||||
|
||||
TRUNCATE TABLE pbx.sipReg;
|
||||
|
||||
TRUNCATE TABLE pbx.sip;
|
||||
|
||||
INSERT INTO pbx.sip (user_id, extension)
|
||||
SELECT w.id, w.id FROM vn.worker w;
|
||||
|
||||
REPLACE INTO pbx.sipReg
|
||||
SELECT tsr.* FROM tSipReg tsr
|
||||
JOIN vn.worker w ON tsr.userId = w.id;
|
||||
|
||||
UPDATE pbx.queueMember qm
|
||||
JOIN tOldSip tos ON tos.extension = qm.extension
|
||||
LEFT JOIN pbx.sip s ON s.user_id = tos.user_id
|
||||
SET qm.extension = s.extension;
|
||||
|
||||
ALTER TABLE pbx.followme
|
||||
ADD CONSTRAINT followme_ibfk_1
|
||||
FOREIGN KEY (extension) REFERENCES pbx.sip(extension);
|
||||
|
||||
ALTER TABLE pbx.queueMember
|
||||
ADD CONSTRAINT queueMember_ibfk_2
|
||||
FOREIGN KEY (extension) REFERENCES pbx.sip(extension);
|
||||
|
||||
ALTER TABLE pbx.sipReg
|
||||
ADD CONSTRAINT sipReg_ibfk_1
|
||||
FOREIGN KEY (userId) REFERENCES pbx.sip(user_id);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tSipReg;
|
||||
DROP TEMPORARY TABLE IF EXISTS tOldSip;
|
Loading…
Reference in New Issue