<?xml version="1.0" encoding="UTF-8"?>

<!-- Differential patch for M/Monit database schema version 20 to 21 -->

<patch>

<!-- sqlite -->

<statements type="sqlite">

<comment>Check database integrity before upgrade</comment>
<statement>
PRAGMA integrity_check;
</statement>
<statement>
PRAGMA foreign_key_check;
</statement>

<comment>Add default password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditdefaultpasswords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditdefaultpasswords=1;
</statement>

<comment>Add MD5 password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditmd5passwords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditmd5passwords=1;
</statement>

<comment>Add controls for automatic monit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmonitversion=0;
</statement>

<comment>Add controls for automatic mmonit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmmonitversion=0;
</statement>

</statements>


<!-- mysql -->

<statements type="mysql">

<comment>Add default password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditdefaultpasswords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditdefaultpasswords=1;
</statement>

<comment>Add MD5 password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditmd5passwords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditmd5passwords=1;
</statement>

<comment>Add controls for automatic monit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmonitversion=0;
</statement>

<comment>Add controls for automatic mmonit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmmonitversion=0;
</statement>

</statements>


<!-- postgresql -->

<statements type="postgresql">

<comment>Add default password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditdefaultpasswords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditdefaultpasswords=1;
</statement>

<comment>Add MD5 password audit controls to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN auditmd5passwords INTEGER;
</statement>
<statement>
UPDATE mmonit SET auditmd5passwords=1;
</statement>

<comment>Add controls for automatic monit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmonitversion=0;
</statement>

<comment>Add controls for automatic mmonit version check to mmonit table</comment>
<statement>
ALTER TABLE mmonit ADD COLUMN checkmmonitversion INTEGER;
</statement>
<statement>
UPDATE mmonit SET checkmmonitversion=0;
</statement>

</statements>

</patch>

