Database Schema¶
Database Schema 2 (since 4.0)¶
Tables¶
The sipis database consists of the following tables.
badgeThis table contains information necessary for calculating correct badge number for push notifications.
dataThis table contains information about user SIP accounts. SIPIS consults this table whenever it needs to create a new SIP client instance.
pushtestsThis table contains information about pending and completed push tests.
restartThis table contains state information about all instances currently running on a given SIPIS server. When SIPIS crashes or is restarted it uses this table to recreate all the SIP client instances that were running on it prior to the restart.
selectorsThis table holds information about the time when a given selector was last seen by a sipis server.
sipcallsThis table contains information about missed and pending incoming calls that are still waiting to be reported to users.
siptextmessagesThis table contains information about incoming text messages that are still waiting to be delivered to users.
tableversionsThis table holds versioning information of the other tables in the database.
tokensThis table contains information used to associate selectors with device tokens used for push notifications.
The data Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumn.
The data table has the following columns.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.namecharacter varying(64) not null
The first part ofnameandvaluepairs that store information about user SIP accounts.valuecharacter varying(255)
The second part ofnameandvaluepairs that store information about user SIP accounts.longvaluetext
Stores value longer that 255 characters.
The pushtests Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumn.Added
rowidcolumn.
The pushtests table has the following colums.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.pushidcharacter varying(64) not null
ID of the push test.platformcharacter varying(255) not null
Platform of the device which initiated the push test.startedtimestamp without time zone not null
Time when the test push was sent to the device.concludedtimestamp without time zone
Time of the reply from the device confirming that the push test was successful.
The restart Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumn.Removed
servercolumn in favor of a new entry named “server”.The
restart_replace_ruleis no longer necessary because sipis uses the new “upsert” functionality in PostgreSQL since version 9.5.
The restart table has the following columns.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.namecharacter varying(64) not null
The first part ofnameandvaluepairs that store information about user SIP accouts.seqinteger default 0 not null
Used to store arrays of values as in “name[seq]: value”.valuecharacter varying(255)
The second part ofnameandvaluepairs that store information about user SIP accounts.longvaluetext
Stores value longer that 255 characters.
The selectors Table (v1)¶
- Changelog
There were no changes in the
selectorstable.
The selectors table has the following columns.
idbigint not null
Integer identifier assigned to the associated instance selector.selectorcharacter varying(64) not null
Instance selector string.lastseentimestamp with time zone not null default now()
Timestamp of the last time any SIPIS server saw the associated instance selector.
The sipcalls Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumn.Added
missedreasoncolumn.
The sipcalls table has the following columns.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.schemecharacter varying(6) not null
Scheme part of the caller URI.userdisplaynamecharacter varying(255) not null
Display name part of the caller URI.usernamecharacter varying(255) not null
User name part of the caller URI.domaincharacter varying(255) not null
Domain part of the caller URI.domainportinteger not null
Domain port part of the caller URI.callidcharacter varying(255) not null
SIPCall-IDheader of the incomingINVITErequest.timetimestamp with time zone not null
Timestamp of arrival of the incomingINVITErequest.missedreasoncharacter varying(64) not null
Missed reason of the incoming call. Possible values areMissed,AnsweredElsewhereandRejectedByDnd.
The siptextmessages Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumn.
The siptextmessages table has the following columns.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.schemecharacter varying(6) not null
Scheme part of the sender URI.userdisplaynamecharacter varying(255) not null
Display name part of the sender URI.usernamecharacter varying(255) not null
User name part of the sender URI.domaincharacter varying(255) not null
Domain part of the sender URI.domainportinteger not null
Domain port part of the sender URI.msgidcharacter varying(255) not null
SIPCall-IDheader of the incomingMESSAGErequest.contenttypecharacter varying(255) not null
SIPContent-Typeheader of the incomingMESSAGErequest.headerstext not null
SIP headers of the incomingMESSAGErequest in XML format.bodytext not null
Encrypted body of the incomingMESSAGErequest.timetimestamp with time zone not null
Timestamp of arrival of the incomingMESSAGErequest.
The tokens Table (v2)¶
- Changelog
- v2
Replaced
idcolumn withselectorcolumnThe
tokens_replace_ruleis no longer necessary because sipis uses the new “upsert” functionality in PostgreSQL since version 9.5.
The tokens table has the following columns.
rowidbigint not null
Auto-incrementing row identifier.selectorcharacter varying(64) not null
Instance selector string.tokentext not null
Base64-encoded device token used for push notifications.appidcharacter varying(200) not null
Identifier of the application that handles the associated instance selector.lastseentimestamp with time zone
Timestamp of the last time any SIPIS server saw the associated device token.
Database migration¶
This section assumes that you are hosting your own sipis server and you have recently updated from version 3.x to version 4.x.
Sipis version 4.x will work well with the older database scheme, however migrating to the newer scheme will enable sipis to report proper missed call reason to the device, improving call history records.
To migrate to the new database scheme, follow these steps
Create a new empty database
# su postgres
$ psql -c "CREATE DATABASE sipis2 OWNER sipis TEMPLATE template0 ENCODING 'SQL_ASCII';"
$ exit
Stop sipis service
# systemctl stop sipis
Update sipis settings file, keeping the old one around for later reference
Note
It’s important that the old settings file DOES NOT end with .xml extension.
# cp /etc/sipis/Settings.xml /etc/sipis/Settings.xml.old
In /etc/sipis/Settings.xml, update the database name in the Sipis/Database[OpenString]
attribute, e.g: replace
<Database OpenString="host=localhost port=5432 dbname=sipis user=sipis password=*****" />
with (notice dbname=sipis2 instead of dbname=sipis)
<Database OpenString="host=localhost port=5432 dbname=sipis2 user=sipis password=*****" />
Invoke CreateSipisDb command to migrate the database
We pass both, the new and the old settings file as arguments. This instructs the CreateSipisDb command to migrate data from the old database to the newly created one.
# CreateSipisDb /etc/sipis/Settings.xml /etc/sipis/Settings.xml.old
Start sipis service
If everything went smoothly, then the migration is done at this point and you can start your sipis server again.
# systemctl start sipis
Cleanup
Optionally, you can delete the old database and the old settings file /etc/sipis/Settings.xml.old
Database Schema 1 (until 3.59)¶
Tables¶
The sipis database consists of the following tables.
dataThis table contains information about user SIP accounts. SIPIS consults this table whenever it needs to create a new SIP client instance.
pushtestsThis table contains information about pending and completed push tests.
restartThis table contains state information about all instances currently running on a given SIPIS server. When SIPIS crashes or is restarted it uses this table to recreate all the SIP client instances that were running on it prior to the restart.
selectorsThis table contains mapping from selector strings to integer identifiers used in other tables.
sipcallsThis table contains information about missed and pending incoming calls that are still waiting to be reported to users.
siptextmessagesThis table contains information about incoming text messages that are still waiting to be delivered to users.
tokensThis table contains information used to associate selectors with device tokens used for push notifications.
The data Table (v1)¶
The data table has the following columns.
rowidinteger not null
Auto-incrementing row identifier.idForeign key to the
selectorstable.namecharacter varying(64)
The first part ofnameandvaluepairs that store information about user SIP accounts.valuecharacter varying(255)The second part ofnameandvaluepairs that store information about user SIP accounts.longvaluetextStores value longer that 255 characters.
The pushtests Table (v1)¶
The pushtests table has the following colums.
idReference to the
selectorstable. This is not a foreign key since it is desired to keep push test results available even after instance gets turned off.pushidcharacter varying(64) not null
ID of the push test.platformcharacter varying(255) not null
Platform of the device to which the test push was sent.startedtimestamp without time zone not null
Time when the test push was sent to the device.concludedtimestamp without time zone
Time of the reply from the device confirming that the push test was successful.
The restart Table (v1)¶
The restart table has the following columns.
rowidinteger not null
Auto-incrementing row identifier.idinteger not null
Foreign key to theselectorstable.namecharacter varying(64) not null
The first part ofnameandvaluepairs that store information about user SIP accouts.valuecharacter varying(255)
The second part ofnameandvaluepairs that store information about user SIP accounts.seqinteger default 0 not null
TBD.servercharacter varying(100)
Name of the SIPIS server that owns the given entry.longvaluetextStores value longer that 255 characters.
The selectors Table (v1)¶
The selectors table has the following columns.
idinteger not null
Integer identifier assigned to the associated instance selector.selectorcharacter varying(64) not null
Instance selector string.lastseentimestamp with time zone default now() not null
Timestamp of the last time any SIPIS server saw the associated instance selector.
The sipcalls Table (v1)¶
TBD.
The siptextmessages Table (v1)¶
TBD.
The tokens Table (v1)¶
The tokens table has the following columns.
rowidinteger not null
Auto-incrementing row identifier.idinteger not null
Foreign key to theselectorstable.tokentext not null
Base64-encoded device token used for push notifications.appidcharacter varying(200) not null
Identifier of the application that handles the associated instance selector.lastseentimestamp with time zone
Timestamp of the last time any SIPIS server saw the associated device token.