TT#30386 add voip_header_rules schema and preference

Change-Id: Id6bf9dea39fe9d01ad0d996c3ff1e5b639516af7
changes/17/18517/45
Kirill Solomko 7 years ago
parent f541f37a22
commit dbe6ae1dfe

@ -0,0 +1,12 @@
set autocommit=0;
USE provisioning;
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE `voip_header_rule_sets`;
DROP TABLE `voip_header_rules`;
DROP TABLE `voip_header_rule_conditions`;
DROP TABLE `voip_header_rule_condition_values`;
DROP TABLE `voip_header_rule_actions`;
COMMIT;

@ -0,0 +1,83 @@
set autocommit=0;
USE provisioning;
CREATE TABLE `voip_header_rule_sets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`reseller_id` int(11) unsigned NOT NULL DEFAULT '1',
`name` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `res_name_idx` (`reseller_id`,`name`),
CONSTRAINT `vhrs_reseller_ref` FOREIGN KEY (`reseller_id`) REFERENCES `billing`.`resellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `voip_header_rules` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`set_id` int(11) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`priority` int(11) unsigned NOT NULL DEFAULT '100',
`direction` enum('inbound','outbound','local','peer') NOT NULL DEFAULT 'inbound',
`stopper` tinyint(1) unsigned NOT NULL DEFAULT 0,
`enabled` tinyint(1) unsigned NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
UNIQUE KEY `set_name_idx` (`set_id`,`name`),
KEY `direction_idx` (`direction`),
KEY `priority_idx` (`priority`),
KEY `enabled_idx` (`enabled`),
CONSTRAINT `v_hr_setid_ref` FOREIGN KEY (`set_id`) REFERENCES `voip_header_rule_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `voip_header_rule_conditions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`rule_id` int(11) unsigned NOT NULL,
`match_type` enum('header','preference','avp') NOT NULL DEFAULT 'header',
`match_part` enum('full','username','domain','port') NOT NULL DEFAULT 'full',
`match_name` varchar(255) NOT NULL,
`expression` enum('is','contains','matches','regexp') NOT NULL,
`expression_negation` tinyint(1) NOT NULL DEFAULT '0',
`value_type` enum('input','preference','avp') NOT NULL,
`rwr_set_id` int(11) unsigned DEFAULT NULL,
`rwr_dp_id` int(11) unsigned DEFAULT NULL,
`enabled` tinyint(1) unsigned NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
KEY `rule_id_idx` (`rule_id`),
KEY `rwr_set_id_idx` (`rwr_set_id`),
KEY `rwr_dp_id_idx` (`rwr_dp_id`),
KEY `enabled_idx` (`enabled`),
CONSTRAINT `v_hrc_ruleid_ref` FOREIGN KEY (`rule_id`) REFERENCES `voip_header_rules` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_hrc_rwrset_ref` FOREIGN KEY (`rwr_set_id`) REFERENCES `voip_rewrite_rule_sets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
);
CREATE TABLE `voip_header_rule_condition_values` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`condition_id` int(11) unsigned NOT NULL,
`value` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `condition_id_idx` (`condition_id`),
CONSTRAINT `v_hrcv_conditionid_ref` FOREIGN KEY (`condition_id`) REFERENCES `voip_header_rule_conditions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `voip_header_rule_actions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`rule_id` int(11) unsigned NOT NULL,
`header` varchar(255) NOT NULL,
`header_part` enum('full','username','domain','port') NOT NULL DEFAULT 'full',
`action_type` enum('set','add','remove','rsub','header','preference') NOT NULL,
`value_part` enum('full','username','domain','port') NOT NULL DEFAULT 'full',
`value` varchar(255) DEFAULT NULL,
`rwr_set_id` int(11) unsigned DEFAULT NULL,
`rwr_dp_id` int(11) unsigned DEFAULT NULL,
`priority` int(11) unsigned NOT NULL DEFAULT '100',
`enabled` tinyint(1) unsigned NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
KEY `rule_id_idx` (`rule_id`),
KEY `rwr_set_id_idx` (`rwr_set_id`),
KEY `rwr_dp_id_idx` (`rwr_dp_id`),
KEY `priority_idx` (`priority`),
KEY `enabled_idx` (`enabled`),
CONSTRAINT `v_hra_ruleid_ref` FOREIGN KEY (`rule_id`) REFERENCES `voip_header_rules` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_hra_rwrset_ref` FOREIGN KEY (`rwr_set_id`) REFERENCES `voip_rewrite_rule_sets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
);
COMMIT;

@ -0,0 +1,4 @@
use provisioning;
DELETE FROM voip_preferences WHERE attribute = 'header_rule_set';

@ -0,0 +1,10 @@
set autocommit=0;
use provisioning;
SELECT id into @vpg_id FROM voip_preference_groups where name = 'Internals';
INSERT INTO voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref, prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer, data_type, read_only, description)
VALUES
(@vpg_id, 'header_rule_set', "Header Rule Set", 1, 1, 1, 0, 1, 1, 0, NOW(), 0, 1, 'int', 0, 'Assign a "Header Rule Set" to manipulate SIP headers based on dynamic conditions');
commit;
Loading…
Cancel
Save