Chapter 4. Updating Databases

Periodically, as new versions of PRepS are released, modifications are made to the database schema. By convension, if the database schema is updated, the second number in the PRepS version is also updated. For example, if the previously installed version of PRepS is 1.4.4, and you upgrade to version 1.6.0, you will need to update any existing PRepS databases. On the other hand, upgrading from version 1.4.4 to 1.4.5 does not require a database update.

Development Versions: In the previous example, notice that the update involving a database update was from 1.4.x to 1.6.x. What happened to 1.5.x? In the tradition of several Open Source projects, if the second number is odd, it indicates that the version is part of a development series.

The database schema will undergo several changes during a development series. For this reason, you should never use development versions of PRepS with production database. Only use test databases, or test copies of production databases.

When testing development version, always update test databases between development version upgrades.

The update_prepsdb Script

update_prepsdb [-c | -h | -v] [-o path] [-P path] [-p path] [-u username] dbname

The update_prepsdb script is used to update existing databases to the current schema version. This script will destroy the current database, create a new database of the same name using the new schema, and load the newly created database with the data from the old database. A backup copy of the old database is automatically created first in case something goes wrong. The backup is stored in the current working directory in a file called DB_NAME.backup.

To ensure proper operation, the update_prepsdb script must be run from the PostgreSQL super user account. The update_prepsdb script understands the following options.