tackley/dbdeploy — pull request #7 by alanraison (2013-02-08 21:47:22+00:00)
Title: Create changelog table

Hi

I've been using dbdeploy at work, and I found I needed to be able to create the changelog table. I see from the open issues that there are a couple of requests for such a feature.

I've refactored most of the template code into a TemplateProcessor class, and created freemarker templates for the table creation scripts. QueryExecuter has a new "doesTableExist" method, which in the end used some complex JDBC calls. This is used to determine whether the changelog table needs to be created.

DatabaseSchemaVersionManager has a new subclass, EmptyDatabaseSchemaVersionManager which doesn't throw an error if the changelog table doesn't exist; this is only used if the user specifies that the changelog table may be created if necessary.

The two ChangelogAppliers now have an additional constructor parameter; ChangelogTableCreator which when set will produce the necessary SQL to create the changelog table. When null, the original behaviour is maintained.

I've also got a few more ideas in the pipeline; tool-appropriate logging to replace the System.err.println()s and maybe some database-specific override mechanism.

Let me know if you need any more detail, but I think the changes are fairly simple.

Regards

Alan