<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE table PUBLIC "-//kamailio.org//DTD DBSchema V1.1//EN" 
  "http://kamailio.org/pub/kamailio/dbschema/dtd/1.1/dbschema.dtd" [

<!ENTITY % entities SYSTEM "entities.xml">
%entities;

]>

<table id="active_watchers" xmlns:db="http://docbook.org/ns/docbook">
    <name>active_watchers</name>
    <version>11</version>
    <type db="mysql">&MYSQL_TABLE_TYPE;</type>
    <description>
        <db:para>Table for the presence module. More information can be found at: &KAMAILIO_MOD_DOC;presence.html
        </db:para>
    </description>

    <column id="id">
        <name>id</name>
        <type>unsigned int</type>
        <size>&table_id_len;</size>
        <autoincrement/>
        <primary/>
        <type db="dbtext">int,auto</type>
        <description>Unique ID</description>
    </column>

    <column id="presentity_uri">
        <name>presentity_uri</name>
        <type>string</type>
        <size>&uri_len;</size>
        <description>Presence URI</description>
        <natural/>
    </column>

    <column>
        <name>watcher_username</name>
        <type>string</type>
        <size>&user_len;</size>
        <description>From User</description>
    </column>

    <column>
        <name>watcher_domain</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>From Domain</description>
    </column>

    <column>
        <name>to_user</name>
        <type>string</type>
        <size>&user_len;</size>
        <description>To User</description>
    </column>

    <column>
        <name>to_domain</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>To Domain</description>
    </column>

    <column>
        <name>event</name>
        <type>string</type>
        <size>&user_len;</size>
        <default>presence</default>
        <description>Event description</description>
        <natural/>
    </column>

    <column>
        <name>event_id</name>
        <type>string</type>
        <size>&user_len;</size>
        <null/>
        <description>Event ID</description>
    </column>

    <column id="to_tag">
        <name>to_tag</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>TO tag</description>
    </column>

    <column id="from_tag">
        <name>from_tag</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>From tag</description>
    </column>

    <column id="callid">
        <name>callid</name>
        <type>string</type>
        <size>&callid_len;</size>
        <description>Call ID</description>
    </column>

    <column>
        <name>local_cseq</name>
        <type>int</type>
        <size>&cseq_len;</size>
        <description>Local cseq</description>
    </column>

    <column>
        <name>remote_cseq</name>
        <type>int</type>
        <size>&cseq_len;</size>
        <description>Remote cseq</description>
    </column>

    <column>
        <name>contact</name>
        <type>string</type>
        <size>&uri_len;</size>
        <description>Contact</description>
    </column>

    <column>
        <name>record_route</name>
        <type>text</type>
        <null/>
        <description>Record route</description>
    </column>

    <column id="expires">
        <name>expires</name>
        <type>int</type>
        <size>&expires_len;</size>
        <description>Expires</description>
    </column>

    <column>
        <name>status</name>
        <type>int</type>
        <size>11</size>
        <default>2</default>
        <description>Status</description>
    </column>

    <column>
        <name>reason</name>
        <type>string</type>
        <size>&user_len;</size>
        <description>Reason</description>
    </column>

    <column>
        <name>version</name>
        <type>int</type>
        <size>11</size>
        <default>0</default>
        <description>Version</description>
    </column>

    <column>
        <name>socket_info</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>Socket info</description>
    </column>

    <column>
        <name>local_contact</name>
        <type>string</type>
        <size>&uri_len;</size>
        <description>Local contact</description>
    </column>

    <column>
        <name>from_user</name>
        <type>string</type>
        <size>&user_len;</size>
        <description>From User</description>
    </column>

    <column>
        <name>from_domain</name>
        <type>string</type>
        <size>&domain_len;</size>
        <description>From Domain</description>
    </column>

    <column id="updated">
        <name>updated</name>
        <type>int</type>
        <size>&expires_len;</size>
        <description>Update flag</description>
    </column>

    <column id="updated_winfo">
        <name>updated_winfo</name>
        <type>int</type>
        <size>&expires_len;</size>
        <description>Update winfo flag</description>
    </column>

    <index>
        <name>active_watchers_idx</name>
        <colref linkend="callid"/>
        <colref linkend="to_tag"/>
        <colref linkend="from_tag"/>
        <unique/>
    </index>

    <index>
        <name>active_watchers_expires</name>
        <colref linkend="expires"/>
    </index>

    <index>
        <name>active_watchers_pres</name>
        <colref linkend="presentity_uri"/>
        <colref linkend="event"/>
        <description>This index is needed only if you use DB_ONLY mode.</description>
    </index>

    <index>
        <name>updated_idx</name>
        <colref linkend="updated"/>
        <description>This index is needed only if you use DB_ONLY mode. If possible use a partial index WHERE (updated &lt;&gt;(-1))</description>
    </index>

    <index>
        <name>updated_winfo_idx</name>
        <colref linkend="updated_winfo"/>
        <colref linkend="presentity_uri"/>
        <description>This index is needed only if you use DB_ONLY mode. If possible use a partial index WHERE (updated_winfo &lt;&gt;(-1))</description>
    </index>

</table>
