schemamule 1.0 released

May 23rd, 2006

We finally got around to open sourcing schemamule, a utility we wrote in the bioinformatics core at Northwestern. Schemamule copies the schema from one database to another (right now we support copying from Oracle to HSQLDB). We have used this tool for over two years now to set up an in-memory HSQDLB database to use for unit testing. This has at least a couple nice benefits:

  • Database-dependent tests (e.g. DAO tests) run much faster than when they are run against a database accessible only over the network, especially when working from home
  • Database-dependent unit tests can be run even if you aren’t on the network at all, very nice if you’re working on a plane, in an airport, or at the beach

We use schemamule primarily via its schemacopy Ant task, which has some nice configuration options if you just want to copy a subset of the table definitions from the schema, if you want to copy views, sequences, etc. Note that table records are never copied.

One of our apps does a number of funky custom-SQL queries for reporting (we have not yet taken the plunge and created a reporting data warehouse DB), and this meant that we had to fake a number of Oracle-specific features in HSQLDB. For example, in HSQLDB there is no DUAL table. We fake it by creating a table called DUAL that has one (and only one) row (the column names and record content being irrelevant). We also provide an HsqldbLibrary class to define other functions (e.g. TRUNC) not available in HSQLDB.

Anyway, if you do a lot of automated unit testing in Java, use Ant to automate your builds, and have slow database-dependent tests, try out schemamule, see if it helps, and let us know. Usage examples are available on the project website.