You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
db-schema/db_scripts/base/0020_create_oss.up

592 lines
35 KiB

-- step out of our provisioning DB
USE mysql;
-- drop database if it allready exists
-- this will drop all tables and triggers
DROP DATABASE IF EXISTS provisioning;
-- create DB with utf8 default charset, so we don't have to
-- specify charset for each table
CREATE DATABASE IF NOT EXISTS provisioning CHARACTER SET 'utf8';
USE provisioning;
-- create domain table
CREATE TABLE `voip_domains` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`domain` varchar(127) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `domain_idx` (`domain`)
) ENGINE=InnoDB;
-- create subscriber table
CREATE TABLE `voip_subscribers` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`username` varchar(127) NOT NULL,
`domain_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_domains` (`id`),
`uuid` char(36) NOT NULL,
`password` varchar(40) default NULL,
`admin` bool NOT NULL DEFAULT FALSE,
`account_id` int(11) UNSIGNED NULL DEFAULT NULL,
`webusername` varchar(127) default NULL,
`webpassword` varchar(40) default NULL,
`autoconf_displayname` varchar(255) default NULL,
`autoconf_group_id` int(11) unsigned default NULL,
`modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`create_timestamp` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `user_dom_idx` (`username`,`domain_id`),
UNIQUE KEY `uuid_idx` (`uuid`),
KEY `accountid_idx` (`account_id`),
KEY `domainid_idx` (`domain_id`),
CONSTRAINT `v_s_domainid_ref` FOREIGN KEY (`domain_id`)
REFERENCES `voip_domains` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create alias table
CREATE TABLE `voip_dbaliases` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`username` varchar(127) NOT NULL,
`domain_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_domains` (`id`),
`subscriber_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_subscribers` (`id`),
PRIMARY KEY (`id`),
UNIQUE KEY `user_dom_idx` (`username`,`domain_id`),
KEY `domainid_idx` (`domain_id`),
KEY `subscriberid_idx` (`subscriber_id`),
CONSTRAINT `v_da_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_da_domainid_ref` FOREIGN KEY (`domain_id`)
REFERENCES `voip_domains` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- sip peering tables
CREATE TABLE `voip_peer_groups` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(127) NOT NULL,
`priority` tinyint(3) NOT NULL default '1',
`description` varchar(255),
`peering_contract_id` int(11) unsigned,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB;
CREATE TABLE `voip_peer_rules` (
`id` int(11) unsigned NOT NULL auto_increment,
`group_id` int(11) unsigned NOT NULL,
`callee_prefix` varchar(64) NOT NULL default '',
`caller_prefix` varchar(64) default NULL,
`description` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `grpidx` (`group_id`),
CONSTRAINT `v_pg_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_peer_hosts` (
`id` int(11) unsigned NOT NULL auto_increment,
`group_id` int(11) unsigned NOT NULL,
`name` varchar(64) NOT NULL default '',
`ip` varchar(64) NOT NULL,
`host` varchar(64) DEFAULT NULL,
`port` int(5) NOT NULL default '5060',
`weight` tinyint(3) NOT NULL default '0',
`via_lb` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `grpname` (`group_id`,`name`),
KEY `grpidx` (`group_id`),
CONSTRAINT `v_ps_groupid_ref` FOREIGN KEY (`group_id`) REFERENCES `voip_peer_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create voip_preferences table
CREATE TABLE `voip_preferences` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`attribute` varchar(31) NOT NULL,
`type` tinyint(3) NOT NULL default 0,
`max_occur` tinyint(3) UNSIGNED NOT NULL,
`usr_pref` bool NOT NULL default FALSE,
`dom_pref` bool NOT NULL default FALSE,
`peer_pref` bool NOT NULL default FALSE,
`modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`internal` tinyint(1) NOT NULL default 0,
`data_type` enum('boolean','int','string') NOT NULL default 'string',
`read_only` bool NOT NULL default FALSE,
`description` text,
PRIMARY KEY (`id`),
UNIQUE KEY `attribute_idx` (`attribute`)
) ENGINE=InnoDB;
-- create subscriber preferences table
CREATE TABLE `voip_usr_preferences` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`subscriber_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_subscribers` (`id`),
`attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`),
`value` varchar(128) NOT NULL,
`modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `subidattrid_idx` (`subscriber_id`,`attribute_id`),
KEY `subscriberid_idx` (`subscriber_id`),
KEY `attributeid_idx` (`attribute_id`),
CONSTRAINT `v_u_p_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_u_p_attributeid_ref` FOREIGN KEY (`attribute_id`)
REFERENCES `voip_preferences` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create domain preferences table
CREATE TABLE `voip_dom_preferences` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`domain_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_domains` (`id`),
`attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`),
`value` varchar(128) NOT NULL,
`modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `domidattrid_idx` (`domain_id`,`attribute_id`),
KEY `domainid_idx` (`domain_id`),
KEY `attributeid_idx` (`attribute_id`),
CONSTRAINT `v_d_p_domainid_ref` FOREIGN KEY (`domain_id`)
REFERENCES `voip_domains` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_d_p_attributeid_ref` FOREIGN KEY (`attribute_id`)
REFERENCES `voip_preferences` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create peer host preferences table
CREATE TABLE `voip_peer_preferences` (
`id` int(11) UNSIGNED NOT NULL auto_increment,
`peer_host_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_peer_hosts` (`id`),
`attribute_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_preferences` (`id`),
`value` varchar(255) NOT NULL,
`modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `peerhostid_idx` (`peer_host_id`),
KEY `attributeid_idx` (`attribute_id`),
CONSTRAINT `v_p_p_peerhostid_ref` FOREIGN KEY (`peer_host_id`)
REFERENCES `voip_peer_hosts` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_p_p_attributeid_ref` FOREIGN KEY (`attribute_id`)
REFERENCES `voip_preferences` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create preliminary address book table
-- this should be moved to LDAP at some time
CREATE TABLE `voip_contacts` (
`id` int(11) unsigned NOT NULL auto_increment,
`subscriber_id` int(11) unsigned NOT NULL REFERENCES `voip_subscribers` (`id`),
`firstname` varchar(127),
`lastname` varchar(127),
`company` varchar(127),
`phonenumber` varchar(31),
`homephonenumber` varchar(31),
`mobilenumber` varchar(31),
`faxnumber` varchar(31),
`email` varchar(255),
`homepage` varchar(255),
PRIMARY KEY (`id`),
KEY `subscriberid_idx` (`subscriber_id`),
CONSTRAINT `v_c_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_speed_dial` (
`id` int(11) UNSIGNED NOT NULL PRIMARY KEY auto_increment,
`subscriber_id` int(11) UNSIGNED NOT NULL,
`slot` varchar(64) NOT NULL,
`destination` varchar(192) NOT NULL,
UNIQUE KEY `subscriberid_slot_idx` (`subscriber_id`,`slot`),
CONSTRAINT `v_sd_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) engine=InnoDB;
CREATE TABLE `voip_reminder` (
`id` int(11) unsigned NOT NULL auto_increment,
`subscriber_id` int(11) unsigned NOT NULL,
`time` time NOT NULL,
`recur` enum('never','weekdays','always') NOT NULL default 'never',
PRIMARY KEY (`id`),
UNIQUE KEY `subscriber_id` (`subscriber_id`),
CONSTRAINT `v_rem_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- create IP groups table containing IPs where users may connect from
-- IP networks are combined to groups to keep usr_preferences a bit smaller
CREATE TABLE `voip_allowed_ip_groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`group_id` int(10) unsigned NOT NULL,
`ipnet` varchar(18) NOT NULL,
PRIMARY KEY (`id`),
KEY `groupid_idx` (`group_id`),
KEY `ipnet_idx` (`ipnet`),
UNIQUE KEY `groupnet_idx` (`group_id`,`ipnet`)
) ENGINE=InnoDB;
-- this is a sequencer for `group_id` in `voip_allowed_ip_groups` above
CREATE TABLE `voip_aig_sequence` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- create fax tables
CREATE TABLE `voip_fax_preferences` (
`id` int(11) unsigned NOT NULL auto_increment,
`subscriber_id` int(11) unsigned NOT NULL REFERENCES `voip_subscribers` (`id`),
`password` varchar(64),
`name` varchar(64),
`active` bool NOT NULL default FALSE,
`send_status` bool NOT NULL default TRUE,
`send_copy` bool NOT NULL default TRUE,
PRIMARY KEY (`id`),
UNIQUE KEY `subscriberid_idx` (`subscriber_id`),
CONSTRAINT `v_f_p_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_fax_destinations` (
`id` int(11) unsigned NOT NULL auto_increment,
`subscriber_id` int(11) unsigned NOT NULL REFERENCES `voip_subscribers` (`id`),
`destination` varchar(255) NOT NULL,
`filetype` enum('PS','TIFF','PDF','PDF14') NOT NULL default 'TIFF',
`cc` bool NOT NULL default FALSE,
`incoming` bool NOT NULL default TRUE,
`outgoing` bool NOT NULL default FALSE,
`status` bool NOT NULL default FALSE,
PRIMARY KEY (`id`),
UNIQUE KEY `subdest_idx` (`subscriber_id`, `destination`),
CONSTRAINT `v_f_d_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- audio files for IVR, auto-attendant, etc.
CREATE TABLE `voip_audio_files` (
`id` int(11) unsigned NOT NULL auto_increment,
`subscriber_id` int(11) unsigned REFERENCES `voip_subscribers` (`id`),
`domain_id` int(11) unsigned REFERENCES `voip_domains` (`id`),
`handle` varchar(63) NOT NULL,
`description` text,
`audio` longblob,
PRIMARY KEY (`id`),
UNIQUE KEY `subhand_idx` (`subscriber_id`, `handle`),
UNIQUE KEY `domhand_idx` (`domain_id`, `handle`),
CONSTRAINT `v_a_f_subscriberid_ref` FOREIGN KEY (`subscriber_id`)
REFERENCES `voip_subscribers` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_a_f_domainid_ref` FOREIGN KEY (`domain_id`)
REFERENCES `voip_domains` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- VSC table
CREATE TABLE `voip_vscs` (
`id` int(11) unsigned NOT NULL auto_increment,
`domain_id` int(11) unsigned REFERENCES `voip_domains` (`id`),
`digits` char(2),
`action` varchar(31) NOT NULL,
`audio_id` int(11) unsigned NOT NULL REFERENCES `voip_audio_files` (`id`),
`description` text,
PRIMARY KEY (`id`),
UNIQUE KEY `domdig_idx` (`domain_id`, `digits`),
UNIQUE KEY `domaction_idx` (`domain_id`, `action`),
KEY `audioid_idx` (`audio_id`),
CONSTRAINT `v_v_domainid_ref` FOREIGN KEY (`domain_id`)
REFERENCES `voip_domains` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `v_v_audioid_ref` FOREIGN KEY (`audio_id`)
REFERENCES `voip_audio_files` (`id`)
ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB;
-- language strings for error messages
CREATE TABLE language_strings (
`id` int(11) unsigned NOT NULL auto_increment,
`code` varchar(63) NOT NULL,
`language` char(2) NOT NULL,
`string` text,
PRIMARY KEY (`id`),
UNIQUE KEY `codelang_idx` (code, language)
) ENGINE=InnoDB;
-- xmlrpc dispatcher tables
CREATE TABLE `xmlqueue` (
`id` int(10) unsigned NOT NULL auto_increment,
`target` varchar(255) NOT NULL,
`body` text NOT NULL,
`ctime` int(10) unsigned NOT NULL,
`atime` int(10) unsigned NOT NULL,
`tries` int(10) unsigned NOT NULL,
`next_try` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `next_try` (`next_try`,`id`)
) ENGINE=InnoDB;
CREATE TABLE `xmlhosts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ip` varchar(15) NOT NULL,
`port` int(5) unsigned NOT NULL,
`path` varchar(64) NOT NULL DEFAULT '/',
`sip_port` int(5) unsigned DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
CREATE TABLE `xmlgroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
KEY `gname` (`name`)
) ENGINE=InnoDB;
CREATE TABLE `xmlhostgroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`group_id` int(11) unsigned NOT NULL,
`host_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `gidx` (`group_id`),
KEY `xhg_hostid_ref` (`host_id`),
CONSTRAINT `xhg_groupid_ref` FOREIGN KEY (`group_id`)
REFERENCES `xmlgroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `xhg_hostid_ref` FOREIGN KEY (`host_id`)
REFERENCES `xmlhosts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_rewrite_rule_sets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`caller_in_dpid` int(11) unsigned DEFAULT NULL,
`callee_in_dpid` int(11) unsigned DEFAULT NULL,
`caller_out_dpid` int(11) unsigned DEFAULT NULL,
`callee_out_dpid` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_idx` (`name`)
) ENGINE=InnoDB;
-- this is a sequencer for the dpids in `voip_rewrite_rule_sets` above
CREATE TABLE `voip_rwrs_sequence` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
CREATE TABLE `voip_rewrite_rules` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`set_id` int(11) unsigned NOT NULL,
`match_pattern` varchar(64) NOT NULL DEFAULT '',
`replace_pattern` varchar(64) NOT NULL,
`description` varchar(127) NOT NULL DEFAULT '',
`direction` enum('in','out') NOT NULL DEFAULT 'in',
`field` enum('caller','callee') NOT NULL DEFAULT 'caller',
`priority` int(11) unsigned NOT NULL DEFAULT '50',
PRIMARY KEY (`id`),
KEY `setidx` (`set_id`),
KEY `dirfieldidx` (`direction`,`field`),
CONSTRAINT `v_rwr_setid_ref` FOREIGN KEY (`set_id`) REFERENCES `voip_rewrite_rule_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- call forward tables
CREATE TABLE `voip_cf_destination_sets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`subscriber_id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `sub_idx` (`subscriber_id`),
KEY `name_idx` (`name`),
CONSTRAINT `v_s_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES `voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_cf_destinations` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`destination_set_id` int(11) unsigned NOT NULL,
`destination` varchar(255) NOT NULL,
`priority` int(3) unsigned DEFAULT NULL,
`timeout` int(11) unsigned NOT NULL DEFAULT 300,
PRIMARY KEY (`id`),
KEY `dset_idx` (`destination_set_id`),
KEY `destination_idx` (`destination`),
CONSTRAINT `v_cf_dsetid_ref` FOREIGN KEY (`destination_set_id`) REFERENCES `voip_cf_destination_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_cf_time_sets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`subscriber_id` int(11) unsigned DEFAULT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `sub_idx` (`subscriber_id`),
KEY `name_idx` (`name`),
CONSTRAINT `v_cf_ts_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES
`voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_cf_periods` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`time_set_id` int(11) unsigned NOT NULL,
`year` varchar(255) DEFAULT NULL,
`month` varchar(255) DEFAULT NULL,
`mday` varchar(255) DEFAULT NULL,
`wday` varchar(255) DEFAULT NULL,
`hour` varchar(255) DEFAULT NULL,
`minute` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `tset_idx` (`time_set_id`),
CONSTRAINT `v_cf_tsetid_ref` FOREIGN KEY (`time_set_id`) REFERENCES
`voip_cf_time_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE `voip_cf_mappings` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`subscriber_id` int(11) unsigned NOT NULL,
`type` enum('cfu','cfb','cfna','cft') NOT NULL DEFAULT 'cfu',
`destination_set_id` int(11) unsigned DEFAULT NULL,
`time_set_id` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `sub_idx` (`subscriber_id`),
KEY `type_idx` (`type`),
CONSTRAINT `v_cfmap_subid_ref` FOREIGN KEY (`subscriber_id`) REFERENCES `voip_subscribers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `cfmap_time_ref` FOREIGN KEY (`time_set_id`) REFERENCES `voip_cf_time_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `cfmap_dest_ref` FOREIGN KEY (`destination_set_id`) REFERENCES `voip_cf_destination_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;
-- INSERT default data
-- localization language strings
LOAD DATA LOCAL INFILE 'language_strings.txt' INTO TABLE language_strings;
-- xmlrpc dispatcher
INSERT INTO xmlgroups (id, name) VALUES(1, 'proxy');
INSERT INTO xmlgroups (id, name) VALUES(2, 'registrar');
INSERT INTO xmlgroups (id, name) VALUES(3, 'presence');
INSERT INTO xmlgroups (id, name) VALUES(4, 'loadbalancer');
INSERT INTO xmlgroups (id, name) VALUES(5, 'appserver');
-- TODO: SR interface hack to work around rpc/mi discrepancies
INSERT INTO xmlgroups (id, name) VALUES(6, 'proxy-ng');
INSERT INTO xmlhosts (id, ip, port, path, sip_port, description) VALUES (1,'127.0.0.1','8000','/RPC2', '5062', 'Kamailio');
INSERT INTO xmlhosts (id, ip, port, path, description) VALUES (2,'127.0.0.1','8090','/','Sems');
-- TODO: SR interface hack to work around rpc/mi discrepancies
INSERT INTO xmlhosts (id, ip, port, path, description) VALUES (3,'127.0.0.1','5062','/','Kamailio-SR');
INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (1,1,1);
INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (2,5,2);
INSERT INTO xmlhostgroups (id, group_id, host_id) VALUES (3,6,3);
-- regular kamailio preferences
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, read_only, description)
VALUES('lock', 0, 1, 'string', 1, 1, 'See "lock_voip_account_subscriber" for a list of possible values. A lock value of "none" will not be returned to the caller. Read-only setting.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_in_mode', 1, 1, 'boolean', 1, 'Specifies the operational mode of the incoming block list. If unset or set to a false value, it is a blacklist (accept all calls except from numbers listed in the block list), with a true value it is a whitelist (reject all calls except from numbers listed in the block list).');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_in_list', 0, 1, 'string', 0, 'Contains wildcarded E.164 numbers that are (not) allowed to call the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards like in shell patterns.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_in_clir', 1, 1, 'boolean', 1, 'Incoming anonymous calls (with calling line identification restriction) are blocked if set to true.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_out_mode', 1, 1, 'boolean', 1, 'Specifies the operational mode of the outgoing block list. If unset or set to a false value, it is a blacklist (allow all calls except to numbers listed in the block list), with a true value it is a whitelist (deny all calls except to numbers listed in the block list).');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_out_list', 0, 1, 'string', 0, 'Contains wildcarded E.164 numbers that are (not) allowed to be called by the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards like in shell patterns.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_in_mode', 1, 1, 'boolean', 1, 'Same as "block_in_mode" but may only be set by administrators.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_in_list', 0, 1, 'string', 0, 'Same as "block_in_list" but may only be set by administrators and is applied prior to the user setting.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_in_clir', 1, 1, 'boolean', 1, 'Same as "block_in_clir" but may only be set by administrators and is applied prior to the user setting.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_out_mode', 1, 1, 'boolean', 1, 'Same as "block_out_mode" but may only be set by administrators.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_out_list', 0, 1, 'string', 0, 'Same as "block_out_list" but may only be set by administrators and is applied prior to the user setting.');
INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description)
VALUES(1, 1, 'cfu', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Unconditional" entry in the voip_cf_mappings table');
INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description)
VALUES(1, 1, 'cfb', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Busy" entry in the voip_cf_mappings table');
INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description)
VALUES(1, 1, 'cfna', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Unavailable" entry in the voip_cf_mappings table');
INSERT INTO voip_preferences (internal, read_only, attribute, type, usr_pref, data_type, max_occur, description)
VALUES(1, 1, 'cft', 1, 1, 'int', 0, 'The id pointing to the "Call Forward Timeout" entry in the voip_cf_mappings table');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('ringtimeout', 1, 1, 'int', 1, 'Specifies how many seconds the system should wait before redirecting the call if "cft" is set.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('cli', 0, 1, 'string', 1, 'E.164 number or complete SIP URI. "network-provided calling line identification" - specifies the source E.164 number or SIP username that is used for outgoing calls in the SIP "From" and "P-Asserted-Identity" headers (as user- and network-provided calling numbers). The content of the "From" header may be overridden by the "user_cli" preference and client (if allowed by the "allowed_clis" preference) SIP signalling. Automatically set to the primary E.164 number specified in the subscriber details.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('user_cli', 0, 1, 'string', 1, 'E.164 number or complete SIP URI. "user-provided calling line identification" - specifies the source E.164 number or SIP username that is used for outgoing calls. If set, this is put in the SIP "From" header (as user-provided calling number) if a client sends a CLI which is not allowed by "allowed_clis" or "allowed_clis" is not set.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('clir', 1, 1, 'boolean', 1, '"Calling line identification restriction" - if set to true, the CLI is not displayed on outgoing calls.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('cc', 0, 1, 'string', 1, 'The country code that will be used for routing of dialed numbers without a country code. Defaults to the country code of the E.164 number if the subscriber has one.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed numbers without an area code. Defaults to the area code of the E.164 number if the subscriber has one.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('svc_ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed service numbers without an area code. Defaults to "ac".');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('emerg_ac', 0, 1, 'string', 1, 'The area code that will be used for routing of dialed emergency numbers without an area code. Defaults to "ac".');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('block_out_override_pin', 0, 1, 'string', 1, 'A PIN code which may be used in a VSC to disable the outgoing user block list and NCOS level for a call.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('adm_block_out_override_pin', 0, 1, 'string', 1, 'Same as "block_out_override_pin" but additionally disables the administrative block list and NCOS level.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, description)
VALUES('allowed_clis', 0, 1, 'string', 0, 'A list of shell patterns specifying which CLIs are allowed to be set by the subscriber. "*", "?" and "[x-y]" with "x" and "y" representing numbers from 0 to 9 may be used as wildcards as usual in shell patterns.');
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('e164_to_ruri', 1, 0, 1, 'boolean', 1, 'Send the E164 number instead of SIP AOR as request username when sending INVITE to the subscriber. If a 404 is received the SIP AOR is sent as request URI as fallback.');
-- "external" kamailio preferences - only used for documentation and provisioning parameter checks
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal, description)
VALUES('ncos', 0, 1, 'string', 1, -1, 'Specifies the NCOS level that applies to the user.');
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal, description)
VALUES('adm_ncos', 0, 1, 'string', 1, -1, 'Same as "ncos", but may only be set by administrators and is applied prior to the user setting.');
-- "internal" kamailio preferences - not directly accessible via provisioning (often mapped to an "external" preference somehow)
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ncos_id', 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('adm_ncos_id', 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('account_id', 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ext_contract_id', 0, 1, 'string', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('ext_subscriber_id', 0, 1, 'string', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, data_type, max_occur, internal) VALUES('prepaid', 1, 1, 'boolean', 1, 1);
-- domain preferences
INSERT INTO voip_preferences (attribute, type, dom_pref, data_type, max_occur, description) VALUES('unauth_inbound_calls', 1, 1, 'boolean', 1, 'Allow unauthenticated inbound calls from FOREIGN domain to users within this domain. Use with care - it allows to flood your users with voice spam.');
-- peer preferences
INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description)
VALUES('peer_auth_user', 0, 1, 1, 'string', 1, 'A username used for authentication against a peer host.');
INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description)
VALUES('peer_auth_pass', 0, 1, 1, 'string', 1, 'A password used for authentication against a peer host.');
INSERT INTO voip_preferences (attribute, type, usr_pref, peer_pref, data_type, max_occur, description)
VALUES('peer_auth_realm', 0, 1, 1, 'string', 1, 'A realm (hostname) used to identify and for authentication against a peer host.');
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('find_subscriber_by_auth_user', 1, 0, 0, 1, 'boolean', 1, 'For incoming calls from this peer, find the destination subscriber also using its auth_username used for outbound registration.');
-- user + domain preferences
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('omit_outbound_displayname', 1, 1, 1, 'boolean', 1, 'Suppress the caller display-name that is put in the SIP "From" header on outgoing calls.');
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, data_type, max_occur, description) VALUES('force_inbound_calls_to_peer', 1, 1, 1, 'boolean', 1, 'Force calls to this user to be treated as if the user was not local. This helps in migration scenarios.');
-- user + domain + peer preferences
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Force rtp relay for this peer/domain/user.');
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('never_use_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Do not use rtp relay for this peer/domain/user. Rtp will be relayed if other participants have always_use_rtpproxy preference enabled.');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('peer_auth_register', 1, 1, 1, 1, 'boolean', 1, 'Specifies whether registration at the peer host is desired.');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('concurrent_max', 1, 1, 1, 1, 'int', 1, 'Maximum number of concurrent sessions (calls) for a subscriber or peer.');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('concurrent_max_out', 1, 1, 1, 1, 'int', 1, 'Maximum number of concurrent outgoing sessions (calls) coming from a subscriber or going to a peer.');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, description) VALUES('force_outbound_calls_to_peer', 1, 1, 1, 1, 'boolean', 1, 'Force calls from this user/domain/peer to be routed to PSTN even if the callee is local. Use with caution, as this setting may increase your costs! When enabling this option in a peer, make sure you trust it, as the NGCP will become an open relay for it!');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal, description)
VALUES('rewrite_rule_set', 1, 1, 1, 1, 'int', 1, -1, 'Specifies the list of caller and callee rewrite rules which should be applied for incoming and outgoing calls.');
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal)
VALUES('rewrite_caller_in_dpid', 1, 1, 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal)
VALUES('rewrite_callee_in_dpid', 1, 1, 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal)
VALUES('rewrite_caller_out_dpid', 1, 1, 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, usr_pref, dom_pref, peer_pref, data_type, max_occur, internal)
VALUES('rewrite_callee_out_dpid', 1, 1, 1, 1, 'int', 1, 1);
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_ipv4_for_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Always force the IPv4 address for the RTP relay, regardless of what is autodetected on SIP/SDP level. This is mutually exclusive with always_use_ipv6_for_rtpproxy.');
INSERT INTO voip_preferences (attribute, type, dom_pref, usr_pref, peer_pref, data_type, max_occur, description) VALUES('always_use_ipv6_for_rtpproxy', 1, 1, 1, 1, 'boolean', 1, 'Always force the IPv6 address for the RTP relay, regardless of what is autodetected on SIP/SDP level. This is mutually exclusive with always_use_ipv4_for_rtpproxy.');