The upgrade scripts script (e.g. `/updates/version5upgrade.php`) have has two main purposes:
1) alter the database structure to match the new code
2) alter/add settings into `/config/config.inc.php` or to the config database table.
Sometimes an the 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 saveddue to a historic bug. Institution specifc data issues should never be fixed via this script. The institution should write their own patch.
The overall principle of the upgrade script is to take any sub-version of Rogo (where possible) 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.
- The files in the /updates/version5scripts/ directory gets automatically included when /updates/version5upgrade.php is run. Each separate update check is in its own file. The reason for this is to avoid conflicts when working in a large team when multiple programmers may all need to change the main update script. This approach solves the conflict issue because separate files are used.
- Some actions such as transforming content into a different format should only be performed once. Because an update script may be run several times in a major release branch it is important that the transformation is not reapplied. To solve this (starting at Rogo 6.0) there is a new To stop an update being run more than once there is a database tabled called sys_updates. Two functions
has_updatedcan be used to record and check whether an update has been done respectively.
- From Rogo 6.1 this process has been replaced with the new updaterttilsSome actions such as transforming content into a different format should only be performed on a specific version of Rogo. u
pdaterttils::check_versionfunction which should be added to each update script. It checks the version of rogo in
config/rogo.xmlagainst the current installed version in config/config. inc.php. This stops upgrade scripts being run more that once on a version as before but and also stops upgrades being run when they are not required i.e. from a previous version.