DSpace/DSpace — pull request #686 by tdonohue (2014-10-06 21:55:28+00:00)
Title: DS-2167: Add Flyway automatic database upgrades to DSpace

Unfortunately, this PR is not as far along as I had hoped. I think it's 85-90% of the way there, but likely needs another day to complete.

In any case, I figured I'd create a PR in case this is of interest to others for 5.0. If so, it will need more work, as you'll see below. This PR does the following (unchecked boxes have not been fully implemented yet):

[x] Integrates dspace-api with (Flyway)[http://flywaydb.org/] for automatic database schema upgrades (Upgrades occur when you startup DSpace - i.e. NO MORE RUNNING SQL SCRIPTS MANUALLY!)
[x] Refactors our various "database_schema*.sql" scripts into Flyway compatible SQL scripts
[x] Refactors the XMLWorkflow setup scripts into a Flyway compatible "Java migration". It is kicked off via Java in the new "org.dspace.storage.rdbms.migration.V5_0__XMLWorkflow_Migration" class, and ONLY Run when it's enabled in the workflow.cfg file.
[x] Reworks/simplifies Unit Tests to just use Flyway to initialize the Unit Testing Database
[ ] Create a Flyway "callback" to automatically reload metadata registry & format registry from config files each time a migration is done (not yet done)
[ ] Remove all Ant related DB scripts, as they are unnecessary (not yet done)
[ ] Fix Unit Test failure, because the "Metadata 4 All" Oracle upgrade script is unfortunately not compatible with H2 (as it uses "DECLARE" which is throwing an error in H2)
[ ] Other minor cleanup of notes / documentation to no longer require any manual DB upgrades.

I've done some basic testing of upgrades from 4.0 -> 5.0 database. It seems to work fine (even though Unit Testing fails cause of H2 / Oracle incompatibilities).

However, fair warning for developers: Testing this WILL REQUIRE you to start with a 4.0 compatible database. Flyway is not "smart" enough to know if you already manually ran the 'database_schema-4-5.sql" script yet...so it will attempt to run those database schema changes a second time.

So, still more work to be done, but I figured I'd get this in under the deadline just in case we want to rush to finish up in time for 5.0.