diff --git a/kamailio/db_scripts/check-kazoodb-sql.sh b/kamailio/db_scripts/check-kazoodb-sql.sh index ab00bec..80d0955 100755 --- a/kamailio/db_scripts/check-kazoodb-sql.sh +++ b/kamailio/db_scripts/check-kazoodb-sql.sh @@ -25,7 +25,7 @@ fi for VIEW in `ls ${DB_SCRIPT_DIR}/vw_*.sql`; do filename=$(basename -- "$VIEW") filename="${filename%.*}" - viewname=$(echo -n "$filename" | cut -d'_' -f2) + viewname=${filename#*_} v1=$(KazooDB -db ${DB_CURRENT_DB} "select sql from sqlite_master where type='view' and name='$viewname'" 2> /dev/null | tr -d ' ' | md5sum | cut -d ' ' -f1) v2=$(cat $VIEW | tr -d ' ' | md5sum | cut -d ' ' -f1) if [[ "$v1" != "$v2" ]]; then diff --git a/kamailio/db_scripts/db_kazoo-specific b/kamailio/db_scripts/db_kazoo-specific index 5c608f5..c67b5ca 100644 --- a/kamailio/db_scripts/db_kazoo-specific +++ b/kamailio/db_scripts/db_kazoo-specific @@ -57,7 +57,9 @@ CREATE TABLE keepalive ( CONSTRAINT keepalive_idx_3 UNIQUE (slot, failed, contact) ); -INSERT INTO version (table_name, table_version) values ('keepalive','2'); +INSERT INTO version (table_name, table_version) values ('keepalive','3'); + +CREATE UNIQUE INDEX active_watchers_contact ON active_watchers (contact, id); 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'; diff --git a/kamailio/db_scripts/vw_w_keepalive_contact.sql b/kamailio/db_scripts/vw_w_keepalive_contact.sql new file mode 100644 index 0000000..ce12ec5 --- /dev/null +++ b/kamailio/db_scripts/vw_w_keepalive_contact.sql @@ -0,0 +1,6 @@ +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 diff --git a/kamailio/db_scripts/vw_w_location_contact.sql b/kamailio/db_scripts/vw_w_location_contact.sql new file mode 100644 index 0000000..6227b0c --- /dev/null +++ b/kamailio/db_scripts/vw_w_location_contact.sql @@ -0,0 +1,6 @@ +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 diff --git a/kamailio/db_scripts/vw_w_watchers_contact.sql b/kamailio/db_scripts/vw_w_watchers_contact.sql new file mode 100644 index 0000000..96d0186 --- /dev/null +++ b/kamailio/db_scripts/vw_w_watchers_contact.sql @@ -0,0 +1,6 @@ +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 diff --git a/kamailio/db_scripts/ww_keepalive_views.sql b/kamailio/db_scripts/ww_keepalive_views.sql deleted file mode 100644 index 7882ed2..0000000 --- a/kamailio/db_scripts/ww_keepalive_views.sql +++ /dev/null @@ -1,20 +0,0 @@ -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;