Upgrade Scripts

ROGO 6.5.0

Purpose

The upgrade script (e.g. `/updates/upgrade.php`) 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 the upgrade script may be used to 'fix' content that is wrong in the database due 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.

Principles

  1. The files in the /updates/scripts/ directory gets automatically included when /updates/upgrade.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.
  2. To stop an update being run more than once there is a database tabled called sys_updates. Two functions record_update and has_updated can be used to record and check whether an update has been done respectively.
  3. Some actions such as transforming content into a different format should only be performed on a specific version of Rogo. updaterttils::check_version function should be added to each update script. It checks the version of rogo in config/rogo.xml against the current installed version. This stops upgrade scripts being run more that once on a version and also stops upgrades being run when they are not required.