From d5a8e26d531238e70a1943d5ed4a12474d3fd504 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 13 Mar 2019 02:21:46 +0000 Subject: [PATCH] update db schema & views --- kamailio/db_scripts/db_kazoo-specific | 25 +++++++++++++++++++++- kamailio/db_scripts/ww_keepalive_views.sql | 20 +++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 kamailio/db_scripts/ww_keepalive_views.sql diff --git a/kamailio/db_scripts/db_kazoo-specific b/kamailio/db_scripts/db_kazoo-specific index 50655f2..5c608f5 100644 --- a/kamailio/db_scripts/db_kazoo-specific +++ b/kamailio/db_scripts/db_kazoo-specific @@ -54,9 +54,10 @@ CREATE TABLE keepalive ( failed INTEGER DEFAULT 0, CONSTRAINT keepalive_idx UNIQUE (contact), CONSTRAINT keepalive_idx_2 UNIQUE (slot, selected, time_sent, contact) + CONSTRAINT keepalive_idx_3 UNIQUE (slot, failed, contact) ); -INSERT INTO version (table_name, table_version) values ('keepalive','1'); +INSERT INTO version (table_name, table_version) values ('keepalive','2'); 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'; @@ -89,6 +90,28 @@ INSERT INTO version (table_name, table_version) select 'auth_cache', table_versi create unique index if not exists idx_dispatcher_destination on dispatcher(destination); + +CREATE VIEW w_keepalive_contact as +SELECT id, slot, failed, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from keepalive; + +CREATE VIEW w_location_contact as +SELECT id, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from location; + +CREATE VIEW w_watchers_contact as +select id, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from active_watchers; + EOF } diff --git a/kamailio/db_scripts/ww_keepalive_views.sql b/kamailio/db_scripts/ww_keepalive_views.sql new file mode 100644 index 0000000..7882ed2 --- /dev/null +++ b/kamailio/db_scripts/ww_keepalive_views.sql @@ -0,0 +1,20 @@ +CREATE VIEW w_keepalive_contact as +SELECT id, slot, failed, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from keepalive; + +CREATE VIEW w_location_contact as +SELECT id, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from location; + +CREATE VIEW w_watchers_contact as +select id, case when instr(contact,";") > 0 + then substr(contact, 1, instr(contact,";")-1) + else contact + end as contact +from active_watchers;