-- 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,
  `local` bool NOT NULL default FALSE,
  `timezone` varchar(31) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `domain_idx` (`domain`)
) ENGINE=InnoDB;

-- create domain rewrite rules table
CREATE TABLE `voip_domain_rewrites` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `domain_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,
  `field` enum('caller','callee') NOT NULL,
  `priority` int(11) unsigned NOT NULL DEFAULT 50,
  PRIMARY KEY (`id`),
  KEY `domainidx` (`domain_id`),
  CONSTRAINT `v_drw_domainid_ref` FOREIGN KEY (`domain_id`) REFERENCES `voip_domains` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) 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(31) default NULL,
  `timezone` varchar(31) default NULL,
  `admin` bool NOT NULL DEFAULT FALSE,
  `account_id` int(11) UNSIGNED NULL DEFAULT NULL,
  `webusername` varchar(127) default NULL,
  `webpassword` varchar(31) 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;

-- 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,
  `modify_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `internal` bool NOT NULL default FALSE,
  `data_type` enum('bool','int','string') NOT NULL default 'string',
  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 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;

-- 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(15) NOT NULL,
  `domain` varchar(64) NOT NULL,
  `port` int(5) NOT NULL default '5060',
  `weight` tinyint(3) NOT NULL default '0',
  `via_lb` tinyint(1) NOT NULL default '0',
  `dp_caller_in_id` int(11) unsigned NOT NULL,
  `dp_callee_in_id` int(11) unsigned NOT NULL,
  `dp_caller_out_id` int(11) unsigned NOT NULL,
  `dp_callee_out_id` int(11) unsigned NOT NULL,
  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 TABLE `voip_peer_rewrites` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `peer_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 `peeridx` (`peer_id`),
  KEY `dirfieldidx` (`direction`,`field`),
  CONSTRAINT `v_prw_peerid_ref` FOREIGN KEY (`peer_id`) REFERENCES `voip_peer_hosts` (`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;

-- counter for various operations
CREATE TABLE `counter` (
  `name` varchar(64) NOT NULL,
  `value` int(11) unsigned NOT NULL,
  PRIMARY KEY (`name`)
) 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 '/',
  `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;


-- INSERT default data

-- dialplan id counter
INSERT INTO counter VALUES('dp_id', 1);

-- 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');

-- internal domain and subscribers
INSERT INTO voip_domains (domain, local) VALUES('voip.sipwise.local', true);
INSERT INTO voip_subscribers (username, domain_id, uuid, create_timestamp)
                       SELECT 'no_such_number', id, '9bcb88b6-541a-43da-8fdc-816f5557ff93', '0'
                         FROM voip_domains WHERE domain = 'voip.sipwise.local';
INSERT INTO voip_subscribers (username, domain_id, uuid, password, create_timestamp)
                       SELECT 'nagios', id, 'ac1697cf-6933-45ef-9abf-b1278054ded0', 'nagios4Sipwise!', '0'
                         FROM voip_domains WHERE domain = 'voip.sipwise.local';

-- kamailio preferences
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('lock', 0, 'int', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('block_in_mode', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('block_in_list', 0, 'string', 0, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('block_in_clir', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('block_out_mode', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('block_out_list', 0, 'string', 0, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('adm_block_in_mode', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('adm_block_in_list', 0, 'string', 0, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('adm_block_in_clir', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('adm_block_out_mode', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('adm_block_out_list', 0, 'string', 0, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cfu', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cfb', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cfna', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cft', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('ringtimeout', 1, 'int', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cli', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('clir', 1, 'bool', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('cc', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('ac', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('svc_ac', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, modify_timestamp) VALUES('emerg_ac', 0, 'string', 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('ncos_id', 1, 'int', 1, 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('adm_ncos_id', 1, 'int', 1, 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('dp_dom_caller_in', 1, 'int', 1, 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('dp_dom_callee_in', 1, 'int', 1, 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('dp_dom_caller_out', 1, 'int', 1, 1, '1970-01-01 00:00:00');
INSERT INTO voip_preferences (attribute, type, data_type, max_occur, internal, modify_timestamp) VALUES('dp_dom_callee_out', 1, 'int', 1, 1, '1970-01-01 00:00:00');

-- xmlrpc hosts
INSERT INTO xmlhosts VALUES ('1','127.0.0.1','8000','/RPC2','Kamailio');
INSERT INTO xmlhosts VALUES ('2','127.0.0.1','8090','/','Sems');
INSERT INTO xmlhostgroups VALUES ('1','1','1');
INSERT INTO xmlhostgroups VALUES ('2','5','2');
