Browse Source

add versions to kazoo specific tables

4.3
lazedo 7 years ago
committed by Luis Azedo
parent
commit
75acf0ee26
3 changed files with 13 additions and 18 deletions
  1. +2
    -5
      kamailio/db_scripts/db_extra_check.sql
  2. +0
    -10
      kamailio/db_scripts/db_init_presence_nat.sql
  3. +11
    -3
      kamailio/db_scripts/db_kazoo-specific

+ 2
- 5
kamailio/db_scripts/db_extra_check.sql View File

@ -1,9 +1,6 @@
do_db_extra_check() { do_db_extra_check() {
# warm cache
KazooDB -db ${DB_CURRENT_DB} "create table if not exists auth_cache as select * from htable;"
# location # location
KazooDB -db ${DB_CURRENT_DB} "delete from location where socket not like 'udp:%';" 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');" 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} "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'));" 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%';"
} }

+ 0
- 10
kamailio/db_scripts/db_init_presence_nat.sql View File

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

+ 11
- 3
kamailio/db_scripts/db_kazoo-specific View File

@ -41,17 +41,25 @@ CREATE TABLE active_watchers_log (
user_agent VARCHAR(255) DEFAULT '' COLLATE NOCASE, user_agent VARCHAR(255) DEFAULT '' COLLATE NOCASE,
CONSTRAINT active_watchers_active_watchers_log_idx UNIQUE (presentity_uri, watcher_username, watcher_domain, event) 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, id INTEGER PRIMARY KEY NOT NULL,
contact VARCHAR(2048) NOT NULL COLLATE NOCASE, 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_inserted timestamp DEFAULT CURRENT_TIMESTAMP,
time_sent timestamp DEFAULT CURRENT_TIMESTAMP, time_sent timestamp DEFAULT CURRENT_TIMESTAMP,
slot INTEGER NOT NULL, slot INTEGER NOT NULL,
selected INTEGER DEFAULT 0, 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 , 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, username, domain, event, cast(substr(etag, instr(etag,"@")+1) as varchar(64)) callid,


Loading…
Cancel
Save