[[databasemgnt]]
= Database Management
:author: daniel wisnewski
:version: v2.0 July 2015. Reformatted for v8.0.0.

Tigase is coded to perform with multiple database types and numbers.
Owing to it's versatile nature, there are some tools and procedures that may be of use to certain administrators.

== Recommended database versions
As of v8.0.0 here are the minimum and recommended versions of databases for use with Tigase:


[width="100%",frame="topbot",options="header"]
|=================================
|Database   |Recommended Version  |Minimum Version  |Additional Information
|DerbyDB    |10.12.1.1            |10.12.1.1        |Included with Tigase XMPP Server
|MySQL      |5.7                  |5.6.4            |Required to properly support timestamp storage with millisecond precision
|SQLServer  |2014                 |2012             |2012 needed so we can count use fetch-offset pagination feature.
|PostgreSQL |9.5                  |9.4              |New UA schema requires at least 9.4
|MongoDB    |3.2                  |3.0              |
|MariaDB    |?                    |10.0.12          |Basic features works with 10.0.12-MariaDB Homebrew, but is not fully tested.
|=================================

Although Tigase may support other versions of databases, these are the ones we are most familiar with in offering support and advice. Use of databases outside these guidelines may result in unforeseen errors.

[[databaseWatchdog]]
== Database Watchdog
It is possible to have Tigase test availability and existence of database periodically only when db connections are idle. By default this ping is sent once every 60 minutes to each connected repository. However this can be overridden as a part of the dataSource property:

[source,properties]
-----
dataSource {
    default () {
        uri = '....'
    }
    'test' () {
        uri =  '...'
        'watchdog-frequency' = 'PT30M'
    }
}
-----

This setting changes frequency to 30 minutes.

[source,properties]
-----
dataSource {
    default () {
        uri = '...'
    }
    'watchdog-frequency' = 'PT15M'
}
-----
This one changes to 15 minutes.

NOTE: see <<periodDurationValues>> for format details

== Using modified database schema
If you are using Tigase XMPP Server with modified schema (changed procedures or tables) and you do not want Tigase XMPP Server to maintain it and automatically upgrade, you can disable `schema-management` for any data source.
If `schema-management` is disable for particular data source then Tigase XMPP Server will not update or modify database schema in any way. Moreover it will not check if schema version is correct or not.

.Disabling `schema-management` for `default` data source
[source,tdsl]
-----
dataSource {
    default () {
        uri = '...'
        'schema-management' = false
    }
}
-----

WARNING: If `schema-management` is disabled, then it is administrator responsibility to maintain database schema and update it if needed (ie. if Tigase XMPP Server schema was changed).

include::SchemaFilesMaintenance.asciidoc[leveloffset=+1]