diff --git a/db_scripts/base/tmp/0010_create_oss.up b/db_scripts/base/tmp/0010_create_oss.up deleted file mode 100644 index fef94be2..00000000 --- a/db_scripts/base/tmp/0010_create_oss.up +++ /dev/null @@ -1,591 +0,0 @@ --- 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.'); diff --git a/db_scripts/base/tmp/0020_create_bss.up b/db_scripts/base/tmp/0020_create_bss.up deleted file mode 100644 index 81660703..00000000 --- a/db_scripts/base/tmp/0020_create_bss.up +++ /dev/null @@ -1,750 +0,0 @@ --- step out of our billing DB -USE mysql; - --- drop database if it allready exists --- this will drop all tables and triggers -DROP DATABASE IF EXISTS billing; - --- create DB with utf8 default charset, so we don't have to --- specify charset for each table -CREATE DATABASE billing CHARACTER SET 'utf8'; - -USE billing; - --- create reseller helper table -CREATE TABLE `resellers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - `name` varchar(63) NOT NULL, - `status` enum('active','locked','terminated') NOT NULL DEFAULT 'active', - PRIMARY KEY (`id`), - UNIQUE KEY `contractid_idx` (`contract_id`), - UNIQUE KEY `name_idx` (`name`) -) ENGINE=InnoDB; - --- create domains and reseller mapping tables -CREATE TABLE `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 TABLE `domain_resellers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `domain_id` int(11) UNSIGNED NOT NULL REFERENCES `domains` (`id`), - `reseller_id` int(11) UNSIGNED NOT NULL REFERENCES `resellers` (`id`), - PRIMARY KEY (`id`), - KEY `domainid_idx` (`domain_id`), - CONSTRAINT `dr_domainid_ref` FOREIGN KEY (`domain_id`) - REFERENCES `domains` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `dr_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create admins table that contains root user as well as reseller admins -CREATE TABLE `admins` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `login` varchar(31) NOT NULL, - `md5pass` char(32), - `is_master` boolean NOT NULL default FALSE, - `is_superuser` boolean NOT NULL default FALSE, - `is_active` boolean NOT NULL default TRUE, - `read_only` boolean NOT NULL default FALSE, - `show_passwords` boolean NOT NULL default TRUE, - `call_data` boolean NOT NULL default FALSE, - `lawful_intercept` boolean NOT NULL default FALSE, - PRIMARY KEY (`id`), - UNIQUE KEY `login_idx` (`login`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `a_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create billing tables -CREATE TABLE `billing_profiles` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `handle` varchar(63) NOT NULL, - `name` varchar(31) NOT NULL, - `prepaid` bool NOT NULL DEFAULT FALSE, - `interval_charge` double NOT NULL DEFAULT 0, - `interval_free_time` int(5) NOT NULL DEFAULT 0, - `interval_free_cash` double NOT NULL DEFAULT 0, - `interval_unit` enum('week','month') NOT NULL DEFAULT 'month', - `interval_count` tinyint(3) UNSIGNED NOT NULL DEFAULT 1, - `fraud_interval_limit` int(11) UNSIGNED NULL DEFAULT NULL, - `fraud_interval_lock` tinyint(3) UNSIGNED NOT NULL DEFAULT 0, - `fraud_interval_notify` varchar(255) NULL DEFAULT NULL, - `currency` varchar(31) NULL DEFAULT NULL, - `vat_rate` tinyint(3) UNSIGNED NULL DEFAULT NULL, - `vat_included` bool NOT NULL DEFAULT TRUE, - PRIMARY KEY (`id`), - UNIQUE KEY `resnam_idx` (`reseller_id`, `name`), - UNIQUE KEY `reshand_idx` (`reseller_id`, `handle`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `b_p_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `billing_zones` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), - `zone` varchar(127) NOT NULL, -- a zone name for internal use: admin interface, etc. - `detail` varchar(127) NULL, -- will be printed on invoices, etc. - PRIMARY KEY (`id`), - UNIQUE KEY `profnamdes_idx` (`billing_profile_id`, `zone`, `detail`), - CONSTRAINT `b_z_profileid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `billing_zones_history` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `bz_id` int(11) UNSIGNED, - `billing_profile_id` int(11) UNSIGNED NOT NULL, - `zone` varchar(127) NOT NULL, - `detail` varchar(127) NULL, - PRIMARY KEY (`id`), - KEY `bzid_idx` (`bz_id`), - CONSTRAINT `b_z_h_bzid_ref` FOREIGN KEY (`bz_id`) - REFERENCES `billing_zones` (`id`) - ON DELETE SET NULL ON UPDATE NO ACTION -) ENGINE=InnoDB; - -DELIMITER | - -CREATE TRIGGER bill_zones_crepl_trig AFTER INSERT ON billing_zones - FOR EACH ROW BEGIN - - INSERT INTO billing_zones_history - VALUES(NULL, NEW.id, NEW.billing_profile_id, NEW.zone, NEW.detail); - - END; -| - -CREATE TRIGGER bill_zones_urepl_trig AFTER UPDATE ON billing_zones - FOR EACH ROW BEGIN - - UPDATE billing_zones_history - SET bz_id = NEW.id, billing_profile_id = NEW.billing_profile_id, - zone = NEW.zone, detail = NEW.detail - WHERE bz_id = OLD.id; - - END; -| - -DELIMITER ; - -CREATE TABLE `billing_fees` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), - `billing_zone_id` int(11) UNSIGNED NULL REFERENCES `billing_zones` (`id`), - `destination` varchar(255) NOT NULL, - `type` enum('call', 'sms') NOT NULL DEFAULT 'call', - `onpeak_init_rate` double NOT NULL DEFAULT 0, - `onpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `onpeak_follow_rate` double NOT NULL DEFAULT 0, - `onpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_init_rate` double NOT NULL DEFAULT 0, - `offpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_follow_rate` double NOT NULL DEFAULT 0, - `offpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `use_free_time` bool NOT NULL DEFAULT FALSE, - PRIMARY KEY (`id`), - KEY `profileid_idx` (`billing_profile_id`), - CONSTRAINT `b_f_bilprofid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `zoneid_idx` (`billing_zone_id`), - CONSTRAINT `b_f_zoneid_ref` FOREIGN KEY (`billing_zone_id`) - REFERENCES `billing_zones` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - UNIQUE KEY `profdestype_idx` (`billing_profile_id`, `destination`, `type`) -) ENGINE=InnoDB; - -CREATE TABLE `billing_fees_history` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `bf_id` int(11) UNSIGNED, - `billing_profile_id` int(11) UNSIGNED NOT NULL, - `billing_zones_history_id` int(11) UNSIGNED NULL, - `destination` varchar(255) NOT NULL, - `type` enum('call', 'sms') NOT NULL DEFAULT 'call', - `onpeak_init_rate` double NOT NULL DEFAULT 0, - `onpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `onpeak_follow_rate` double NOT NULL DEFAULT 0, - `onpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_init_rate` double NOT NULL DEFAULT 0, - `offpeak_init_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `offpeak_follow_rate` double NOT NULL DEFAULT 0, - `offpeak_follow_interval` int(5) UNSIGNED NOT NULL DEFAULT 0, - `use_free_time` bool NOT NULL DEFAULT FALSE, - PRIMARY KEY (`id`), - KEY `bfid_idx` (`bf_id`), - CONSTRAINT `b_f_h_bfid_ref` FOREIGN KEY (`bf_id`) - REFERENCES `billing_fees` (`id`) - ON DELETE SET NULL ON UPDATE NO ACTION, - KEY `zonehid_idx` (`billing_zones_history_id`), - CONSTRAINT `b_f_h_bzhid_ref` FOREIGN KEY (`billing_zones_history_id`) - REFERENCES `billing_zones_history` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE -) ENGINE=InnoDB; - -DELIMITER | - -CREATE TRIGGER bill_fees_crepl_trig AFTER INSERT ON billing_fees - FOR EACH ROW BEGIN - DECLARE my_bzh_id int UNSIGNED; - - SELECT id INTO my_bzh_id FROM billing_zones_history WHERE bz_id = NEW.billing_zone_id; - - INSERT INTO billing_fees_history - VALUES(NULL, NEW.id, NEW.billing_profile_id, my_bzh_id, NEW.destination, - NEW.type, NEW.onpeak_init_rate, NEW.onpeak_init_interval, NEW.onpeak_follow_rate, - NEW.onpeak_follow_interval, NEW.offpeak_init_rate, NEW.offpeak_init_interval, - NEW.offpeak_follow_rate, NEW.offpeak_follow_interval, NEW.use_free_time); - - END; -| - -CREATE TRIGGER bill_fees_urepl_trig AFTER UPDATE ON billing_fees - FOR EACH ROW BEGIN - DECLARE my_bzh_id int UNSIGNED; - - SELECT id INTO my_bzh_id FROM billing_zones_history WHERE bz_id = NEW.billing_zone_id; - - UPDATE billing_fees_history - SET bf_id = NEW.id, billing_profile_id = NEW.billing_profile_id, - billing_zones_history_id = my_bzh_id, destination = NEW.destination, type = NEW.type, - onpeak_init_rate = NEW.onpeak_init_rate, onpeak_init_interval = NEW.onpeak_init_interval, - onpeak_follow_rate = NEW.onpeak_follow_rate, onpeak_follow_interval = NEW.onpeak_follow_interval, - offpeak_init_rate = NEW.offpeak_init_rate, offpeak_init_interval = NEW.offpeak_init_interval, - offpeak_follow_rate = NEW.offpeak_follow_rate, offpeak_follow_interval = NEW.offpeak_follow_interval, - use_free_time = NEW.use_free_time - WHERE bf_id = OLD.id; - - END; -| - -DELIMITER ; - -CREATE TABLE `billing_peaktime_weekdays` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), - `weekday` tinyint(3) UNSIGNED NOT NULL, - `start` time, - `end` time, - PRIMARY KEY (`id`), - KEY `profileid_idx` (`billing_profile_id`), - CONSTRAINT `b_p_w_bilprofid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `billing_peaktime_special` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `billing_profile_id` int(11) UNSIGNED NOT NULL REFERENCES `billing_profiles` (`id`), - `start` datetime, - `end` datetime, - PRIMARY KEY (`id`), - KEY `profileid_idx` (`billing_profile_id`), - CONSTRAINT `b_p_s_bilprofid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create LNP tables -CREATE TABLE `lnp_providers` ( - `id` int(11) UNSIGNED NOT NULL, - `name` varchar(255), - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE `lnp_numbers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `number` varchar(31) NOT NULL, - `lnp_provider_id` int(11) UNSIGNED NOT NULL REFERENCES `lnp_providers` (`id`), - `start` datetime NULL DEFAULT NULL, - `end` datetime NULL DEFAULT NULL, - PRIMARY KEY (`id`), - CONSTRAINT `l_n_lnpproid_ref` FOREIGN KEY (`lnp_provider_id`) - REFERENCES `lnp_providers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create NCOS tables -CREATE TABLE `ncos_levels` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED REFERENCES `resellers` (`id`), - `level` varchar(31) NOT NULL, - `mode` enum('blacklist', 'whitelist') NOT NULL default 'blacklist', - `local_ac` bool NOT NULL DEFAULT FALSE, - `description` text, - PRIMARY KEY (`id`), - UNIQUE KEY `reslev_idx` (`reseller_id`, `level`), - CONSTRAINT `c_l_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `ncos_pattern_list` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `ncos_level_id` int(11) UNSIGNED NOT NULL REFERENCES `ncos_levels` (`id`), - `pattern` varchar(255) NOT NULL, - `description` text, - PRIMARY KEY (`id`), - UNIQUE KEY `levpat_idx` (`ncos_level_id`, `pattern`), - CONSTRAINT `c_p_l_ncoslevid_ref` FOREIGN KEY (`ncos_level_id`) - REFERENCES `ncos_levels` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `ncos_lnp_list` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `ncos_level_id` int(11) UNSIGNED NOT NULL REFERENCES `ncos_levels` (`id`), - `lnp_provider_id` int(11) UNSIGNED NOT NULL REFERENCES `lnp_providers` (`id`), - `description` text, - PRIMARY KEY (`id`), - UNIQUE KEY `levpro_idx` (`ncos_level_id`, `lnp_provider_id`), - CONSTRAINT `c_l_l_ncoslevid_ref` FOREIGN KEY (`ncos_level_id`) - REFERENCES `ncos_levels` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `c_l_l_lnpproid_ref` FOREIGN KEY (`lnp_provider_id`) - REFERENCES `lnp_providers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create contact information table -CREATE TABLE `contacts` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `gender` enum('male','female'), - `firstname` varchar(127), - `lastname` varchar(127), - `comregnum` varchar(31), - `company` varchar(127), - `street` varchar(127), - `postcode` int(6), - `city` varchar(127), - `country` char(2), - `phonenumber` varchar(31), - `mobilenumber` varchar(31), - `email` varchar(255), - `newsletter` bool NOT NULL DEFAULT FALSE, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- create customer tables -CREATE TABLE `customers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `shopuser` varchar(31) NULL, - `shoppass` varchar(31) NULL, - `business` bool NOT NULL DEFAULT FALSE, - `contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), - `tech_contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), - `comm_contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), - `external_id` varchar(255) NULL default NULL, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp, - PRIMARY KEY (`id`), - UNIQUE KEY (`reseller_id`, `shopuser`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `cu_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `contactid_idx` (`contact_id`), - CONSTRAINT `cu_contactid_ref` FOREIGN KEY (`contact_id`) - REFERENCES `contacts` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `commcontactid_idx` (`comm_contact_id`), - CONSTRAINT `cu_commcontactid_ref` FOREIGN KEY (`comm_contact_id`) - REFERENCES `contacts` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `techcontact_idx` (`tech_contact_id`), - CONSTRAINT `cu_techcontact_ref` FOREIGN KEY (`tech_contact_id`) - REFERENCES `contacts` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `externalid_idx` (`external_id`) -) ENGINE=InnoDB; - -CREATE TABLE `customer_registers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `customer_id` int(11) UNSIGNED NOT NULL REFERENCES `customers` (`id`), - `actor` varchar(15), - `type` varchar(31) NOT NULL, - `data` text, - PRIMARY KEY (`id`), - KEY `customerid_idx` (`customer_id`), - CONSTRAINT `c_r_customerid_ref` FOREIGN KEY (`customer_id`) - REFERENCES `customers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `products` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `class` enum('sippeering', 'pstnpeering', 'reseller', 'voip', 'hardware', 'auxiliary') NOT NULL, - `handle` varchar(63) NOT NULL, - `name` varchar(127) NOT NULL, - `on_sale` bool NOT NULL DEFAULT FALSE, - `price` double, - `weight` mediumint(9) UNSIGNED, - `billing_profile_id` int(11) UNSIGNED NULL REFERENCES `billing_profiles` (`id`), - PRIMARY KEY (`id`), - UNIQUE KEY `resnam_idx` (`reseller_id`, `name`), - UNIQUE KEY `reshand_idx` (`reseller_id`, `handle`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `p_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `profileid_idx` (`billing_profile_id`), - CONSTRAINT `p_bilprofid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `invoices` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `year` smallint(4) UNSIGNED NOT NULL, - `month` tinyint(2) UNSIGNED NOT NULL, - `serial` int(5) UNSIGNED NOT NULL, - `data` blob, - PRIMARY KEY (`id`), - UNIQUE KEY `yms_idx` (`year`,`month`,`serial`) -) ENGINE=InnoDB; - -CREATE TABLE `orders` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED REFERENCES `resellers` (`id`), - `customer_id` int(11) UNSIGNED REFERENCES `customers` (`id`), - `delivery_contact_id` int(11) UNSIGNED REFERENCES `contacts` (`id`), - `type` varchar(31), - `state` enum('init','transact','failed','success') NOT NULL DEFAULT 'init', - `value` int(11), - `shipping_costs` int(11), - `invoice_id` int(11) UNSIGNED REFERENCES `invoices` (`id`), - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp, - `complete_timestamp` timestamp, - PRIMARY KEY (`id`), - KEY `customerid_idx` (`customer_id`), - CONSTRAINT `o_customerid_ref` FOREIGN KEY (`customer_id`) - REFERENCES `customers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `o_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `contactid_idx` (`delivery_contact_id`), - CONSTRAINT `o_contactid_ref` FOREIGN KEY (`delivery_contact_id`) - REFERENCES `contacts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `invoiceid_idx` (`invoice_id`), - CONSTRAINT `o_invoiceid_ref` FOREIGN KEY (`invoice_id`) - REFERENCES `invoices` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create payment table -CREATE TABLE `payments` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `amount` int(11), - `type` varchar(31), - `state` enum('init','transact','failed','success'), - `mpaytid` int(11) UNSIGNED, - `status` varchar(31), - `errno` int(11), - `returncode` varchar(63), - `externalstatus` text, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp, - PRIMARY KEY (`id`), - KEY `state_idx` (`state`), - KEY `mpaytid_idx` (`mpaytid`), - KEY `status_idx` (`status`) -) ENGINE=InnoDB; - --- create mapping table between orders and payments -CREATE TABLE `order_payments` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `order_id` int(11) UNSIGNED NOT NULL REFERENCES `orders` (`id`), - `payment_id` int(11) UNSIGNED NOT NULL REFERENCES `payments` (`id`), - PRIMARY KEY (`id`), - KEY `orderid_idx` (`order_id`), - CONSTRAINT `op_orderid_ref` FOREIGN KEY (`order_id`) - REFERENCES `orders` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `paymentid_idx` (`payment_id`), - CONSTRAINT `op_paymentid_ref` FOREIGN KEY (`payment_id`) - REFERENCES `payments` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create contract tables -CREATE TABLE `contracts` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `customer_id` int(11) UNSIGNED NULL REFERENCES `customers` (`id`), - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `contact_id` int(11) UNSIGNED NULL REFERENCES `contacts` (`id`), - `order_id` int(11) UNSIGNED NULL REFERENCES `orders` (`id`), - `status` enum('pending','active','locked','terminated') NOT NULL DEFAULT 'active', - `external_id` varchar(255) NULL default NULL, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp NOT NULL, - `activate_timestamp` timestamp NULL, - `terminate_timestamp` timestamp NULL, - PRIMARY KEY (`id`), - KEY `contactid_idx` (`contact_id`), - CONSTRAINT `co_contactid_ref` FOREIGN KEY (`contact_id`) - REFERENCES `contacts` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE, - KEY `customerid_idx` (`customer_id`), - CONSTRAINT `c_customerid_ref` FOREIGN KEY (`customer_id`) - REFERENCES `customers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `co_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `orderid_idx` (`order_id`), - CONSTRAINT `co_orderid_ref` FOREIGN KEY (`order_id`) - REFERENCES `orders` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE, - KEY `externalid_idx` (`external_id`) -) ENGINE=InnoDB; - --- create resellers->contracts foreign key -ALTER TABLE resellers - ADD CONSTRAINT `r_contractid_ref` - FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -; - -CREATE TABLE `contract_registers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - `actor` varchar(15), - `type` varchar(31) NOT NULL, - `data` text, - PRIMARY KEY (`id`), - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `c_r_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `voip_subscribers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - `uuid` char(36) NOT NULL, - `username` varchar(127) NOT NULL, - `domain_id` int(11) UNSIGNED NOT NULL REFERENCES `domains` (`id`), - `status` enum('active','locked','terminated') NOT NULL DEFAULT 'active', - `primary_number_id` int(11) unsigned default NULL, - `external_id` varchar(255) NULL default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `uuid_idx` (uuid), - KEY `username_idx` (`username`), - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `v_s_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `domainid_idx` (`domain_id`), - CONSTRAINT `v_s_domainid_ref` FOREIGN KEY (`domain_id`) - REFERENCES `domains` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `pnumid_idx` (`primary_number_id`), - KEY `externalid_idx` (`external_id`) -) ENGINE=InnoDB; - --- create table that stores all known E.164 numbers -CREATE TABLE `voip_numbers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `cc` int(4) UNSIGNED NOT NULL, - `ac` varchar(7) NOT NULL, - `sn` varchar(31) NOT NULL, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `subscriber_id` int(11) UNSIGNED NULL REFERENCES `voip_subscribers` (`id`), - `status` enum('active','reserved','locked','deported') NOT NULL DEFAULT 'active', - `ported` bool NOT NULL DEFAULT FALSE, - `list_timestamp` timestamp, - PRIMARY KEY (`id`), - KEY `listts_idx` (`list_timestamp`), - UNIQUE KEY `number_idx` (`cc`,`ac`,`sn`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `v_n_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE, - KEY `subscriberid_idx` (`subscriber_id`), - CONSTRAINT `v_n_subscriberid_ref` FOREIGN KEY (`subscriber_id`) - REFERENCES `voip_subscribers` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB; - --- define local number blocks -CREATE TABLE `voip_number_blocks` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `cc` int(4) UNSIGNED NOT NULL, - `ac` varchar(7) NOT NULL, - `sn_prefix` varchar(31) NOT NULL, - `sn_length` tinyint(2) UNSIGNED NOT NULL, - `allocable` bool NOT NULL DEFAULT FALSE, - `authoritative` bool NOT NULL DEFAULT FALSE, - PRIMARY KEY (`id`), - UNIQUE KEY `prefix_idx` (`cc`, `ac`, `sn_prefix`) -) ENGINE=InnoDB; - -CREATE TABLE `voip_number_block_resellers` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `number_block_id` int(11) UNSIGNED NOT NULL REFERENCES `voip_number_blocks` (`id`), - `reseller_id` int(11) UNSIGNED NOT NULL REFERENCES `resellers` (`id`), - PRIMARY KEY (`id`), - KEY `numblockid_idx` (`number_block_id`), - CONSTRAINT `vnbr_numblockid_ref` FOREIGN KEY (`number_block_id`) - REFERENCES `voip_number_blocks` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `vnbr_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create subscribers->primary-number foreign key -ALTER TABLE voip_subscribers - ADD CONSTRAINT `v_s_pnumid_ref` - FOREIGN KEY (`primary_number_id`) - REFERENCES `voip_numbers` (`id`) - ON DELETE SET NULL ON UPDATE CASCADE -; - --- create account status table -CREATE TABLE `contract_balances` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - `cash_balance` double, - `cash_balance_interval` double NOT NULL DEFAULT 0, - `free_time_balance` int(11), - `free_time_balance_interval` int(11) NOT NULL DEFAULT 0, - `start` datetime NOT NULL, - `end` datetime NOT NULL, - `invoice_id` int(11) UNSIGNED REFERENCES `invoices` (`id`), - PRIMARY KEY (`id`), - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `c_b_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `invoiceid_idx` (`invoice_id`), - CONSTRAINT `cb_invoiceid_ref` FOREIGN KEY (`invoice_id`) - REFERENCES `invoices` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create table that holds credits and debits -CREATE TABLE `contract_credits` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `balance_id` int(11) UNSIGNED NOT NULL REFERENCES `contract_balances` (`id`), - `state` enum('init','transact','charged','failed','success') NOT NULL DEFAULT 'init', - `amount` double, - `reason` text, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp, - PRIMARY KEY (`id`), - KEY `balanceid_idx` (`balance_id`), - CONSTRAINT `cc_balanceid_ref` FOREIGN KEY (`balance_id`) - REFERENCES `contract_balances` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create mapping table between orders and payments -CREATE TABLE `credit_payments` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `credit_id` int(11) UNSIGNED NOT NULL REFERENCES `contract_credits` (`id`), - `payment_id` int(11) UNSIGNED NOT NULL REFERENCES `payments` (`id`), - PRIMARY KEY (`id`), - KEY `creditid_idx` (`credit_id`), - CONSTRAINT `cp_creditid_ref` FOREIGN KEY (`credit_id`) - REFERENCES `contract_credits` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `paymentid_idx` (`payment_id`), - CONSTRAINT `cp_paymentid_ref` FOREIGN KEY (`payment_id`) - REFERENCES `payments` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - --- create mapping table between contracts and billing_profiles, billing_groups and products -CREATE TABLE `billing_mappings` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `start_date` datetime, - `end_date` datetime, - `billing_profile_id` int(11) UNSIGNED REFERENCES `billing_profiles` (`id`), - `contract_id` int(11) UNSIGNED NOT NULL REFERENCES `contracts` (`id`), - `product_id` int(11) UNSIGNED REFERENCES `products` (`id`), - PRIMARY KEY (`id`), - KEY `profileid_idx` (`billing_profile_id`), - CONSTRAINT `b_m_bilprofid_ref` FOREIGN KEY (`billing_profile_id`) - REFERENCES `billing_profiles` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE, - KEY `contractid_idx` (`contract_id`), - CONSTRAINT `b_m_contractid_ref` FOREIGN KEY (`contract_id`) - REFERENCES `contracts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `productid_idx` (`product_id`), - CONSTRAINT `b_m_productid_ref` FOREIGN KEY (`product_id`) - REFERENCES `products` (`id`) - ON DELETE RESTRICT ON UPDATE CASCADE -) ENGINE=InnoDB; - --- lawful intercept table -CREATE TABLE `voip_intercept` ( - `id` int(11) UNSIGNED NOT NULL auto_increment, - `reseller_id` int(11) UNSIGNED NULL REFERENCES `resellers` (`id`), - `LIID` int(11) UNSIGNED, - `number` varchar(63), - `cc_required` bool NOT NULL DEFAULT FALSE, - `delivery_host` varchar(15), - `delivery_port` smallint(5) UNSIGNED, - `delivery_user` text NULL, - `delivery_pass` text NULL, - `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `create_timestamp` timestamp NOT NULL, - `deleted` bool NOT NULL DEFAULT FALSE, - PRIMARY KEY (`id`), - KEY `resellerid_idx` (`reseller_id`), - CONSTRAINT `vi_resellerid_ref` FOREIGN KEY (`reseller_id`) - REFERENCES `resellers` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - KEY `number_idx` (`number`), - KEY `deleted_idx` (`deleted`) -) ENGINE=InnoDB; - --- insert some data to get rating and the web interface working - --- system internal products -INSERT INTO `products` (id,class,handle,name,on_sale) - VALUES (1,'pstnpeering','PSTN_PEERING','PSTN Peering',1), - (2,'sippeering','SIP_PEERING','SIP Peering',1), - (3,'reseller','VOIP_RESELLER','VoIP Reseller',1); --- the default reseller contract, will be the only one unless multitenancy is enabled -INSERT INTO `contracts` (id,status,modify_timestamp,create_timestamp,activate_timestamp) VALUES (1,'active',now(),now(),now()); -INSERT INTO `resellers` (id,contract_id,name,status) VALUES (1,1,'default','active'); -INSERT INTO `billing_mappings` (id,start_date,end_date,contract_id,product_id) VALUES (1,NULL,NULL,1,3); --- first administrative account, change password after first login -INSERT INTO `admins` (id,reseller_id,login,md5pass,is_master,is_superuser,call_data,lawful_intercept) - VALUES (1,1,'administrator',md5('administrator'),1,1,1,1); --- default billing profile creation -INSERT INTO `billing_profiles` (id,reseller_id,handle,name,interval_unit,interval_count) - VALUES(1,1,'default','Default Billing Profile','month',1); -INSERT INTO `billing_zones` (id,billing_profile_id,zone,detail) VALUES (1,1,'Free Default Zone','All Destinations'); -INSERT INTO `billing_fees` (id,billing_profile_id,billing_zone_id,destination,type, - onpeak_init_rate,onpeak_init_interval,onpeak_follow_rate,onpeak_follow_interval, - offpeak_init_rate,offpeak_init_interval,offpeak_follow_rate,offpeak_follow_interval) - VALUES (1,1,1,'.*','call',0,600,0,600,0,600,0,600); diff --git a/db_scripts/base/tmp/0030_create_kamailio.up b/db_scripts/base/tmp/0030_create_kamailio.up deleted file mode 100644 index deca5732..00000000 --- a/db_scripts/base/tmp/0030_create_kamailio.up +++ /dev/null @@ -1,390 +0,0 @@ -USE mysql; -DROP DATABASE IF EXISTS kamailio; - -CREATE DATABASE IF NOT EXISTS kamailio CHARACTER SET 'utf8'; - -USE kamailio; - -CREATE TABLE `acc` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `method` varchar(16) NOT NULL DEFAULT '', - `from_tag` varchar(64) NOT NULL DEFAULT '', - `to_tag` varchar(64) NOT NULL DEFAULT '', - `callid` varchar(255) NOT NULL DEFAULT '', - `sip_code` varchar(3) NOT NULL DEFAULT '', - `sip_reason` varchar(128) NOT NULL DEFAULT '', - `time` datetime NOT NULL, - `time_hires` decimal(13,3) NOT NULL, - `src_leg` varchar(2048) default NULL, - `dst_leg` varchar(2048) default NULL, - `dst_user` varchar(64) NOT NULL default '', - `dst_ouser` varchar(64) NOT NULL default '', - `dst_domain` varchar(128) NOT NULL default '', - `src_user` varchar(64) NOT NULL default '', - `src_domain` varchar(128) NOT NULL default '', - PRIMARY KEY (`id`), - KEY `callid_idx` (`callid`) -) ENGINE=InnoDB; - -CREATE TABLE `dbaliases` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `alias_username` varchar(64) NOT NULL DEFAULT '', - `alias_domain` varchar(64) NOT NULL DEFAULT '', - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - UNIQUE KEY `alias_idx` (`alias_username`,`alias_domain`), - KEY `target_idx` (`username`,`domain`) -) ENGINE=InnoDB; - -CREATE TABLE `dialog` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `hash_entry` int(10) unsigned NOT NULL, - `hash_id` int(10) unsigned NOT NULL, - `callid` varchar(255) NOT NULL, - `from_uri` varchar(128) NOT NULL, - `from_tag` varchar(64) NOT NULL, - `to_uri` varchar(128) NOT NULL, - `to_tag` varchar(64) NOT NULL, - `caller_cseq` varchar(7) NOT NULL, - `callee_cseq` varchar(7) NOT NULL, - `caller_route_set` varchar(512) DEFAULT NULL, - `callee_route_set` varchar(512) DEFAULT NULL, - `caller_contact` varchar(128) NOT NULL, - `callee_contact` varchar(128) NOT NULL, - `caller_sock` varchar(64) NOT NULL, - `callee_sock` varchar(64) NOT NULL, - `state` int(10) unsigned NOT NULL, - `start_time` int(10) unsigned NOT NULL, - `timeout` int(10) unsigned NOT NULL DEFAULT '0', - `sflags` int(10) unsigned NOT NULL DEFAULT '0', - `toroute` int(10) unsigned NOT NULL DEFAULT '0', - `req_uri` varchar(128) NOT NULL, - PRIMARY KEY (`id`), - KEY `hash_idx` (`hash_entry`,`hash_id`) -) ENGINE=InnoDB; - -CREATE TABLE `dialplan` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `dpid` int(11) NOT NULL, - `pr` int(11) NOT NULL, - `match_op` int(11) NOT NULL, - `match_exp` varchar(64) NOT NULL, - `match_len` int(11) NOT NULL, - `subst_exp` varchar(64) NOT NULL, - `repl_exp` varchar(64) NOT NULL, - `attrs` varchar(32) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE `dispatcher` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `setid` int(11) NOT NULL DEFAULT '0', - `destination` varchar(192) NOT NULL DEFAULT '', - `flags` int(11) NOT NULL DEFAULT '0', - `priority` int(11) NOT NULL DEFAULT '0', - `description` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE `domain` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `domain` varchar(64) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - UNIQUE KEY `domain_idx` (`domain`) -) ENGINE=InnoDB; - -CREATE TABLE `lcr_gw` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `gw_name` varchar(128) NOT NULL, - `ip_addr` varchar(64) NOT NULL, - `hostname` varchar(64) DEFAULT NULL, - `port` smallint(5) unsigned DEFAULT NULL, - `params` varchar(64) DEFAULT NULL, - `uri_scheme` tinyint(3) unsigned DEFAULT NULL, - `transport` tinyint(3) unsigned DEFAULT NULL, - `strip` tinyint(3) unsigned DEFAULT NULL, - `tag` varchar(16) DEFAULT NULL, - `flags` int(10) unsigned NOT NULL DEFAULT '0', - `defunct` int(10) unsigned DEFAULT NULL, - `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `lcr_id_gw_name_idx` (`lcr_id`,`gw_name`), - UNIQUE KEY `lcr_id_ip_addr_idx` (`lcr_id`,`ip_addr`) -) ENGINE=InnoDB; - -CREATE TABLE `lcr_rule` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `prefix` varchar(16) DEFAULT NULL, - `from_uri` varchar(64) DEFAULT NULL, - `stopper` int(10) unsigned NOT NULL DEFAULT '0', - `enabled` int(10) unsigned NOT NULL DEFAULT '1', - `group_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `lcr_id_idx` (`lcr_id`) -) ENGINE=InnoDB; - -CREATE TABLE `lcr_rule_target` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `rule_id` int(10) unsigned NOT NULL, - `gw_id` int(10) unsigned NOT NULL, - `priority` tinyint(3) unsigned NOT NULL, - `weight` int(10) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - UNIQUE KEY `rule_id_gw_id_idx` (`rule_id`,`gw_id`), - KEY `lcr_id_idx` (`lcr_id`), - KEY `gw_id_idx` (`gw_id`), - CONSTRAINT `l_r_t_ruleid_ref` FOREIGN KEY (`rule_id`) - REFERENCES `lcr_rule` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `l_r_t_gwid_ref` FOREIGN KEY (`gw_id`) - REFERENCES `lcr_gw` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `location` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) DEFAULT NULL, - `contact` varchar(255) NOT NULL DEFAULT '', - `received` varchar(128) DEFAULT NULL, - `path` varchar(128) DEFAULT NULL, - `expires` datetime NOT NULL DEFAULT '2020-05-28 21:32:15', - `q` float(10,2) NOT NULL DEFAULT '1.00', - `callid` varchar(255) NOT NULL DEFAULT 'Default-Call-ID', - `cseq` int(11) NOT NULL DEFAULT '13', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - `flags` int(11) NOT NULL DEFAULT '0', - `cflags` int(11) NOT NULL DEFAULT '0', - `user_agent` varchar(255) NOT NULL DEFAULT '', - `socket` varchar(64) DEFAULT NULL, - `methods` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `account_contact_idx` (`username`,`domain`,`contact`) -) ENGINE=InnoDB; - -CREATE TABLE `speed_dial` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - `sd_username` varchar(64) NOT NULL DEFAULT '', - `sd_domain` varchar(64) NOT NULL DEFAULT '', - `new_uri` varchar(128) NOT NULL DEFAULT '', - `fname` varchar(64) NOT NULL DEFAULT '', - `lname` varchar(64) NOT NULL DEFAULT '', - `description` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - UNIQUE KEY `speed_dial_idx` (`username`,`domain`,`sd_domain`,`sd_username`) -) ENGINE=InnoDB; - -CREATE TABLE `subscriber` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - `password` varchar(40) NOT NULL DEFAULT '', - `email_address` varchar(64) NOT NULL DEFAULT '', - `ha1` varchar(64) NOT NULL DEFAULT '', - `ha1b` varchar(64) NOT NULL DEFAULT '', - `rpid` varchar(64) DEFAULT NULL, - `uuid` char(36) NOT NULL, - `timezone` varchar(64) NOT NULL DEFAULT '', - `datetime_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - UNIQUE KEY `account_idx` (`username`,`domain`), - KEY `username_idx` (`username`) -) ENGINE=InnoDB; - -CREATE TABLE `trusted` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `src_ip` varchar(50) NOT NULL, - `proto` varchar(4) NOT NULL, - `from_pattern` varchar(64) DEFAULT NULL, - `tag` varchar(64) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `peer_idx` (`src_ip`) -) ENGINE=InnoDB; - -CREATE TABLE `usr_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` char(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`), - KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; - -CREATE TABLE `dom_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` char(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`), - KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; - -CREATE TABLE `peer_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` varchar(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`) --- not used -- KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB; - -CREATE TABLE `address` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `grp` smallint(5) unsigned NOT NULL DEFAULT '0', - `ip_addr` varchar(15) NOT NULL, - `mask` tinyint(4) NOT NULL DEFAULT '32', - `port` smallint(5) unsigned NOT NULL DEFAULT '0', - `tag` VARCHAR(64), - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - -CREATE TABLE `version` ( - `table_name` varchar(32) NOT NULL, - `table_version` int(10) unsigned NOT NULL DEFAULT '0' -) ENGINE=InnoDB; - -CREATE TABLE `voicemail_users` ( - `uniqueid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `customer_id` char(36) NOT NULL DEFAULT '', - `context` varchar(63) NOT NULL DEFAULT 'default', - `mailbox` varchar(31) NOT NULL, - `password` varchar(31) NOT NULL DEFAULT '0', - `fullname` varchar(255) NOT NULL DEFAULT '', - `email` varchar(255) NOT NULL DEFAULT '', - `pager` varchar(255) NOT NULL DEFAULT '', - `tz` varchar(10) NOT NULL DEFAULT 'central', - `attach` varchar(4) NOT NULL DEFAULT 'yes', - `saycid` varchar(4) NOT NULL DEFAULT 'yes', - `dialout` varchar(10) NOT NULL DEFAULT '', - `callback` varchar(10) NOT NULL DEFAULT '', - `review` varchar(4) NOT NULL DEFAULT 'no', - `operator` varchar(4) NOT NULL DEFAULT 'no', - `envelope` varchar(4) NOT NULL DEFAULT 'no', - `sayduration` varchar(4) NOT NULL DEFAULT 'no', - `saydurationm` tinyint(4) NOT NULL DEFAULT '1', - `sendvoicemail` varchar(4) NOT NULL DEFAULT 'no', - `delete` varchar(4) NOT NULL DEFAULT 'no', - `nextaftercmd` varchar(4) NOT NULL DEFAULT 'yes', - `forcename` varchar(4) NOT NULL DEFAULT 'no', - `forcegreetings` varchar(4) NOT NULL DEFAULT 'no', - `hidefromdir` varchar(4) NOT NULL DEFAULT 'yes', - `stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`uniqueid`), - KEY `customer_idx` (`customer_id`), - KEY `mailbox_context` (`mailbox`,`context`) -) ENGINE=InnoDB; - -CREATE TABLE `voicemail_spool` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `msgnum` int(11) NOT NULL DEFAULT '0', - `dir` varchar(127) DEFAULT '', - `context` varchar(63) DEFAULT '', - `macrocontext` varchar(63) DEFAULT '', - `callerid` varchar(255) DEFAULT '', - `origtime` varchar(16) DEFAULT '', - `duration` varchar(16) DEFAULT '', - `mailboxuser` varchar(255) DEFAULT '', - `mailboxcontext` varchar(63) DEFAULT '', - `recording` longblob, - PRIMARY KEY (`id`), - KEY `dir` (`dir`), - KEY `mailboxuser_idx` (`mailboxuser`), - CONSTRAINT `v_s_mailboxuser_ref` FOREIGN KEY (`mailboxuser`) REFERENCES `voicemail_users` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB; - -CREATE TABLE `fax_preferences` ( - `subscriber_id` int(10) unsigned NOT NULL, - `password` varchar(64) default NULL, - `name` varchar(64) default NULL, - `active` enum('true','false') NOT NULL default 'true', - `send_status` enum('true','false') NOT NULL default 'false', - `send_copy` enum('true','false') NOT NULL default 'false', - `send_copy_cc` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB; - -CREATE TABLE `fax_destinations` ( - `id` int(10) unsigned NOT NULL auto_increment, - `subscriber_id` int(10) unsigned NOT NULL, - `destination` varchar(64) NOT NULL, - `filetype` enum('ps','tiff','pdf','pdf14') NOT NULL default 'tiff', - `cc` enum('true','false') NOT NULL default 'false', - `incoming` enum('true','false') NOT NULL default 'true', - `outgoing` enum('true','false') NOT NULL default 'false', - `status` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`id`), - KEY `subscriber_id` (`subscriber_id`) -) ENGINE=InnoDB; - -CREATE TABLE `sems_registrations` ( - `subscriber_id` int(11) NOT NULL, - `registration_status` tinyint(1) NOT NULL DEFAULT '0', - `last_registration` datetime DEFAULT NULL, - `expiry` datetime DEFAULT NULL, - `last_code` smallint(2) DEFAULT NULL, - `last_reason` varchar(256) DEFAULT NULL, - `contacts` varchar(512) DEFAULT NULL, - PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB; - -CREATE TABLE `fax_journal` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `subscriber_id` int(10) unsigned NOT NULL DEFAULT '0', - `the_timestamp` int(11) unsigned NOT NULL DEFAULT '0', - `duration` int(11) unsigned NOT NULL DEFAULT '0', - `direction` enum('in','out') NOT NULL DEFAULT 'in', - `peer_number` varchar(255) NOT NULL DEFAULT '', - `peer_name` varchar(255) NOT NULL DEFAULT '', - `pages` int(10) unsigned NOT NULL DEFAULT '0', - `reason` varchar(255) NOT NULL, - `status` varchar(255) NOT NULL DEFAULT '', - `signal_rate` int(10) unsigned NOT NULL DEFAULT '0', - `quality` varchar(255) NOT NULL DEFAULT '', - `filename` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY `selkey` (`subscriber_id`,`direction`) -) ENGINE=InnoDB; - -INSERT INTO `version` VALUES - ('acc',4), - ('lcr_gw',1), - ('lcr_rule_target',1), - ('lcr_rule',1), - ('domain',1), - ('trusted',5), - ('location',1004), - ('dbaliases',1), - ('speed_dial',2), - ('usr_preferences',2), - ('subscriber',6), - ('dialog',4), - ('dispatcher',3), - ('address',4), - ('dialplan',1); - - -INSERT INTO `dispatcher` VALUES ('1','2','sip:127.0.0.1:5070','0','0','Voicemail servers'); -INSERT INTO `dispatcher` VALUES ('2','3','sip:127.0.0.1:5080','0','0','Application servers'); -INSERT INTO `dispatcher` VALUES ('3','4','sip:127.0.0.1:5090','0','0','Fax2Mail servers'); diff --git a/db_scripts/base/tmp/0040_create_accounting.up b/db_scripts/base/tmp/0040_create_accounting.up deleted file mode 100644 index 7c553fb3..00000000 --- a/db_scripts/base/tmp/0040_create_accounting.up +++ /dev/null @@ -1,71 +0,0 @@ --- 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 accounting; - --- create DB with utf8 default charset, so we don't have to --- specify charset for each table -CREATE DATABASE IF NOT EXISTS accounting CHARACTER SET 'utf8'; - -USE accounting; - --- create accounting tables - -CREATE TABLE `acc` like kamailio.acc; - -CREATE TABLE `cdr` ( - `id` int(10) unsigned NOT NULL auto_increment, - `update_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `source_user_id` char(36) NOT NULL, - `source_provider_id` varchar(255) NOT NULL, - `source_user` varchar(255) NOT NULL, - `source_domain` varchar(255) NOT NULL, - `source_cli` varchar(64) NOT NULL, - `source_clir` tinyint(1) NOT NULL default '0', - `destination_user_id` char(36) NOT NULL, - `destination_provider_id` varchar(255) NOT NULL, - `destination_user` varchar(255) NOT NULL, - `destination_domain` varchar(255) NOT NULL, - `destination_user_dialed` varchar(255) NOT NULL, - `destination_user_in` varchar(255) NOT NULL, - `destination_domain_in` varchar(255) NOT NULL, - `call_type` enum('call','cfu','cft','cfb','cfna') NOT NULL default 'call', - `call_status` enum('ok','busy','noanswer','cancel','offline','timeout','other') NOT NULL default 'ok', - `call_code` char(3) NOT NULL, - `start_time` timestamp NOT NULL default '0000-00-00 00:00:00', - `duration` int(10) unsigned NOT NULL, - `call_id` varchar(255) NOT NULL, - `carrier_cost` float default NULL, - `reseller_cost` float default NULL, - `customer_cost` float default NULL, - `carrier_billing_fee_id` int(11) unsigned default NULL, - `reseller_billing_fee_id` int(11) unsigned default NULL, - `customer_billing_fee_id` int(11) unsigned default NULL, - `carrier_billing_zone_id` int(11) unsigned default NULL, - `reseller_billing_zone_id` int(11) unsigned default NULL, - `customer_billing_zone_id` int(11) unsigned default NULL, - `frag_carrier_onpeak` tinyint(1) default NULL, - `frag_reseller_onpeak` tinyint(1) default NULL, - `frag_customer_onpeak` tinyint(1) default NULL, - `is_fragmented` tinyint(1) default NULL, - `rated_at` datetime default NULL, - `rating_status` enum('unrated','ok','failed') NOT NULL default 'unrated', - PRIMARY KEY (`id`), - KEY `suid` (`source_user_id`), - KEY `duid` (`destination_user_id`), - KEY `suri` (`source_user`,`source_domain`,`source_cli`), - KEY `duri` (`destination_user`,`destination_domain`), - KEY `sprov` (`source_provider_id`), - KEY `dprov` (`destination_provider_id`), - KEY `kcid` (`call_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `mark` ( - `id` int(10) unsigned NOT NULL auto_increment, - `collector` varchar(255) NOT NULL, - `acc_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - diff --git a/db_scripts/base/tmp/0050_create_kamailio_301.up b/db_scripts/base/tmp/0050_create_kamailio_301.up deleted file mode 100644 index 473e2871..00000000 --- a/db_scripts/base/tmp/0050_create_kamailio_301.up +++ /dev/null @@ -1,324 +0,0 @@ -USE mysql; -DROP DATABASE IF EXISTS kamailio; - -CREATE DATABASE IF NOT EXISTS kamailio CHARACTER SET 'latin1'; - -USE kamailio; - -CREATE TABLE `acc` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `method` varchar(16) NOT NULL DEFAULT '', - `from_tag` varchar(64) NOT NULL DEFAULT '', - `to_tag` varchar(64) NOT NULL DEFAULT '', - `callid` varchar(64) NOT NULL DEFAULT '', - `sip_code` varchar(3) NOT NULL DEFAULT '', - `sip_reason` varchar(128) NOT NULL DEFAULT '', - `time` datetime NOT NULL, - `src_leg` varchar(255) default NULL, - `dst_leg` varchar(255) default NULL, - `dst_user` varchar(64) NOT NULL default '', - `dst_ouser` varchar(64) NOT NULL default '', - `dst_domain` varchar(128) NOT NULL default '', - `src_user` varchar(64) NOT NULL default '', - `src_domain` varchar(128) NOT NULL default '', - PRIMARY KEY (`id`), - KEY `callid_idx` (`callid`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `dbaliases` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `alias_username` varchar(64) NOT NULL DEFAULT '', - `alias_domain` varchar(64) NOT NULL DEFAULT '', - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - UNIQUE KEY `alias_idx` (`alias_username`,`alias_domain`), - KEY `target_idx` (`username`,`domain`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `dialog` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `hash_entry` int(10) unsigned NOT NULL, - `hash_id` int(10) unsigned NOT NULL, - `callid` varchar(255) NOT NULL, - `from_uri` varchar(128) NOT NULL, - `from_tag` varchar(64) NOT NULL, - `to_uri` varchar(128) NOT NULL, - `to_tag` varchar(64) NOT NULL, - `caller_cseq` varchar(7) NOT NULL, - `callee_cseq` varchar(7) NOT NULL, - `caller_route_set` varchar(512) DEFAULT NULL, - `callee_route_set` varchar(512) DEFAULT NULL, - `caller_contact` varchar(128) NOT NULL, - `callee_contact` varchar(128) NOT NULL, - `caller_sock` varchar(64) NOT NULL, - `callee_sock` varchar(64) NOT NULL, - `state` int(10) unsigned NOT NULL, - `start_time` int(10) unsigned NOT NULL, - `timeout` int(10) unsigned NOT NULL DEFAULT '0', - `sflags` int(10) unsigned NOT NULL DEFAULT '0', - `toroute` int(10) unsigned NOT NULL DEFAULT '0', - `req_uri` varchar(128) NOT NULL, - PRIMARY KEY (`id`), - KEY `hash_idx` (`hash_entry`,`hash_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `dialplan` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `dpid` int(11) NOT NULL, - `pr` int(11) NOT NULL, - `match_op` int(11) NOT NULL, - `match_exp` varchar(64) NOT NULL, - `match_len` int(11) NOT NULL, - `subst_exp` varchar(64) NOT NULL, - `repl_exp` varchar(32) NOT NULL, - `attrs` varchar(32) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `dispatcher` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `setid` int(11) NOT NULL DEFAULT '0', - `destination` varchar(192) NOT NULL DEFAULT '', - `flags` int(11) NOT NULL DEFAULT '0', - `priority` int(11) NOT NULL DEFAULT '0', - `description` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `domain` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `domain` varchar(64) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - UNIQUE KEY `domain_idx` (`domain`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `gw` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `gw_name` varchar(128) NOT NULL, - `grp_id` int(10) unsigned NOT NULL, - `ip_addr` varchar(15) NOT NULL, - `hostname` varchar(64) DEFAULT NULL, - `port` smallint(5) unsigned DEFAULT NULL, - `uri_scheme` tinyint(3) unsigned DEFAULT NULL, - `transport` tinyint(3) unsigned DEFAULT NULL, - `strip` tinyint(3) unsigned DEFAULT NULL, - `tag` varchar(16) DEFAULT NULL, - `weight` int(10) unsigned DEFAULT NULL, - `flags` int(10) unsigned NOT NULL DEFAULT '0', - `defunct` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `lcr_id_grp_id_gw_name_idx` (`lcr_id`,`grp_id`,`gw_name`), - UNIQUE KEY `lcr_id_grp_id_ip_addr_idx` (`lcr_id`,`grp_id`,`ip_addr`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `lcr` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `lcr_id` smallint(5) unsigned NOT NULL, - `prefix` varchar(16) DEFAULT NULL, - `from_uri` varchar(64) DEFAULT NULL, - `grp_id` int(10) unsigned NOT NULL, - `priority` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `lcr_id_idx` (`lcr_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `location` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) DEFAULT NULL, - `contact` varchar(255) NOT NULL DEFAULT '', - `received` varchar(128) DEFAULT NULL, - `path` varchar(128) DEFAULT NULL, - `expires` datetime NOT NULL DEFAULT '2020-05-28 21:32:15', - `q` float(10,2) NOT NULL DEFAULT '1.00', - `callid` varchar(255) NOT NULL DEFAULT 'Default-Call-ID', - `cseq` int(11) NOT NULL DEFAULT '13', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - `flags` int(11) NOT NULL DEFAULT '0', - `cflags` int(11) NOT NULL DEFAULT '0', - `user_agent` varchar(255) NOT NULL DEFAULT '', - `socket` varchar(64) DEFAULT NULL, - `methods` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `account_contact_idx` (`username`,`domain`,`contact`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `speed_dial` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - `sd_username` varchar(64) NOT NULL DEFAULT '', - `sd_domain` varchar(64) NOT NULL DEFAULT '', - `new_uri` varchar(128) NOT NULL DEFAULT '', - `fname` varchar(64) NOT NULL DEFAULT '', - `lname` varchar(64) NOT NULL DEFAULT '', - `description` varchar(64) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - UNIQUE KEY `speed_dial_idx` (`username`,`domain`,`sd_domain`,`sd_username`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `subscriber` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '', - `domain` varchar(64) NOT NULL DEFAULT '', - `password` varchar(25) NOT NULL DEFAULT '', - `email_address` varchar(64) NOT NULL DEFAULT '', - `ha1` varchar(64) NOT NULL DEFAULT '', - `ha1b` varchar(64) NOT NULL DEFAULT '', - `rpid` varchar(64) DEFAULT NULL, - `uuid` char(36) NOT NULL, - `timezone` varchar(64) NOT NULL DEFAULT '', - `datetime_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - UNIQUE KEY `account_idx` (`username`,`domain`), - KEY `username_idx` (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `trusted` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `src_ip` varchar(50) NOT NULL, - `proto` varchar(4) NOT NULL, - `from_pattern` varchar(64) DEFAULT NULL, - `tag` varchar(64) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `peer_idx` (`src_ip`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `usr_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` char(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`), - KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `dom_preferences` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `uuid` char(36) NOT NULL, - `username` varchar(128) NOT NULL DEFAULT '0', - `domain` varchar(64) NOT NULL DEFAULT '', - `attribute` varchar(32) NOT NULL DEFAULT '', - `type` int(11) NOT NULL DEFAULT '0', - `value` varchar(128) NOT NULL DEFAULT '', - `last_modified` datetime NOT NULL DEFAULT '1900-01-01 00:00:01', - PRIMARY KEY (`id`), - KEY `ua_idx` (`uuid`,`attribute`), - KEY `uda_idx` (`username`,`domain`,`attribute`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `address` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `grp` smallint(5) unsigned NOT NULL DEFAULT '0', - `ip_addr` varchar(15) NOT NULL, - `mask` tinyint(4) NOT NULL DEFAULT '32', - `port` smallint(5) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `version` ( - `table_name` varchar(32) NOT NULL, - `table_version` int(10) unsigned NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `voicemail_users` ( - `uniqueid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `customer_id` char(36) NOT NULL DEFAULT '', - `context` varchar(63) NOT NULL DEFAULT 'default', - `mailbox` varchar(31) NOT NULL, - `password` varchar(31) NOT NULL DEFAULT '0', - `fullname` varchar(255) NOT NULL DEFAULT '', - `email` varchar(255) NOT NULL DEFAULT '', - `pager` varchar(255) NOT NULL DEFAULT '', - `tz` varchar(10) NOT NULL DEFAULT 'central', - `attach` varchar(4) NOT NULL DEFAULT 'yes', - `saycid` varchar(4) NOT NULL DEFAULT 'yes', - `dialout` varchar(10) NOT NULL DEFAULT '', - `callback` varchar(10) NOT NULL DEFAULT '', - `review` varchar(4) NOT NULL DEFAULT 'no', - `operator` varchar(4) NOT NULL DEFAULT 'no', - `envelope` varchar(4) NOT NULL DEFAULT 'no', - `sayduration` varchar(4) NOT NULL DEFAULT 'no', - `saydurationm` tinyint(4) NOT NULL DEFAULT '1', - `sendvoicemail` varchar(4) NOT NULL DEFAULT 'no', - `delete` varchar(4) NOT NULL DEFAULT 'no', - `nextaftercmd` varchar(4) NOT NULL DEFAULT 'yes', - `forcename` varchar(4) NOT NULL DEFAULT 'no', - `forcegreetings` varchar(4) NOT NULL DEFAULT 'no', - `hidefromdir` varchar(4) NOT NULL DEFAULT 'yes', - `stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`uniqueid`), - KEY `customer_idx` (`customer_id`), - KEY `mailbox_context` (`mailbox`,`context`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `voicemail_spool` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `msgnum` int(11) NOT NULL DEFAULT '0', - `dir` varchar(127) DEFAULT '', - `context` varchar(63) DEFAULT '', - `macrocontext` varchar(63) DEFAULT '', - `callerid` varchar(255) DEFAULT '', - `origtime` int(11) unsigned DEFAULT '0', - `duration` int(11) unsigned DEFAULT '0', - `mailboxuser` varchar(255) DEFAULT '', - `mailboxcontext` varchar(63) DEFAULT '', - `recording` longblob, - PRIMARY KEY (`id`), - KEY `dir` (`dir`), - KEY `mailboxuser_idx` (`mailboxuser`), - CONSTRAINT `v_s_mailboxuser_ref` FOREIGN KEY (`mailboxuser`) REFERENCES `voicemail_users` (`customer_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `fax_preferences` ( - `subscriber_id` int(10) unsigned NOT NULL, - `password` varchar(64) default NULL, - `name` varchar(64) default NULL, - `active` enum('true','false') NOT NULL default 'true', - `send_status` enum('true','false') NOT NULL default 'false', - `send_copy` enum('true','false') NOT NULL default 'false', - `send_copy_cc` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -CREATE TABLE `fax_destinations` ( - `id` int(10) unsigned NOT NULL auto_increment, - `subscriber_id` int(10) unsigned NOT NULL, - `destination` varchar(64) NOT NULL, - `filetype` enum('ps','tiff','pdf','pdf14') NOT NULL default 'tiff', - `cc` enum('true','false') NOT NULL default 'false', - `incoming` enum('true','false') NOT NULL default 'true', - `outgoing` enum('true','false') NOT NULL default 'false', - `status` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`id`), - KEY `subscriber_id` (`subscriber_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -INSERT INTO `version` VALUES - ('acc',4), - ('gw',10), - ('lcr',3), - ('domain',1), - ('trusted',5), - ('location',1004), - ('dbaliases',1), - ('speed_dial',2), - ('usr_preferences',2), - ('subscriber',6), - ('dialog',4), - ('dispatcher',3), - ('address',3), - ('dialplan',1); - - -INSERT INTO `dispatcher` VALUES ('1','2','sip:127.0.0.1:5070','0','0','Voicemail servers'); -INSERT INTO `dispatcher` VALUES ('2','3','sip:127.0.0.1:5080','0','0','Application servers'); -INSERT INTO `dispatcher` VALUES ('3','4','sip:127.0.0.1:5090','0','0','Fax2Mail servers'); diff --git a/db_scripts/base/tmp/0060_create_faxserver.up b/db_scripts/base/tmp/0060_create_faxserver.up deleted file mode 100644 index 58651113..00000000 --- a/db_scripts/base/tmp/0060_create_faxserver.up +++ /dev/null @@ -1,61 +0,0 @@ -USE `kamailio`; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - - -DROP TABLE IF EXISTS `fax_destinations`; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `fax_destinations` ( - `id` int(10) unsigned NOT NULL auto_increment, - `subscriber_id` int(10) unsigned NOT NULL, - `destination` varchar(64) NOT NULL, - `filetype` enum('ps','tiff','pdf','pdf14') NOT NULL default 'tiff', - `cc` enum('true','false') NOT NULL default 'false', - `incoming` enum('true','false') NOT NULL default 'true', - `outgoing` enum('true','false') NOT NULL default 'false', - `status` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`id`), - KEY `subscriber_id` (`subscriber_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -SET character_set_client = @saved_cs_client; - - - - -DROP TABLE IF EXISTS `fax_preferences`; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `fax_preferences` ( - `subscriber_id` int(10) unsigned NOT NULL, - `password` varchar(64), - `name` varchar(64), - `active` enum('true','false') NOT NULL default 'true', - `send_status` enum('true','false') NOT NULL default 'false', - `send_copy` enum('true','false') NOT NULL default 'false', - `send_copy_cc` enum('true','false') NOT NULL default 'false', - PRIMARY KEY (`subscriber_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; -SET character_set_client = @saved_cs_client; - - - -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; diff --git a/db_scripts/base/tmp/0070_create_no_replicates.up b/db_scripts/base/tmp/0070_create_no_replicates.up deleted file mode 100644 index 11d9a66b..00000000 --- a/db_scripts/base/tmp/0070_create_no_replicates.up +++ /dev/null @@ -1,8 +0,0 @@ -USE accounting; -create table acc_backup like kamailio.acc; -create table acc_trash like kamailio.acc; - -USE kamailio; -create table acc_backup like kamailio.acc; -create table acc_trash like kamailio.acc; - diff --git a/db_scripts/base/tmp/0080_create_oss_triggers_kamailio.up b/db_scripts/base/tmp/0080_create_oss_triggers_kamailio.up deleted file mode 100644 index 585a892a..00000000 --- a/db_scripts/base/tmp/0080_create_oss_triggers_kamailio.up +++ /dev/null @@ -1,862 +0,0 @@ - -USE provisioning; - --- create triggers that populate kamailio tables -DELIMITER | - -CREATE TRIGGER voip_sub_crepl_trig AFTER INSERT ON voip_subscribers - FOR EACH ROW BEGIN - DECLARE subscriber_domain varchar(127); - - SELECT domain INTO subscriber_domain FROM voip_domains where id = NEW.domain_id; - - INSERT INTO kamailio.subscriber (username, domain, uuid, timezone, password, datetime_created, ha1, ha1b) - VALUES(NEW.username, subscriber_domain, NEW.uuid, NEW.timezone, NEW.password, now(), - MD5(CONCAT(NEW.username, ':', subscriber_domain, ':', NEW.password)), - MD5(CONCAT(NEW.username, '@', subscriber_domain, ':', subscriber_domain, ':', NEW.password))); - END; -| - -CREATE TRIGGER voip_sub_urepl_trig AFTER UPDATE ON voip_subscribers - FOR EACH ROW BEGIN - DECLARE old_subscriber_domain varchar(127); - DECLARE new_subscriber_domain varchar(127); - - SELECT domain INTO old_subscriber_domain FROM voip_domains where id = OLD.domain_id; - SELECT domain INTO new_subscriber_domain FROM voip_domains where id = NEW.domain_id; - - UPDATE kamailio.subscriber SET username = NEW.username, domain = new_subscriber_domain, - uuid = NEW.uuid, timezone = NEW.timezone, password = NEW.password, - ha1 = MD5(CONCAT(NEW.username, ':', new_subscriber_domain, ':', NEW.password)), - ha1b = MD5(CONCAT(NEW.username, '@', new_subscriber_domain, ':', new_subscriber_domain, ':', NEW.password)) - WHERE username = OLD.username - AND domain = old_subscriber_domain; - END; -| - -CREATE TRIGGER voip_sub_drepl_trig BEFORE DELETE ON voip_subscribers - FOR EACH ROW BEGIN - DECLARE subscriber_domain varchar(127); - DECLARE os_subscriber_id int(10) UNSIGNED; - - SELECT domain INTO subscriber_domain FROM voip_domains where id = OLD.domain_id; - SELECT id INTO os_subscriber_id FROM kamailio.subscriber - WHERE username = OLD.username AND domain = subscriber_domain; - - DELETE FROM kamailio.subscriber WHERE username = OLD.username - AND domain = subscriber_domain; - - -- should be implemented via a provisioning.voicemail_users table - -- and a foreign key to voip_subscribers - DELETE FROM kamailio.voicemail_users WHERE customer_id = OLD.uuid; - - -- work around MySQL bug. the cascaded delete should trigger our - -- delete actions on the provisioning tables, but doesn't - DELETE FROM kamailio.usr_preferences WHERE username = OLD.username - AND domain = subscriber_domain; - DELETE FROM kamailio.dbaliases WHERE username = OLD.username - AND domain = subscriber_domain; - DELETE FROM kamailio.speed_dial WHERE username = OLD.username - AND domain = subscriber_domain; - DELETE FROM kamailio.fax_preferences WHERE subscriber_id = os_subscriber_id; - DELETE FROM kamailio.fax_destinations WHERE subscriber_id = os_subscriber_id; - END; -| - -CREATE TRIGGER voip_dba_crepl_trig AFTER INSERT ON voip_dbaliases - FOR EACH ROW BEGIN - DECLARE dbalias_domain varchar(127); - DECLARE target_username varchar(127); - DECLARE target_domain varchar(127); - - SELECT domain INTO dbalias_domain FROM voip_domains where id = NEW.domain_id; - SELECT a.username, b.domain INTO target_username, target_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - INSERT INTO kamailio.dbaliases (alias_username, alias_domain, username, domain) - VALUES(NEW.username, dbalias_domain, target_username, target_domain); - END; -| - -CREATE TRIGGER voip_dba_urepl_trig AFTER UPDATE ON voip_dbaliases - FOR EACH ROW BEGIN - DECLARE old_dbalias_domain varchar(127); - DECLARE new_dbalias_domain varchar(127); - DECLARE target_username varchar(127); - DECLARE target_domain varchar(127); - - SELECT domain INTO old_dbalias_domain FROM voip_domains where id = OLD.domain_id; - SELECT domain INTO new_dbalias_domain FROM voip_domains where id = NEW.domain_id; - SELECT a.username, b.domain INTO target_username, target_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - UPDATE kamailio.dbaliases SET alias_username = NEW.username, alias_domain = new_dbalias_domain, - username = target_username, domain = target_domain - WHERE alias_username = OLD.username - AND alias_domain = old_dbalias_domain; - END; -| - -CREATE TRIGGER voip_dba_drepl_trig BEFORE DELETE ON voip_dbaliases - FOR EACH ROW BEGIN - DECLARE dbalias_domain varchar(127); - - SELECT domain INTO dbalias_domain FROM voip_domains where id = OLD.domain_id; - - DELETE FROM kamailio.dbaliases WHERE alias_username = OLD.username - AND alias_domain = dbalias_domain; - END; -| - -CREATE TRIGGER voip_prul_crepl_trig AFTER INSERT ON voip_peer_rules - FOR EACH ROW BEGIN - DECLARE prio int(11) unsigned; - - SELECT priority INTO prio FROM voip_peer_groups - WHERE id = NEW.group_id; - - INSERT INTO kamailio.lcr (lcr_id, prefix, from_uri, grp_id, priority) - VALUES(1, NEW.callee_prefix, IF(LENGTH(NEW.caller_prefix), CONCAT('^', NEW.caller_prefix), ''), NEW.group_id, prio); - - END; -| - -CREATE TRIGGER voip_prul_urepl_trig AFTER UPDATE ON voip_peer_rules - FOR EACH ROW BEGIN - DECLARE prio int(11) unsigned; - - SELECT priority INTO prio FROM voip_peer_groups - WHERE id = NEW.group_id; - - UPDATE kamailio.lcr SET prefix = NEW.callee_prefix, - from_uri = IF(LENGTH(NEW.caller_prefix), CONCAT('^', NEW.caller_prefix), '') - WHERE grp_id = OLD.group_id - AND prefix = OLD.callee_prefix - AND from_uri = IF(LENGTH(OLD.caller_prefix), CONCAT('^', OLD.caller_prefix), '') - AND priority = prio; - - END; -| - -CREATE TRIGGER voip_pgrp_urepl_trig AFTER UPDATE ON voip_peer_groups - FOR EACH ROW BEGIN - - UPDATE kamailio.lcr SET priority = NEW.priority - WHERE grp_id = NEW.id; - - END; -| - -CREATE TRIGGER voip_prul_drepl_trig AFTER DELETE ON voip_peer_rules - FOR EACH ROW BEGIN - DECLARE prio int(11) unsigned; - - SELECT priority INTO prio FROM voip_peer_groups - WHERE id = OLD.group_id; - - DELETE FROM kamailio.lcr - WHERE grp_id = OLD.group_id AND - prefix = OLD.callee_prefix AND - from_uri = IF(LENGTH(OLD.caller_prefix), CONCAT('^', OLD.caller_prefix), '') AND - priority = prio; - - END; -| - -CREATE TRIGGER voip_pgrp_drepl_trig AFTER DELETE ON voip_peer_groups - FOR EACH ROW BEGIN - - DELETE FROM kamailio.lcr WHERE grp_id = OLD.id; - DELETE FROM kamailio.gw WHERE grp_id = OLD.id; - - END; -| - -CREATE TRIGGER voip_phost_crepl_trig AFTER INSERT ON voip_peer_hosts - FOR EACH ROW BEGIN - - INSERT INTO kamailio.gw (lcr_id, gw_name, grp_id, ip_addr, port, weight, - uri_scheme, transport, strip, tag, flags, defunct) VALUES - (1, NEW.name, NEW.group_id, NEW.ip, NEW.port, NEW.weight, - 1, 1, 0, NULL, NEW.id, NULL); - - END; -| - -CREATE TRIGGER voip_phost_urepl_trig AFTER UPDATE ON voip_peer_hosts - FOR EACH ROW BEGIN - - UPDATE kamailio.gw SET gw_name = NEW.name, - ip_addr = NEW.ip, port = NEW.port, weight = NEW.weight, tag = NULL - WHERE grp_id = OLD.group_id AND gw_name = OLD.name AND - ip_addr = OLD.ip AND port = OLD.port AND weight = OLD.weight; - - END; -| - -CREATE TRIGGER voip_phost_drepl_trig AFTER DELETE ON voip_peer_hosts - FOR EACH ROW BEGIN - - DELETE FROM kamailio.gw - WHERE grp_id = OLD.group_id AND gw_name = OLD.name AND - ip_addr = OLD.ip AND port = OLD.port AND weight = OLD.weight; - DELETE FROM kamailio.dialplan - WHERE dpid IN (OLD.dp_caller_in_id, OLD.dp_callee_in_id, - OLD.dp_caller_out_id, OLD.dp_callee_out_id); - - END; -| - - -CREATE TRIGGER voip_domrw_crepl_trig AFTER INSERT ON voip_domain_rewrites - FOR EACH ROW BEGIN - - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - - IF NEW.direction = 'in' AND NEW.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - INSERT INTO kamailio.dialplan (dpid, pr, match_op, match_exp, - match_len, subst_exp, repl_exp, attrs) - VALUES(dp_id, NEW.priority, 1, NEW.match_pattern, 0, NEW.match_pattern, NEW.replace_pattern, ''); - - END; -| - -CREATE TRIGGER voip_domrw_urepl_trig AFTER UPDATE ON voip_domain_rewrites - FOR EACH ROW BEGIN - - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_caller_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = NEW.domain_id AND vp.attribute = 'dp_dom_callee_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - - IF NEW.direction = 'in' AND NEW.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - UPDATE kamailio.dialplan SET match_exp = NEW.match_pattern, - subst_exp = NEW.match_pattern, repl_exp = NEW.replace_pattern, pr = NEW.priority - WHERE dpid = dp_id AND match_exp = OLD.match_pattern AND pr = OLD.priority - AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_domrw_drepl_trig AFTER DELETE ON voip_domain_rewrites - FOR EACH ROW BEGIN - - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_caller_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_callee_in' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_caller_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp, - voip_domains vd WHERE vd.id = OLD.domain_id AND vp.attribute = 'dp_dom_callee_out' - AND vdp.attribute_id = vp.id AND vd.id = vdp.domain_id; - - IF OLD.direction = 'in' AND OLD.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF OLD.direction = 'in' AND OLD.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF OLD.direction = 'out' AND OLD.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF OLD.direction = 'out' AND OLD.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - DELETE FROM kamailio.dialplan - WHERE dpid = dp_id AND match_exp = OLD.match_pattern - AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_peerrw_crepl_trig AFTER INSERT ON voip_peer_rewrites - FOR EACH ROW BEGIN - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id - INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id - FROM voip_peer_hosts WHERE id = NEW.peer_id; - - IF NEW.direction = 'in' AND NEW.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - INSERT INTO kamailio.dialplan (dpid, pr, match_op, match_exp, - match_len, subst_exp, repl_exp, attrs) - VALUES(dp_id, NEW.priority, 1, NEW.match_pattern, 0, NEW.match_pattern, NEW.replace_pattern, ''); - - END; -| - -CREATE TRIGGER voip_peerrw_urepl_trig AFTER UPDATE ON voip_peer_rewrites - FOR EACH ROW BEGIN - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id - INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id - FROM voip_peer_hosts WHERE id = NEW.peer_id; - - IF NEW.direction = 'in' AND NEW.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF NEW.direction = 'in' AND NEW.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF NEW.direction = 'out' AND NEW.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - UPDATE kamailio.dialplan SET match_exp = NEW.match_pattern, - subst_exp = NEW.match_pattern, repl_exp = NEW.replace_pattern, - pr = NEW.priority - WHERE dpid = dp_id AND match_exp = OLD.match_pattern AND pr = OLD.priority - AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_peerrw_drepl_trig AFTER DELETE ON voip_peer_rewrites - FOR EACH ROW BEGIN - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - DECLARE dp_id int(11) unsigned default 0; - - SELECT dp_caller_in_id, dp_callee_in_id, dp_caller_out_id, dp_callee_out_id - INTO caller_in_id, callee_in_id, caller_out_id, callee_out_id - FROM voip_peer_hosts WHERE id = OLD.peer_id; - - IF OLD.direction = 'in' AND OLD.field = 'caller' THEN - SET dp_id = caller_in_id; - ELSEIF OLD.direction = 'in' AND OLD.field = 'callee' THEN - SET dp_id = callee_in_id; - ELSEIF OLD.direction = 'out' AND OLD.field = 'caller' THEN - SET dp_id = caller_out_id; - ELSEIF OLD.direction = 'out' AND OLD.field = 'callee' THEN - SET dp_id = callee_out_id; - END IF; - - DELETE FROM kamailio.dialplan - WHERE dpid = dp_id AND match_exp = OLD.match_pattern - AND subst_exp = OLD.match_pattern AND repl_exp = OLD.replace_pattern; - - END; -| - -CREATE TRIGGER voip_usrpref_crepl_trig AFTER INSERT ON voip_usr_preferences - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE subscriber_uuid char(36); - DECLARE attribute_name varchar(31); - DECLARE attribute_type tinyint(3); - - SELECT a.username, b.domain, a.uuid INTO subscriber_username, subscriber_domain, subscriber_uuid - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND a.domain_id = b.id; - SELECT attribute, type INTO attribute_name, attribute_type - FROM voip_preferences - WHERE id = NEW.attribute_id; - - INSERT INTO kamailio.usr_preferences (uuid, username, domain, attribute, type, value) - VALUES(subscriber_uuid, subscriber_username, subscriber_domain, - attribute_name, attribute_type, NEW.value); - END; -| - -CREATE TRIGGER voip_usrpref_urepl_trig AFTER UPDATE ON voip_usr_preferences - FOR EACH ROW BEGIN - DECLARE old_subscriber_username varchar(127); - DECLARE new_subscriber_username varchar(127); - DECLARE old_subscriber_domain varchar(127); - DECLARE new_subscriber_domain varchar(127); - DECLARE old_attribute_name varchar(31); - DECLARE new_attribute_name varchar(31); - - SELECT a.username, b.domain INTO old_subscriber_username, old_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND a.domain_id = b.id; - SELECT a.username, b.domain INTO new_subscriber_username, new_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND a.domain_id = b.id; - SELECT attribute INTO old_attribute_name - FROM voip_preferences - WHERE id = OLD.attribute_id; - SELECT attribute INTO new_attribute_name - FROM voip_preferences - WHERE id = NEW.attribute_id; - - UPDATE kamailio.usr_preferences SET username = new_subscriber_username, domain = new_subscriber_domain, - attribute = new_attribute_name, value = NEW.value - WHERE username = old_subscriber_username - AND domain = old_subscriber_domain - AND attribute = old_attribute_name - AND value = OLD.value; - END; -| - -CREATE TRIGGER voip_usrpref_drepl_trig BEFORE DELETE ON voip_usr_preferences - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE attribute_name varchar(31); - - SELECT a.username, b.domain INTO subscriber_username, subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND a.domain_id = b.id; - SELECT attribute INTO attribute_name - FROM voip_preferences - WHERE id = OLD.attribute_id; - - DELETE FROM kamailio.usr_preferences WHERE username = subscriber_username - AND domain = subscriber_domain - AND attribute = attribute_name - AND value = OLD.value; - END; -| - -CREATE TRIGGER voip_dom_crepl_trig AFTER INSERT ON voip_domains - FOR EACH ROW BEGIN - - IF NEW.local IS TRUE THEN - INSERT INTO kamailio.domain (domain) VALUES(NEW.domain); - END IF; - - END; -| - -CREATE TRIGGER voip_dom_urepl_trig AFTER UPDATE ON voip_domains - FOR EACH ROW BEGIN - - IF NEW.local IS TRUE AND OLD.local IS FALSE THEN - INSERT INTO kamailio.domain (domain) VALUES(NEW.domain); - ELSEIF NEW.local IS FALSE AND OLD.local IS TRUE THEN - DELETE FROM kamailio.domain WHERE domain = OLD.domain; - END IF; - - END; -| - -CREATE TRIGGER voip_dom_drepl_trig BEFORE DELETE ON voip_domains - FOR EACH ROW BEGIN - - DECLARE caller_in_id int(11) unsigned; - DECLARE callee_in_id int(11) unsigned; - DECLARE caller_out_id int(11) unsigned; - DECLARE callee_out_id int(11) unsigned; - - SELECT vdp.value INTO caller_in_id FROM voip_dom_preferences vdp, voip_preferences vp - WHERE vp.attribute = 'dp_dom_caller_in' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; - SELECT vdp.value INTO callee_in_id FROM voip_dom_preferences vdp, voip_preferences vp - WHERE vp.attribute = 'dp_dom_callee_in' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; - SELECT vdp.value INTO caller_out_id FROM voip_dom_preferences vdp, voip_preferences vp - WHERE vp.attribute = 'dp_dom_caller_out' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; - SELECT vdp.value INTO callee_out_id FROM voip_dom_preferences vdp, voip_preferences vp - WHERE vp.attribute = 'dp_dom_callee_out' AND vdp.attribute_id = vp.id AND vdp.domain_id = OLD.id; - - IF OLD.local IS TRUE THEN - DELETE FROM kamailio.domain WHERE domain = OLD.domain; - END IF; - - DELETE FROM kamailio.dialplan WHERE dpid IN - (caller_in_id, callee_in_id, caller_out_id, callee_out_id); - - -- work around MySQL bug. the cascaded delete should trigger our - -- voip_dom_preferences delete action, but doesn't - DELETE FROM kamailio.dom_preferences WHERE domain = OLD.domain; - -- this will trigger the delete action for each subscriber - DELETE FROM provisioning.voip_subscribers WHERE domain_id = OLD.id; - - - END; -| - -CREATE TRIGGER voip_dompref_crepl_trig AFTER INSERT ON voip_dom_preferences - FOR EACH ROW BEGIN - DECLARE domain_name varchar(127); - DECLARE attribute_name varchar(31); - DECLARE attribute_type tinyint(3); - - SELECT domain INTO domain_name - FROM voip_domains - WHERE id = NEW.domain_id; - SELECT attribute, type INTO attribute_name, attribute_type - FROM voip_preferences - WHERE id = NEW.attribute_id; - - INSERT INTO kamailio.dom_preferences (domain, attribute, type, value) - VALUES(domain_name, attribute_name, attribute_type, NEW.value); - END; -| - -CREATE TRIGGER voip_dompref_urepl_trig AFTER UPDATE ON voip_dom_preferences - FOR EACH ROW BEGIN - DECLARE old_domain_name varchar(127); - DECLARE new_domain_name varchar(127); - DECLARE old_attribute_name varchar(31); - DECLARE new_attribute_name varchar(31); - - SELECT domain INTO old_domain_name - FROM voip_domains - WHERE id = OLD.domain_id; - SELECT domain INTO new_domain_name - FROM voip_domains - WHERE id = NEW.domain_id; - SELECT attribute INTO old_attribute_name - FROM voip_preferences - WHERE id = OLD.attribute_id; - SELECT attribute INTO new_attribute_name - FROM voip_preferences - WHERE id = NEW.attribute_id; - - UPDATE kamailio.dom_preferences SET domain = new_domain_name, - attribute = new_attribute_name, - value = NEW.value - WHERE domain = old_domain_name - AND attribute = old_attribute_name - AND value = OLD.value; - END; -| - -CREATE TRIGGER voip_dompref_drepl_trig BEFORE DELETE ON voip_dom_preferences - FOR EACH ROW BEGIN - DECLARE domain_name varchar(127); - DECLARE attribute_name varchar(31); - - SELECT domain INTO domain_name - FROM voip_domains - WHERE id = OLD.domain_id; - SELECT attribute INTO attribute_name - FROM voip_preferences - WHERE id = OLD.attribute_id; - - DELETE FROM kamailio.dom_preferences WHERE domain = domain_name - AND attribute = attribute_name - AND value = OLD.value; - END; -| - -CREATE TRIGGER voip_sd_crepl_trig AFTER INSERT ON voip_speed_dial - FOR EACH ROW BEGIN - DECLARE target_username varchar(64); - DECLARE target_domain varchar(64); - - SELECT a.username, b.domain INTO target_username, target_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - INSERT INTO kamailio.speed_dial (username, domain, sd_username, sd_domain, - new_uri, fname, lname, description) - VALUES(target_username, target_domain, - NEW.slot, target_domain, - NEW.destination, '', '', ''); - END; -| - -CREATE TRIGGER voip_sd_urepl_trig AFTER UPDATE ON voip_speed_dial - FOR EACH ROW BEGIN - DECLARE old_username varchar(127); - DECLARE old_domain varchar(127); - DECLARE new_username varchar(127); - DECLARE new_domain varchar(127); - - SELECT a.username, b.domain INTO old_username, old_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - SELECT a.username, b.domain INTO new_username, new_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - UPDATE kamailio.speed_dial SET username = new_username, domain = new_domain, - sd_username = NEW.slot, sd_domain = new_domain, - new_uri = NEW.destination - WHERE username = old_username - AND domain = old_domain - AND sd_username = OLD.slot; - END; -| - -CREATE TRIGGER voip_sd_drepl_trig BEFORE DELETE ON voip_speed_dial - FOR EACH ROW BEGIN - DECLARE old_username varchar(127); - DECLARE old_domain varchar(127); - - SELECT a.username, b.domain INTO old_username, old_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - - DELETE FROM kamailio.speed_dial WHERE username = old_username - AND domain = old_domain - AND sd_username = OLD.slot; - END; -| - -CREATE TRIGGER voip_faxp_crepl_trig AFTER INSERT ON voip_fax_preferences - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO subscriber_username, subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO os_subscriber_id FROM kamailio.subscriber - WHERE username = subscriber_username AND domain = subscriber_domain; - - INSERT INTO kamailio.fax_preferences - (subscriber_id, password, name, active, send_status, send_copy) - VALUES(os_subscriber_id, NEW.password, NEW.name, IF(NEW.active, 'true', 'false'), - IF(NEW.send_status, 'true', 'false'), IF(NEW.send_copy, 'true', 'false')); - - END; -| - -CREATE TRIGGER voip_faxp_urepl_trig AFTER UPDATE ON voip_fax_preferences - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE os_subscriber_id int(10) UNSIGNED; - DECLARE old_subscriber_username varchar(127); - DECLARE old_subscriber_domain varchar(127); - DECLARE old_os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO subscriber_username, subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO os_subscriber_id FROM kamailio.subscriber - WHERE username = subscriber_username AND domain = subscriber_domain; - - SELECT a.username, b.domain INTO old_subscriber_username, old_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO old_os_subscriber_id FROM kamailio.subscriber - WHERE username = old_subscriber_username AND domain = old_subscriber_domain; - - UPDATE kamailio.fax_preferences SET subscriber_id = os_subscriber_id, password = NEW.password, - name = NEW.name, active = IF(NEW.active, 'true', 'false'), - send_status = IF(NEW.send_status, 'true', 'false'), - send_copy = IF(NEW.send_copy, 'true', 'false') - WHERE subscriber_id = old_os_subscriber_id; - - END; -| - -CREATE TRIGGER voip_faxp_drepl_trig BEFORE DELETE ON voip_fax_preferences - FOR EACH ROW BEGIN - DECLARE old_subscriber_username varchar(127); - DECLARE old_subscriber_domain varchar(127); - DECLARE old_os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO old_subscriber_username, old_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO old_os_subscriber_id FROM kamailio.subscriber - WHERE username = old_subscriber_username AND domain = old_subscriber_domain; - - DELETE FROM kamailio.fax_preferences WHERE subscriber_id = old_os_subscriber_id; - - END; -| - -CREATE TRIGGER voip_faxd_crepl_trig AFTER INSERT ON voip_fax_destinations - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO subscriber_username, subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO os_subscriber_id FROM kamailio.subscriber - WHERE username = subscriber_username AND domain = subscriber_domain; - - INSERT INTO kamailio.fax_destinations (subscriber_id, destination, filetype, - cc, incoming, outgoing, status) - VALUES(os_subscriber_id, NEW.destination, NEW.filetype, - IF(NEW.cc, 'true', 'false'), IF(NEW.incoming, 'true', 'false'), - IF(NEW.outgoing, 'true', 'false'), IF(NEW.status, 'true', 'false')); - - END; -| - -CREATE TRIGGER voip_faxd_urepl_trig AFTER UPDATE ON voip_fax_destinations - FOR EACH ROW BEGIN - DECLARE subscriber_username varchar(127); - DECLARE subscriber_domain varchar(127); - DECLARE os_subscriber_id int(10) UNSIGNED; - DECLARE old_subscriber_username varchar(127); - DECLARE old_subscriber_domain varchar(127); - DECLARE old_os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO subscriber_username, subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = NEW.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO os_subscriber_id FROM kamailio.subscriber - WHERE username = subscriber_username AND domain = subscriber_domain; - - SELECT a.username, b.domain INTO old_subscriber_username, old_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO old_os_subscriber_id FROM kamailio.subscriber - WHERE username = old_subscriber_username AND domain = old_subscriber_domain; - - UPDATE kamailio.fax_destinations SET subscriber_id = os_subscriber_id, destination = NEW.destination, - filetype = NEW.filetype, cc = IF(NEW.cc, 'true', 'false'), - incoming = IF(NEW.incoming, 'true', 'false'), - outgoing = IF(NEW.outgoing, 'true', 'false'), - status = IF(NEW.status, 'true', 'false') - WHERE subscriber_id = old_os_subscriber_id - AND destination = OLD.destination; - - END; -| - -CREATE TRIGGER voip_faxd_drepl_trig BEFORE DELETE ON voip_fax_destinations - FOR EACH ROW BEGIN - DECLARE old_subscriber_username varchar(127); - DECLARE old_subscriber_domain varchar(127); - DECLARE old_os_subscriber_id int(10) UNSIGNED; - - SELECT a.username, b.domain INTO old_subscriber_username, old_subscriber_domain - FROM voip_subscribers a, voip_domains b - WHERE a.id = OLD.subscriber_id - AND b.id = a.domain_id; - - SELECT id INTO old_os_subscriber_id FROM kamailio.subscriber - WHERE username = old_subscriber_username AND domain = old_subscriber_domain; - - DELETE FROM kamailio.fax_destinations WHERE subscriber_id = old_os_subscriber_id - AND destination = OLD.destination; - - END; -| - -CREATE TRIGGER voip_aig_crepl_trig AFTER INSERT ON voip_allowed_ip_groups - FOR EACH ROW BEGIN - - INSERT INTO kamailio.address (id, grp, ip_addr, mask) - VALUES(NEW.id, NEW.group_id, - IF(LOCATE('/', NEW.ipnet), SUBSTRING_INDEX(NEW.ipnet, '/', 1), NEW.ipnet), - IF(LOCATE('/', NEW.ipnet), SUBSTRING_INDEX(NEW.ipnet, '/', -1), 32)); - - END; -| - -CREATE TRIGGER voip_aig_urepl_trig AFTER UPDATE ON voip_allowed_ip_groups - FOR EACH ROW BEGIN - - UPDATE kamailio.address SET id = NEW.id, grp = NEW.group_id, - ip_addr = IF(LOCATE('/', NEW.ipnet), SUBSTRING_INDEX(NEW.ipnet, '/', 1), NEW.ipnet), - mask = IF(LOCATE('/', NEW.ipnet), SUBSTRING_INDEX(NEW.ipnet, '/', -1), 32) - WHERE id = OLD.id; - - END; -| - -CREATE TRIGGER voip_aig_drepl_trig BEFORE DELETE ON voip_allowed_ip_groups - FOR EACH ROW BEGIN - - DELETE FROM kamailio.address WHERE id = OLD.id; - - END; -| - -DELIMITER ; diff --git a/db_scripts/base/tmp/0090_create_syslog.up b/db_scripts/base/tmp/0090_create_syslog.up deleted file mode 100644 index 09524ed6..00000000 --- a/db_scripts/base/tmp/0090_create_syslog.up +++ /dev/null @@ -1,99 +0,0 @@ --- 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 syslog; - --- create DB with utf8 default charset, so we don't have to --- specify charset for each table -CREATE DATABASE IF NOT EXISTS syslog CHARACTER SET 'utf8'; - -USE syslog; - - -CREATE TABLE `se1` ( - `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, - `CustomerID` bigint(20) DEFAULT NULL, - `ReceivedAt` datetime DEFAULT NULL, - `DeviceReportedTime` datetime DEFAULT NULL, - `Facility` smallint(6) DEFAULT NULL, - `Priority` smallint(6) DEFAULT NULL, - `FromHost` varchar(60) DEFAULT NULL, - `Message` text, - `NTSeverity` int(11) DEFAULT NULL, - `Importance` int(11) DEFAULT NULL, - `EventSource` varchar(60) DEFAULT NULL, - `EventUser` varchar(60) DEFAULT NULL, - `EventCategory` int(11) DEFAULT NULL, - `EventID` int(11) DEFAULT NULL, - `EventBinaryData` text, - `MaxAvailable` int(11) DEFAULT NULL, - `CurrUsage` int(11) DEFAULT NULL, - `MinUsage` int(11) DEFAULT NULL, - `MaxUsage` int(11) DEFAULT NULL, - `InfoUnitID` int(11) DEFAULT NULL, - `SysLogTag` varchar(60) DEFAULT NULL, - `EventLogType` varchar(60) DEFAULT NULL, - `GenericFileName` varchar(60) DEFAULT NULL, - `SystemID` int(11) DEFAULT NULL, - PRIMARY KEY (`ID`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - -CREATE TABLE `se2` like `se1`; -CREATE TABLE `se3` like `se1`; -CREATE TABLE `se4` like `se1`; -CREATE TABLE `se5` like `se1`; -CREATE TABLE `se6` like `se1`; -CREATE TABLE `se7` like `se1`; -CREATE TABLE `se8` like `se1`; -CREATE TABLE `se9` like `se1`; -CREATE TABLE `se10` like `se1`; -CREATE TABLE `se11` like `se1`; -CREATE TABLE `se12` like `se1`; -CREATE TABLE `se13` like `se1`; -CREATE TABLE `se14` like `se1`; -CREATE TABLE `se15` like `se1`; -CREATE TABLE `se16` like `se1`; -CREATE TABLE `se17` like `se1`; -CREATE TABLE `se18` like `se1`; -CREATE TABLE `se19` like `se1`; -CREATE TABLE `se20` like `se1`; -CREATE TABLE `se21` like `se1`; -CREATE TABLE `se22` like `se1`; -CREATE TABLE `se23` like `se1`; -CREATE TABLE `se24` like `se1`; -CREATE TABLE `se25` like `se1`; -CREATE TABLE `se26` like `se1`; -CREATE TABLE `se27` like `se1`; -CREATE TABLE `se28` like `se1`; - -CREATE TABLE `SystemEvents` ( - `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, - `CustomerID` bigint(20) DEFAULT NULL, - `ReceivedAt` datetime DEFAULT NULL, - `DeviceReportedTime` datetime DEFAULT NULL, - `Facility` smallint(6) DEFAULT NULL, - `Priority` smallint(6) DEFAULT NULL, - `FromHost` varchar(60) DEFAULT NULL, - `Message` text, - `NTSeverity` int(11) DEFAULT NULL, - `Importance` int(11) DEFAULT NULL, - `EventSource` varchar(60) DEFAULT NULL, - `EventUser` varchar(60) DEFAULT NULL, - `EventCategory` int(11) DEFAULT NULL, - `EventID` int(11) DEFAULT NULL, - `EventBinaryData` text, - `MaxAvailable` int(11) DEFAULT NULL, - `CurrUsage` int(11) DEFAULT NULL, - `MinUsage` int(11) DEFAULT NULL, - `MaxUsage` int(11) DEFAULT NULL, - `InfoUnitID` int(11) DEFAULT NULL, - `SysLogTag` varchar(60) DEFAULT NULL, - `EventLogType` varchar(60) DEFAULT NULL, - `GenericFileName` varchar(60) DEFAULT NULL, - `SystemID` int(11) DEFAULT NULL, - PRIMARY KEY (`ID`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 INSERT_METHOD=FIRST UNION=(`se1`,`se2`,`se3`,`se4`,`se5`,`se6`,`se7`,`se8`,`se9`,`se10`,`se11`,`se12`,`se13`,`se14`,`se15`,`se16`,`se17`,`se18`,`se19`,`se20`,`se21`,`se22`,`se23`,`se24`,`se25`,`se26`,`se27`,`se28`); - - diff --git a/db_scripts/base/tmp/0100_grants_dbs.up b/db_scripts/base/tmp/0100_grants_dbs.up deleted file mode 100644 index ff519949..00000000 --- a/db_scripts/base/tmp/0100_grants_dbs.up +++ /dev/null @@ -1,59 +0,0 @@ -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO replicator@"192.168.255.%" IDENTIFIED BY 'PW_REPLICATOR'; - -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON mysql.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON mysql.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; - -GRANT SELECT ON kamailio.* TO kamailioro@localhost IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT ALL ON kamailio.* TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON kamailio.location TO natping@'192.168.255.%' IDENTIFIED BY 'PW_NATPING'; -GRANT SELECT ON kamailio.location TO natping@localhost IDENTIFIED BY 'PW_NATPING'; - -GRANT ALL ON accounting.* TO 'collector'@'localhost' IDENTIFIED BY 'PW_COLLECTOR'; -GRANT ALL ON accounting.* TO 'collector'@'192.168.255.%' IDENTIFIED BY 'PW_COLLECTOR'; - -GRANT ALL ON accounting.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; -GRANT ALL ON accounting.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; -GRANT SELECT ON provisioning.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; -GRANT SELECT ON provisioning.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; -GRANT SELECT ON billing.* TO 'mediator'@'localhost' IDENTIFIED BY 'PW_MEDIATOR'; -GRANT SELECT ON billing.* TO 'mediator'@'192.168.255.%' IDENTIFIED BY 'PW_MEDIATOR'; - -GRANT ALL ON accounting.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON accounting.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON billing.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON billing.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; - -GRANT ALL PRIVILEGES ON kamailio.voicemail_users TO asterisk@'192.168.255.%' IDENTIFIED BY 'PW_ASTERISK'; -GRANT ALL PRIVILEGES ON kamailio.voicemail_users TO asterisk@localhost IDENTIFIED BY 'PW_ASTERISK'; -GRANT ALL PRIVILEGES ON kamailio.voicemail_spool TO asterisk@'192.168.255.%' IDENTIFIED BY 'PW_ASTERISK'; -GRANT ALL PRIVILEGES ON kamailio.voicemail_spool TO asterisk@localhost IDENTIFIED BY 'PW_ASTERISK'; - -GRANT ALL ON provisioning.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON provisioning.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON kamailio.* TO 'soap'@'localhost' IDENTIFIED BY 'PW_SOAP'; -GRANT ALL ON kamailio.* TO 'soap'@'192.168.255.%' IDENTIFIED BY 'PW_SOAP'; - -GRANT SELECT ON powerdns.* TO pdns@'192.168.255.%' IDENTIFIED BY 'dns4Sipwise!'; - -GRANT SELECT ON accounting.cdr TO exporter@'192.168.255.%' IDENTIFIED BY 'PW_EXPORTER'; -GRANT SELECT ON accounting.cdr TO exporter@localhost IDENTIFIED BY 'PW_EXPORTER'; -GRANT SELECT,INSERT,UPDATE ON accounting.mark TO exporter@'192.168.255.%' IDENTIFIED BY 'PW_EXPORTER'; -GRANT SELECT,INSERT,UPDATE ON accounting.mark TO exporter@localhost IDENTIFIED BY 'PW_EXPORTER'; - -GRANT RELOAD ON *.* TO rsyslog@localhost IDENTIFIED BY 'PW_RSYSLOG'; -GRANT ALL on syslog.* TO rsyslog@localhost IDENTIFIED BY 'PW_RSYSLOG'; - -GRANT SELECT,INSERT,UPDATE ON accounting.* TO rateomat@'192.168.255.%' IDENTIFIED BY 'PW_RATEOMAT'; -GRANT SELECT,INSERT,UPDATE ON accounting.* TO rateomat@localhost IDENTIFIED BY 'PW_RATEOMAT'; -GRANT SELECT,INSERT,UPDATE ON billing.* TO rateomat@'192.168.255.%' IDENTIFIED BY 'PW_RATEOMAT'; -GRANT SELECT,INSERT,UPDATE ON billing.* TO rateomat@localhost IDENTIFIED BY 'PW_RATEOMAT'; - -GRANT ALL PRIVILEGES ON *.* TO sipwise@localhost IDENTIFIED BY 'PW_SIPWISE' WITH GRANT OPTION; - -GRANT ALL PRIVILEGES ON kamailio.* to dbcleaner@localhost IDENTIFIED BY 'PW_CLEANUP_TOOLS'; -GRANT ALL PRIVILEGES ON kamailio.* to dbcleaner@'192.168.255.%' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; -GRANT ALL PRIVILEGES ON accounting.* to dbcleaner@localhost IDENTIFIED BY 'PW_CLEANUP_TOOLS'; -GRANT ALL PRIVILEGES ON accounting.* to dbcleaner@'192.168.255.%' IDENTIFIED BY 'PW_CLEANUP_TOOLS'; diff --git a/db_scripts/base/tmp/0110_grants_proxies_kamailio.up b/db_scripts/base/tmp/0110_grants_proxies_kamailio.up deleted file mode 100644 index eec8f62d..00000000 --- a/db_scripts/base/tmp/0110_grants_proxies_kamailio.up +++ /dev/null @@ -1,11 +0,0 @@ -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON mysql.* TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON mysql.* TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO nagios@"192.168.255.%" IDENTIFIED BY 'PW_CHECKTOOL'; -GRANT SELECT ON kamailio.location TO nagios@localhost IDENTIFIED BY 'PW_CHECKTOOL'; - -GRANT SELECT ON kamailio.* TO kamailioro@localhost IDENTIFIED BY 'PW_KAMAILIORO'; -GRANT ALL ON kamailio.* TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; -GRANT SELECT ON provisioning.voip_peer_hosts TO kamailio@localhost IDENTIFIED BY 'PW_KAMAILIORW'; -