From time to time, developers need to modify the database structure to cope with new features. In some cases, these modifications can be applied to existing databases without losing their contents. This is possible when stored procedures are replaced or when new tables are added (and their contents are not fundamentally needed in normal LXR operation). Of course, full database functionality and integrity can be guaranteed only after next genxref indexation.

Database upgrade is a feature provided by script recreatedb.pl in LXR 2.2 and higher.

Required files before upgrade

The bare minimum needed to upgrade the LXR database(s) is the master configuration file lxr.conf.

Check you also have the context file custom.d/lxr.ctxt though it can be reconstructed but not without inconsistency risk.

Upgrading

The LXR configuration and database creation steps are replaced by the following procedure.

  1. Run script recreatedb.pl IMPORTANT! This script is designed to be run from the LXR root directory. Eventually type command: $ cd /LXR/root/directory $ ./scripts/recreatedb.pl --verbose

    You can also use a copy of the configuration file:

    $ ./scripts/recreatedb.pl --verbose custom.d/lxr.conf *** LXR DB initialisation reconstruction (version: 2.2) *** LXR root directory is /home/myself/lxr Configuration read from custom.d/lxr.conf Initial context custom.d/lxr.ctxt is reloaded Your DB engine was: MySQL Configuration file custom.d/lxr.conf loaded *** scanning global configuration section *** *** scanning tree1 tree configuration section *** *** scanning tree2 tree configuration section *** *** scanning tree3 tree configuration section ***

    recreatedb.pl creates a script custom.d/initdb.sh containing SQL instructions to rebuild all database corresponding to the trees described in the master configuration file (and consequently to update database schemata).

  2. Upgrade the databases $ NO_DB=1 NO_USER=1 ./custom.d/initdb.sh The important point here is the modification of the local environment by the shell variables NO_DB and NO_USER which respectively suppress database and user creations. Original contents is therefore preserved. See the notes related to this script in the configuration step .
  3. Eventually, if your trees were modified, reindex them $ ./genxref --allurls This is the only case where option --allurls is recommended. Under some unclear circumstances, reindexing PostgreSQL trees may fail. In that case, abort the running genxref with control-C and relaunch individual genxrefs from the failing tree onward: $ ./genxref --url=... --reindexall Option --reindexall is only necessary on the failing tree to force a clean database.

Advanced usage

See the Reconstructing Databases tip.