Finally remove ossbss peer_rules duplicates too

It was possible to add same rule to same group 
via ossbss.
2.6
Jon Bonilla 14 years ago
parent 8bed97f50f
commit 4dbfff5cd1

@ -1,8 +1,22 @@
# Remove duplicated rules on the same group. Triggers should do the rest for lcr_rule.
use provisioning;
ALTER IGNORE TABLE voip_peer_rules ADD UNIQUE KEY `idx1temp` (`group_id`, `callee_prefix`, `callee_pattern`, `caller_pattern`);
ALTER TABLE voip_peer_rules DROP KEY `idx1temp`;
#make sure that the repeated have caller_prefix '' instead of null or won't be detected
UPDATE voip_peer_rules SET caller_pattern='' WHERE caller_pattern IS NULL;
#Can't use ALTER IGNORE in Percona https://bugs.launchpad.net/percona-xtradb/+bug/604439
#ALTER IGNORE TABLE voip_peer_rules ADD UNIQUE KEY `idx1temp` (`group_id`, `callee_prefix`, `callee_pattern`, `caller_pattern`);
#ALTER TABLE voip_peer_rules DROP KEY `idx1temp`;
#Remove duplicated that could be added via ossbss. Removed keys via triggers will be added later
CREATE TABLE newtemp LIKE voip_peer_rules;
ALTER TABLE newtemp ADD UNIQUE KEY `idx1temp` (`group_id`, `callee_prefix`, `callee_pattern`, `caller_pattern`);
INSERT IGNORE INTO newtemp SELECT * FROM voip_peer_rules;
DELETE FROM voip_peer_rules;
INSERT INTO voip_peer_rules SELECT * FROM newtemp;
DROP table newtemp;
# Now we can create the unique key without duplicates
use kamailio;

Loading…
Cancel
Save