From e078bb9d87423520939903e45d68696f93028066 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 10 Oct 2019 14:31:28 +1300 Subject: [PATCH] Backport fixes for issue#395 and Issue #398 related to db schema issues. (#437) --- db/install.xml | 4 ++-- db/upgrade.php | 31 +++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/db/install.xml b/db/install.xml index 2296cd0..01f7a09 100644 --- a/db/install.xml +++ b/db/install.xml @@ -45,7 +45,7 @@ - + @@ -127,7 +127,7 @@ - + diff --git a/db/upgrade.php b/db/upgrade.php index 9d0d199..e386202 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -550,5 +550,36 @@ function xmldb_attendance_upgrade($oldversion=0) { upgrade_mod_savepoint(true, 2018051408, 'attendance'); } + if ($oldversion < 2018051409) { + + // Make sure default value to '0'. + $table = new xmldb_table('attendance_sessions'); + $field = new xmldb_field('preventsharedip', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, + XMLDB_NOTNULL, null, '0', 'absenteereport'); + + if ($dbman->field_exists($table, $field)) { + $dbman->change_field_default($table, $field); + } + + // Make sure sessiondetailspos is not null. + $table = new xmldb_table('attendance'); + $field = new xmldb_field('sessiondetailspos', XMLDB_TYPE_CHAR, '5', null, XMLDB_NOTNULL, null, 'left', 'subnet'); + + if ($dbman->field_exists($table, $field)) { + $dbman->change_field_notnull($table, $field); + } + + // Make sure maxwarn has default value of '1'. + $table = new xmldb_table('attendance_warning'); + $field = new xmldb_field('maxwarn', XMLDB_TYPE_INTEGER, '10', null, true, null, '1', 'warnafter'); + + if ($dbman->field_exists($table, $field)) { + $dbman->change_field_default($table, $field); + } + + // Attendance savepoint reached. + upgrade_mod_savepoint(true, 2018051409, 'attendance'); + } + return $result; } diff --git a/version.php b/version.php index bd5eaa3..b911fea 100644 --- a/version.php +++ b/version.php @@ -23,7 +23,7 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018051408; +$plugin->version = 2018051409; $plugin->requires = 2018050800; // Requires 3.5. $plugin->release = '3.5.6'; $plugin->maturity = MATURITY_STABLE;