User Tools

Site Tools


install:upgrade:3.2.x-to-3.3.0

Upgrade Kamailio from v3.2.x to v3.3.0

The page contains the details about the changes that were made to old components during the development of v3.3.0 compared with what existed in v3.2.x. It does not include the brand new modules, focusing on how to upgrade database and configuration file from v3.2.x to run with Kamailio v3.3.0.

Database Structure

These sections presents notes, listed by modules, about the structure of database tables that existed in v3.2.x and changed during development of v3.3.0.

modules_k/dialog

  • table dialog
    • table version is 7
    • new columns:
      • iflags INT(10) UNSIGNED DEFAULT 0 NOT NULL
      • xdata VARCHAR(512)
    • column definition changes:
      • caller_cseq VARCHAR(20) NOT NULL
      • callee_cseq VARCHAR(20) NOT NULL

modules_k/domain

  • new table domain_attrs
  • table domain
    • new column did

modules/lcr

  • table lcr_gw
    • ip_addr column has now the size varchar(47)
  • table lcr_rule
    • new column request_uri varchar(64)
    • table version is 2

modules_k/msilo

  • table silo
    • table version is 6
    • new columns:
      • extra_hdrs TEXT DEFAULT ' ' NOT NULL

modules/mtree

  • table mtrees
    • table version is 2
    • definition changes:
      • drop: CONSTRAINT tname_tprefix_idx UNIQUE (tname, tprefix)
      • add: CONSTRAINT tname_tprefix_tvalue_idx UNIQUE (tname, tprefix, tvalue)

modules_k/permissions

  • table address
    • table version is 5
    • column definition changes:
      • grp INT(11) UNSIGNED DEFAULT 1 NOT NULL
      • ip_addr VARCHAR(48) NOT NULL
      • mask INT DEFAULT 32 NOT NULL

modules_k/usrloc

  • table aliases
    • table version is 5
    • new columns:
      • ruid VARCHAR(64) DEFAULT ' ' NOT NULL
      • instance VARCHAR(255) DEFAULT NULL
  • table location
    • table version is 5
    • new columns:
      • ruid VARCHAR(64) DEFAULT ' ' NOT NULL
      • instance VARCHAR(255) DEFAULT NULL
      • reg_id INT(11) DEFAULT 0 NOT NULL

SQL Commands

MySQL

You can use next SQL commands (made for MySQL) to update the structure of existing tables in v3.2.x for v3.3.0:

-- PERMISSIONS module
ALTER TABLE address CHANGE COLUMN ip_addr ip_addr VARCHAR(48) NOT NULL; # was VARCHAR(15) NOT NULL
ALTER TABLE address CHANGE COLUMN grp grp INT(11) UNSIGNED NOT NULL DEFAULT '1'; # was SMALLINT(5) UNSIGNED NOT NULL DEFAULT '1'
ALTER TABLE address CHANGE COLUMN mask mask INT(11) NOT NULL DEFAULT '32'; # was tinyint(4) NOT NULL DEFAULT '32'
 
-- DIALOG module
DELETE FROM dialog;
ALTER TABLE dialog CHANGE COLUMN caller_cseq caller_cseq VARCHAR(20) NOT NULL; # was VARCHAR(7) NOT NULL
ALTER TABLE dialog CHANGE COLUMN callee_cseq callee_cseq VARCHAR(20) NOT NULL; # was VARCHAR(7) NOT NULL
ALTER TABLE dialog DROP COLUMN toroute; # was INT(10) UNSIGNED NOT NULL DEFAULT '0'
ALTER TABLE dialog ADD COLUMN iflags INT(10) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE dialog ADD COLUMN xdata VARCHAR(512) DEFAULT NULL;
 
DELETE FROM dialog_vars;
 
-- LCR module
ALTER TABLE lcr_gw CHANGE COLUMN ip_addr ip_addr VARCHAR(47) DEFAULT NULL; # was VARCHAR(15) DEFAULT NULL
ALTER TABLE lcr_rule ADD COLUMN request_uri VARCHAR(64) DEFAULT NULL;
 
-- USRLOC module
DELETE FROM location;
ALTER TABLE location ADD COLUMN ruid VARCHAR(64) NOT NULL DEFAULT '';
ALTER TABLE location ADD COLUMN reg_id INT(11) NOT NULL DEFAULT '0';
ALTER TABLE location ADD COLUMN instance VARCHAR(255) DEFAULT NULL;
 
ALTER TABLE aliases ADD COLUMN ruid VARCHAR(64) NOT NULL DEFAULT '';
ALTER TABLE aliases ADD COLUMN reg_id INT(11) NOT NULL DEFAULT '0';
ALTER TABLE aliases ADD COLUMN instance VARCHAR(255) DEFAULT NULL;
 
-- MSILO module
ALTER TABLE silo ADD COLUMN STATUS INT(11) NOT NULL DEFAULT '0';
ALTER TABLE silo ADD COLUMN extra_hdrs text NOT NULL DEFAULT '';
ALTER TABLE silo ADD COLUMN callid VARCHAR(128) NOT NULL DEFAULT '';
 
-- DOMAIN module
ALTER TABLE DOMAIN CHANGE COLUMN DOMAIN DOMAIN VARCHAR(64) NOT NULL; # was VARCHAR(64) NOT NULL DEFAULT ''
ALTER TABLE DOMAIN ADD COLUMN did VARCHAR(64) DEFAULT NULL;
 
CREATE TABLE domain_attrs (
  id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  did VARCHAR(64) NOT NULL,
  name VARCHAR(32) NOT NULL,
  TYPE INT(10) UNSIGNED NOT NULL,
  VALUE VARCHAR(255) NOT NULL,
  last_modified datetime NOT NULL DEFAULT '1900-01-01 00:00:01',
  PRIMARY KEY (id),
  UNIQUE KEY domain_attrs_idx (did,name,VALUE)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
GRANT ALL PRIVILEGES ON TABLE domain_attrs TO openser;
GRANT SELECT ON TABLE domain_attrs TO openserro;
GRANT ALL PRIVILEGES ON TABLE domain_attrs_id_seq TO openser;
GRANT SELECT ON TABLE domain_attrs_id_seq TO openserro;
 
-- PRESENCE modules
DELETE FROM active_watchers;
ALTER TABLE active_watchers ADD COLUMN from_domain VARCHAR(64) NOT NULL;
ALTER TABLE active_watchers ADD COLUMN updated_winfo INT(11) NOT NULL;
ALTER TABLE active_watchers ADD COLUMN updated INT(11) NOT NULL;
ALTER TABLE active_watchers ADD COLUMN from_user VARCHAR(64) NOT NULL;
ALTER TABLE active_watchers DROP INDEX active_watchers_idx; # was UNIQUE (presentity_uri,callid,to_tag,from_tag)
ALTER TABLE active_watchers ADD UNIQUE active_watchers_idx (callid,to_tag,from_tag);
ALTER TABLE active_watchers ADD INDEX active_watchers_expires (expires);
ALTER TABLE active_watchers ADD INDEX active_watchers_pres (presentity_uri);
ALTER TABLE active_watchers ADD INDEX updated_idx (updated);
ALTER TABLE active_watchers ADD INDEX updated_winfo_idx (updated_winfo,presentity_uri);
 
ALTER TABLE presentity ADD INDEX account_idx (username,DOMAIN,event);
ALTER TABLE presentity ADD INDEX presentity_expires (expires);
 
ALTER TABLE pua ADD INDEX tmp_record2_idx (pres_id,etag);
ALTER TABLE pua ADD INDEX tmp_dlg2_idx (pres_id,pres_uri,call_id,from_tag);
ALTER TABLE pua ADD INDEX tmp_record1_idx (pres_id);
ALTER TABLE pua ADD INDEX dialog2_idx (pres_id,pres_uri);
ALTER TABLE pua ADD INDEX dialog1_idx (call_id,from_tag,to_tag);
ALTER TABLE pua ADD INDEX tmp_dlg1_idx (call_id,from_tag);
ALTER TABLE pua ADD UNIQUE pua_idx (etag,tuple_id,call_id,from_tag);
ALTER TABLE pua ADD UNIQUE expires_idx (expires);
 
ALTER TABLE rls_presentity ADD INDEX rlsubs_idx (rlsubs_did);
ALTER TABLE rls_presentity ADD INDEX expires_idx (expires);
 
DELETE FROM rls_watchers;
ALTER TABLE rls_watchers ADD COLUMN from_domain VARCHAR(64) NOT NULL;
ALTER TABLE rls_watchers ADD COLUMN updated INT(11) NOT NULL;
ALTER TABLE rls_watchers ADD COLUMN from_user VARCHAR(64) NOT NULL;
ALTER TABLE rls_watchers DROP INDEX rls_watcher_idx; # was UNIQUE (presentity_uri,callid,to_tag,from_tag)
ALTER TABLE rls_watchers ADD UNIQUE rls_watcher_idx (callid,to_tag,from_tag);
ALTER TABLE rls_watchers ADD INDEX rls_watchers_expires (expires);
ALTER TABLE rls_watchers ADD INDEX updated_idx (updated);
ALTER TABLE rls_watchers ADD INDEX rls_watchers_update (watcher_username,watcher_domain,event);
ALTER TABLE rls_watchers ADD INDEX rls_watchers_delete (callid,to_tag);
 
ALTER TABLE xcap DROP INDEX source_idx; # was INDEX (SOURCE)
ALTER TABLE xcap DROP INDEX account_doc_type_idx; # was UNIQUE (username,DOMAIN,doc_type,doc_uri)
ALTER TABLE xcap ADD INDEX account_doc_type_idx (username,DOMAIN,doc_type);
ALTER TABLE xcap ADD INDEX account_doc_type_uri_idx (username,DOMAIN,doc_type,doc_uri);
ALTER TABLE xcap ADD UNIQUE doc_uri_idx (doc_uri);
ALTER TABLE xcap ADD INDEX account_doc_uri_idx (username,DOMAIN,doc_uri);
 
 
-- VERSION table
DELETE FROM version WHERE TABLE_NAME='dialog';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('dialog','7');
DELETE FROM version WHERE TABLE_NAME='domain';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('domain','2');
DELETE FROM version WHERE TABLE_NAME='domain_attrs';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('domain_attrs','1');
DELETE FROM version WHERE TABLE_NAME='silo';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('silo','7');
DELETE FROM version WHERE TABLE_NAME='mtrees';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('mtrees','2');
DELETE FROM version WHERE TABLE_NAME='address';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('address','5');
DELETE FROM version WHERE TABLE_NAME='active_watchers';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('active_watchers','11');
DELETE FROM version WHERE TABLE_NAME='aliases';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('aliases','5');
DELETE FROM version WHERE TABLE_NAME='rls_watchers';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('rls_watchers','3');
DELETE FROM version WHERE TABLE_NAME='location';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('location','5');

PostgreSQL

This is the translation of the above MySQL script for PostgreSQL (Should work with 9.1.1, partially tested on 9.1.5.)

-- PERMISSIONS module
ALTER TABLE address ALTER COLUMN ip_addr TYPE VARCHAR(48);
ALTER TABLE address ALTER COLUMN ip_addr SET NOT NULL; --# was varchar(15) NOT NULL
ALTER TABLE address ALTER COLUMN grp TYPE INTEGER;
ALTER TABLE address ALTER COLUMN grp SET NOT NULL;
ALTER TABLE address ALTER COLUMN grp SET DEFAULT '1'; --# was smallint(5) UNSIGNED NOT NULL DEFAULT '1'
ALTER TABLE address ALTER COLUMN mask TYPE INTEGER;
ALTER TABLE address ALTER COLUMN mask SET NOT NULL;
ALTER TABLE address ALTER COLUMN mask SET DEFAULT '32'; --# was tinyint(4) NOT NULL DEFAULT '32'
 
-- DIALOG module
DELETE FROM dialog;
ALTER TABLE dialog ALTER COLUMN caller_cseq TYPE VARCHAR(20);
ALTER TABLE dialog ALTER COLUMN caller_cseq SET NOT NULL; --# was varchar(7) NOT NULL
ALTER TABLE dialog ALTER COLUMN callee_cseq TYPE VARCHAR(20);
ALTER TABLE dialog ALTER COLUMN callee_cseq SET NOT NULL; --# was varchar(7) NOT NULL
ALTER TABLE dialog DROP COLUMN toroute; --# was int(10) UNSIGNED NOT NULL DEFAULT '0'
ALTER TABLE dialog ADD COLUMN iflags INTEGER;
ALTER TABLE dialog ALTER COLUMN iflags SET NOT NULL;
ALTER TABLE dialog ALTER COLUMN iflags SET DEFAULT '0';
ALTER TABLE dialog ADD COLUMN xdata VARCHAR(512);
ALTER TABLE dialog ALTER COLUMN xdata SET DEFAULT NULL;
 
DELETE FROM dialog_vars;
 
-- LCR module
ALTER TABLE lcr_gw ALTER COLUMN ip_addr TYPE VARCHAR(47);
ALTER TABLE lcr_gw ALTER COLUMN ip_addr SET DEFAULT NULL; --# was varchar(15) DEFAULT NULL
ALTER TABLE lcr_rule ADD COLUMN request_uri VARCHAR(64);
ALTER TABLE lcr_rule ALTER COLUMN request_uri SET DEFAULT NULL;
 
-- USRLOC module
DELETE FROM location;
ALTER TABLE location ADD COLUMN ruid VARCHAR(64);
ALTER TABLE location ALTER COLUMN ruid SET NOT NULL;
ALTER TABLE location ALTER COLUMN ruid SET DEFAULT '';
ALTER TABLE location ADD COLUMN reg_id INTEGER;
ALTER TABLE location ALTER COLUMN reg_id SET NOT NULL;
ALTER TABLE location ALTER COLUMN reg_id SET DEFAULT '0';
ALTER TABLE location ADD COLUMN instance VARCHAR(255);
ALTER TABLE location ALTER COLUMN instance SET DEFAULT NULL;
 
ALTER TABLE aliases ADD COLUMN ruid VARCHAR(64);
ALTER TABLE aliases ALTER COLUMN ruid SET NOT NULL;
ALTER TABLE aliases ALTER COLUMN ruid SET DEFAULT '';
ALTER TABLE aliases ADD COLUMN reg_id INTEGER;
ALTER TABLE aliases ALTER COLUMN reg_id SET NOT NULL;
ALTER TABLE aliases ALTER COLUMN reg_id SET DEFAULT '0';
ALTER TABLE aliases ADD COLUMN instance VARCHAR(255);
ALTER TABLE aliases ALTER COLUMN instance SET DEFAULT NULL;
 
-- MSILO module
ALTER TABLE silo ADD COLUMN STATUS INTEGER;
ALTER TABLE silo ALTER COLUMN STATUS SET NOT NULL;
ALTER TABLE silo ALTER COLUMN STATUS SET DEFAULT '0';
ALTER TABLE silo ADD COLUMN extra_hdrs text;
ALTER TABLE silo ALTER COLUMN extra_hdrs SET NOT NULL;
ALTER TABLE silo ALTER COLUMN extra_hdrs SET DEFAULT '';
ALTER TABLE silo ADD COLUMN callid VARCHAR(128);
ALTER TABLE silo ALTER COLUMN callid SET NOT NULL;
ALTER TABLE silo ALTER COLUMN callid SET DEFAULT '';
 
-- DOMAIN module
ALTER TABLE DOMAIN ALTER COLUMN DOMAIN TYPE VARCHAR(64);
ALTER TABLE DOMAIN ALTER COLUMN DOMAIN SET NOT NULL; --# was varchar(64) NOT NULL DEFAULT ''
ALTER TABLE DOMAIN ADD COLUMN did VARCHAR(64);
ALTER TABLE DOMAIN ALTER COLUMN did SET DEFAULT NULL;
 
CREATE TABLE domain_attrs (
  id serial,
  did VARCHAR(64) NOT NULL,
  name VARCHAR(32) NOT NULL,
  TYPE INTEGER NOT NULL,
  VALUE VARCHAR(255) NOT NULL,
  last_modified TIMESTAMP WITHOUT TIME zone NOT NULL DEFAULT '1900-01-01 00:00:01'::TIMESTAMP WITHOUT TIME zone,
  PRIMARY KEY (id),
  UNIQUE (did,name,VALUE)
);
 
GRANT ALL PRIVILEGES ON TABLE domain_attrs TO openser;
GRANT SELECT ON TABLE domain_attrs TO openserro;
GRANT ALL PRIVILEGES ON TABLE domain_attrs_id_seq TO openser;
GRANT SELECT ON TABLE domain_attrs_id_seq TO openserro;
 
-- PRESENCE modules
DELETE FROM active_watchers;
ALTER TABLE active_watchers ADD COLUMN from_domain VARCHAR(64);
ALTER TABLE active_watchers ALTER COLUMN from_domain SET NOT NULL;
ALTER TABLE active_watchers ADD COLUMN updated_winfo INTEGER;
ALTER TABLE active_watchers ALTER COLUMN updated_winfo SET NOT NULL;
ALTER TABLE active_watchers ADD COLUMN updated INTEGER;
ALTER TABLE active_watchers ALTER COLUMN updated SET NOT NULL;
ALTER TABLE active_watchers ADD COLUMN from_user VARCHAR(64);
ALTER TABLE active_watchers ALTER COLUMN from_user SET NOT NULL;
ALTER TABLE active_watchers DROP CONSTRAINT active_watchers_active_watchers_idx; --# was UNIQUE (presentity_uri,callid,to_tag,from_tag)
ALTER TABLE active_watchers ADD CONSTRAINT active_watchers_active_watchers_idx UNIQUE (callid,to_tag,from_tag);
CREATE INDEX active_watchers_expires ON active_watchers(expires);
CREATE INDEX active_watchers_pres ON active_watchers(presentity_uri);
CREATE INDEX active_watchers_updated_idx ON active_watchers(updated);
CREATE INDEX active_watchers_updated_winfo_idx ON active_watchers(updated_winfo,presentity_uri);
 
CREATE INDEX presentity_account_idx ON presentity(username,DOMAIN,event);
CREATE INDEX presentity_expires ON presentity(expires);
 
CREATE INDEX pua_tmp_record2_idx ON pua(pres_id,etag);
CREATE INDEX pua_tmp_dlg2_idx ON pua(pres_id,pres_uri,call_id,from_tag);
CREATE INDEX pua_tmp_record1_idx ON pua(pres_id);
CREATE INDEX pua_dialog2_idx ON pua(pres_id,pres_uri);
CREATE INDEX pua_dialog1_idx ON pua(call_id,from_tag,to_tag);
CREATE INDEX pua_tmp_dlg1_idx ON pua(call_id,from_tag);
ALTER TABLE pua ADD CONSTRAINT pua_pua_idx UNIQUE (etag,tuple_id,call_id,from_tag);
ALTER TABLE pua ADD CONSTRAINT pua_expires_idx UNIQUE (expires);
 
CREATE INDEX rls_presentity_rlsubs_idx ON rls_presentity(rlsubs_did);
CREATE INDEX rls_presentity_expires_idx ON rls_presentity(expires);
 
DELETE FROM rls_watchers;
ALTER TABLE rls_watchers ADD COLUMN from_domain VARCHAR(64);
ALTER TABLE rls_watchers ALTER COLUMN from_domain SET NOT NULL;
ALTER TABLE rls_watchers ADD COLUMN updated INTEGER;
ALTER TABLE rls_watchers ALTER COLUMN updated SET NOT NULL;
ALTER TABLE rls_watchers ADD COLUMN from_user VARCHAR(64);
ALTER TABLE rls_watchers ALTER COLUMN from_user SET NOT NULL;
ALTER TABLE rls_watchers DROP CONSTRAINT rls_watchers_rls_watcher_idx; --# was UNIQUE (presentity_uri,callid,to_tag,from_tag)
ALTER TABLE rls_watchers ADD CONSTRAINT rls_watchers_rls_watcher_idx UNIQUE (callid,to_tag,from_tag);
CREATE INDEX rls_watchers_expires ON rls_watchers(expires);
CREATE INDEX rls_watchers_updated_idx ON rls_watchers(updated);
CREATE INDEX rls_watchers_update ON rls_watchers(watcher_username,watcher_domain,event);
CREATE INDEX rls_watchers_delete ON rls_watchers(callid,to_tag);
 
ALTER TABLE xcap DROP CONSTRAINT xcap_account_doc_type_idx; --# was UNIQUE (username,domain,doc_type,doc_uri) 
DROP INDEX xcap_source_idx; --# was INDEX (source)
CREATE INDEX xcap_account_doc_type_idx ON xcap(username,DOMAIN,doc_type);
CREATE INDEX xcap_account_doc_type_uri_idx ON xcap(username,DOMAIN,doc_type,doc_uri);
ALTER TABLE xcap ADD CONSTRAINT xcap_doc_uri_idx UNIQUE (doc_uri);
CREATE INDEX xcap_account_doc_uri_idx ON xcap(username,DOMAIN,doc_uri);
 
-- VERSION table
DELETE FROM version WHERE TABLE_NAME='dialog';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('dialog','7');
DELETE FROM version WHERE TABLE_NAME='lcr_rule';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('lcr_rule','2');
DELETE FROM version WHERE TABLE_NAME='domain';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('domain','2');
DELETE FROM version WHERE TABLE_NAME='domain_attrs';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('domain_attrs','1');
DELETE FROM version WHERE TABLE_NAME='silo';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('silo','7');
DELETE FROM version WHERE TABLE_NAME='mtrees';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('mtrees','2');
DELETE FROM version WHERE TABLE_NAME='address';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('address','5');
DELETE FROM version WHERE TABLE_NAME='active_watchers';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('active_watchers','11');
DELETE FROM version WHERE TABLE_NAME='aliases';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('aliases','5');
DELETE FROM version WHERE TABLE_NAME='rls_watchers';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('rls_watchers','3');
DELETE FROM version WHERE TABLE_NAME='location';
INSERT INTO version (TABLE_NAME, table_version) VALUES ('location','5');

Modules

modules_k/domain

  • Removed support for db only mode and, as consequence, removed db_mode module variable.

modules_k/presence

  • removed db_mode and fallback2db parameters
  • added two new parameters subs_db_mode and publ_cache to replace the ones that were removed

modules/your-module-here

  • Add changes or additions reflected in kamailio config syntax here.
install/upgrade/3.2.x-to-3.3.0.txt · Last modified: 2013/07/15 22:36 by elactrum