From 9c361c85d59aa682b6ed249b9ad2e19185ba10bf Mon Sep 17 00:00:00 2001 From: lazedo Date: Mon, 11 Mar 2019 13:07:42 +0000 Subject: [PATCH] add versions to kazoo specific tables --- kamailio/db_scripts/db_extra_check.sql | 7 ++----- kamailio/db_scripts/db_init_presence_nat.sql | 10 ---------- kamailio/db_scripts/db_kazoo-specific | 14 +++++++++++--- 3 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 kamailio/db_scripts/db_init_presence_nat.sql diff --git a/kamailio/db_scripts/db_extra_check.sql b/kamailio/db_scripts/db_extra_check.sql index 74522a9..68a73d9 100644 --- a/kamailio/db_scripts/db_extra_check.sql +++ b/kamailio/db_scripts/db_extra_check.sql @@ -1,9 +1,6 @@ do_db_extra_check() { -# warm cache -KazooDB -db ${DB_CURRENT_DB} "create table if not exists auth_cache as select * from htable;" - # location KazooDB -db ${DB_CURRENT_DB} "delete from location where socket not like 'udp:%';" KazooDB -db ${DB_CURRENT_DB} "delete from location where expires > 0 and datetime(expires) < datetime('now', '-30 seconds');" @@ -23,7 +20,7 @@ KazooDB -db ${DB_CURRENT_DB} "drop table if exists tmp_probe;" KazooDB -db ${DB_CURRENT_DB} "create table tmp_probe as select distinct a.event, a.presentity_uri, cast(2 as integer) action from presentities a inner join active_watchers b on a.presentity_uri = b.presentity_uri and a.event = b.event where state in('early', 'confirmed', 'onthephone', 'busy');" KazooDB -db ${DB_CURRENT_DB} "delete from presentity where id in(select id from presentities where state in('early', 'confirmed', 'onthephone', 'busy'));" -## presence nat -KazooDB -db ${DB_CURRENT_DB} "delete from presence_nat where id in(select id from presence_nat a where not exists (select id from active_watchers b where b.contact = a.contact));" +## keepalive +KazooDB -db ${DB_CURRENT_DB} "delete from keepalive where sockinfo NOT LIKE 'udp%';" } diff --git a/kamailio/db_scripts/db_init_presence_nat.sql b/kamailio/db_scripts/db_init_presence_nat.sql deleted file mode 100644 index 0df244d..0000000 --- a/kamailio/db_scripts/db_init_presence_nat.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE if not exists presence_nat ( - id INTEGER PRIMARY KEY NOT NULL, - contact VARCHAR(2048) NOT NULL COLLATE NOCASE, - local_contact VARCHAR(32) NOT NULL COLLATE NOCASE, - time_inserted timestamp DEFAULT CURRENT_TIMESTAMP, - time_sent timestamp DEFAULT CURRENT_TIMESTAMP, - slot INTEGER NOT NULL, - selected INTEGER DEFAULT 0, - CONSTRAINT presence_nat_idx UNIQUE (contact) - ); diff --git a/kamailio/db_scripts/db_kazoo-specific b/kamailio/db_scripts/db_kazoo-specific index b8a3c2d..50655f2 100644 --- a/kamailio/db_scripts/db_kazoo-specific +++ b/kamailio/db_scripts/db_kazoo-specific @@ -41,17 +41,25 @@ CREATE TABLE active_watchers_log ( user_agent VARCHAR(255) DEFAULT '' COLLATE NOCASE, CONSTRAINT active_watchers_active_watchers_log_idx UNIQUE (presentity_uri, watcher_username, watcher_domain, event) ); +INSERT INTO version (table_name, table_version) values ('active_watchers_log','1'); -CREATE TABLE presence_nat ( +CREATE TABLE keepalive ( id INTEGER PRIMARY KEY NOT NULL, contact VARCHAR(2048) NOT NULL COLLATE NOCASE, - local_contact VARCHAR(128) NOT NULL COLLATE NOCASE, + sockinfo VARCHAR(128) NOT NULL COLLATE NOCASE, time_inserted timestamp DEFAULT CURRENT_TIMESTAMP, time_sent timestamp DEFAULT CURRENT_TIMESTAMP, slot INTEGER NOT NULL, selected INTEGER DEFAULT 0, - CONSTRAINT presence_nat_idx UNIQUE (contact) + failed INTEGER DEFAULT 0, + CONSTRAINT keepalive_idx UNIQUE (contact), + CONSTRAINT keepalive_idx_2 UNIQUE (slot, selected, time_sent, contact) ); + +INSERT INTO version (table_name, table_version) values ('keepalive','1'); + +create table auth_cache as select * from htable; +INSERT INTO version (table_name, table_version) select 'auth_cache', table_version from version where table_name = 'htable'; create view presentities as select id, cast(printf("sip:%s@%s",username,domain) as varchar(64)) presentity_uri , username, domain, event, cast(substr(etag, instr(etag,"@")+1) as varchar(64)) callid,