The upgrade scripts (e.g. `/updates/version5.php`) have two main purposes: 1) alter the database structure to match the new code, and 2) alter/add settings into `/config/config.inc.php`. Sometimes an upgrade script may be used to 'fix' content that is wrong in the database - update the content of a question(s) that has become corrupted or student answers that are incorrectly saved.
The overall principle of the upgrade script is to take any sub-version of Rogo and upgrade to the latest. To do this it will actively look at the database and configuration file and determine what changes are necessary. This allows for the script to be safely run more than once and not get too many fields add to the database.
record_update
and has_updated
can be used to record and check whether an update has been done respectively.updaterttils::check_version
function which should be added to each update script. It checks the version of rogo in config/rogo.xml
against the current installed version in config/config.inc.php
. This stops upgrade scripts being run more that once on a version as before but also stops upgrades being run when they are not required i.e. from a previous version.