Changesets & Java integration

Does liquibase support running a registered Java class on a per changelog/set basis (for the cases where the data migration from one version to the next requires programmatic intervention) so that I can perform some JDBC operations directly against the DB before/after Liquibase has processed the XML definition for the upgrade.


If so, is any of this documented?

No.  You could conceivably write an extension that would abuse the various SQL-oriented contracts to generate no SQL to execute, but that would actually do some programmatic work (we’ve done some of this in the past); it is ugly and doesn’t really fit into the mental model of the tool very well.  (We needed the ability to do some data conversion in the JDBC driver for Informix, whose SQL implementation is broken in several data conversion respects.)


One thing that I think would be interesting would be to take the core of Liquibase (keeping track of various commands executed, checksumming them, providing certain kinds of conceptual rollback) and abstract it to various environments other than databases.  Think Chef or Puppet but in Java without necessarily relying on state verification—just relying on the fact that a given setup command was run or not.


Best,

Laird



http://about.me/lairdnelson

So in Liquibase, how would one approach such a scenario in a production continuous deployment mode where I need to insert/manipulate the database beyond normal SQL abilities in the Liquibase XML/SQL language.


The easiest approach is to use the http://www.liquibase.org/documentation/changes/custom_change.html custom change tag. I see the generated customChange page is fairly poor (I logged an issue to fix that).  Basically you create a class that implements Nathan