MT#33031 New table reseller_preferences + triggers

New table reseller_preferences inside provisioning created.
The new table is liked to the already existing provisioning.voip_reseller_preferences.
This commit includes the trigger in order to reflect changes from
provisioning.voip_reseller_preferences into provisioning.reseller_preferences.

Change-Id: I4a5e36813a30d902a817b2545c80c668cbf9663b
mr11.4
Alessio Garzi 2 years ago
parent b8294a0189
commit be1b44ea45

@ -0,0 +1,7 @@
USE kamailio;
drop table reseller_preferences;
drop trigger voip_resellerpref_crepl_trig;
drop trigger voip_resellerpref_urepl_trig;
drop trigger voip_resellerpref_drepl_trig;

@ -0,0 +1,41 @@
SET AUTOCOMMIT=0;
USE kamailio;
CREATE TABLE reseller_preferences LIKE usr_preferences;
USE provisioning;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sipwise`@`localhost`*/ /*!50003 TRIGGER voip_resellerpref_crepl_trig AFTER INSERT ON voip_reseller_preferences
FOR EACH ROW BEGIN
INSERT INTO kamailio.reseller_preferences
(id, uuid, attribute, type, value, last_modified)
SELECT NEW.id, NEW.reseller_id, attribute, type, NEW.value, '0'
FROM provisioning.voip_preferences
WHERE id <=> NEW.attribute_id;
END */;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sipwise`@`localhost`*/ /*!50003 TRIGGER voip_resellerpref_urepl_trig AFTER UPDATE ON voip_reseller_preferences
FOR EACH ROW BEGIN
UPDATE kamailio.reseller_preferences pp, provisioning.voip_preferences vp
SET pp.id = NEW.id, pp.uuid = NEW.reseller_id, pp.type = vp.type,
pp.attribute = vp.attribute, pp.value = NEW.value, pp.last_modified = '0'
WHERE pp.id <=> OLD.id
AND vp.id <=> NEW.attribute_id;
END */;;
/*!50003 CREATE*/ /*!50017 DEFINER=`sipwise`@`localhost`*/ /*!50003 TRIGGER voip_resellerpref_drepl_trig BEFORE DELETE ON voip_reseller_preferences
FOR EACH ROW BEGIN
DELETE FROM kamailio.reseller_preferences
WHERE id <=> OLD.id;
END */;;
DELIMITER ;
COMMIT;
Loading…
Cancel
Save