Chapter 7. Upgrading and Database Migration

Upgrading to higher versions of JTrac is usually as simple as replacing the WAR file and deleting the web-app server temporary / work folder before re-starting. In some rare cases the database schema may have changed and a script for updating the database would then be provided. It may also happen that upgrading the Jetty version would be recommended in case you happen to be using the bundled Jetty webapp-server for deploying JTrac.

7.1. Deleting webapp temporary files

In case you are using the bundled Jetty server in the JTrac distribution, you should delete the contents of the folder called "work". Note that Jetty expects a folder called "work" to exist when it starts, so ensure that you leave the empty "work" folder in place.

If you are using another application server please follow the steps for removing temporary files corresponding to the server that you are using.

7.2. Upgrading the Database

Previously, if the JTrac release notes mentioned database schema changes, you needed to additionally run an upgrade script before restarting the webapp-server with the new WAR in place. Upgrade scripts came in the form of Beanshell scripts (*.bsh) and would be always released within the "etc" folder of the JTrac downloadable distribution.

But starting with version 2.2.1, JTrac is configured to update the database automatically, so nothing needs to be done for this.

7.3. Upgrading Jetty

If you are using the embedded Jetty web-app server, you can also choose to upgrade the JAR files that make up Jetty. This is optional, but is as simple as overwriting the contents of the "lib" directory with the corresponding files within the new distribution. You can easily check if the Jetty related JAR file versions have changed because the file-names clearly include the version numbers.

7.4. Database Migration

Using the Beanshell based approach above, it is relatively straightforward to port data into another database. This is useful especially in those cases where you start off using JTrac with the embedded HSQLDB database and then decide to scale up and move to something like MySQL.

First, you should start the application re-configured to point to the new database and let JTrac do the hard work of creating all the database tables. It is not necessary for Jtrac to be shut-down before proceeding with the next step, but don't log-in yet!

A Beanshell script called "jtrac-hsqldb-to-mysql.bsh" is available in the "etc" folder of the JTrac distribution. You can execute this just like described in the previous section on upgrading. Note that you will need to have both the database drivers on the classpath in this case. You should of course edit the database connection parameters (for database 1 and database 2) to suit your environment. Some more instructions are provided within the script file on how to ensure database encoding and invoke the script on the command line. For example, if your database has a lot of data, you should configure the Java process to use more memory by passing a command line parameter like "-Xmx512m".

This particular script is extremely generic and it should be possible to use this to migrate across combinations of databases other than HSQLDB and MySQL. The use of BeanShell means that you can edit the script without needing to compile it.

Do back-up your data before performing a database migration. You are well advised to perform a "dry-run" and test if everything is ok once. Do check if special characters (e.g. Japanese / Chinese) can still be viewed correctly when JTrac is using the new database. Also pay attention to any errors or warning messages that may appear on the console when the migration script runs.