Spring-based schema update management

I’m posting this here because I thought it might be interesting and/or useful to other Liquibase users, and also because I’d be interested in hearing other folks’ perspective, as I’m coming at things from a different perspective.

The problem of database schema management is of course an old one, and a long while back (before Liquibase existed) some coworkers and I developed our own schema management tool. Over time variants and partial re-inventions of this tool have found their way into a few different projects.

Later, I looked at Liquibase as a possible replacement for our this tool. However Liquibase still didn’t have the features we needed, which were:

  • Automatic initialization of the database schema when the application runs for the first time
  • Automatic application of database schema updates as needed during each application startup cycle
  • Automated tracking and constraint-based ordering of schema updates supporting multiple code branches
  • Integration with Spring allowing simple XML declaration of updates
  • Provides a DataSource implementation
  • An ant task that verifies schema update correctness
So I decided finally to publish this tool as part of a larger open source project (those bullet points are from the project’s documentation). The schema stuff is in this Java package.

My project does use Liquibase for the schema verification part (i.e., the schema “diff” operation) and it’s working great.

Thanks.

This is really cool. Have you considered contributing your work as a Liquibase extension? You may like to leave the configuration stuff out of the extension, e.g. DataSource, Ant/Spring integration etc. and focus on only the functionality you bring in.


In fact I have been thinking of using a subset of Liquibase for development workflow so that I can update the schema as the data model changes (model driven development.) If you have any input on that line of thought please share your idea.


Regards,

Shantanu


 Have you considered contributing your work as a Liquibase extension? You may like to leave the configuration stuff out of the extension, e.g. DataSource, Ant/Spring integration etc. and focus on only the functionality you bring in.

I would like to consider that but I’m currently too busy to do any work on it. If someone else were interested then I’m all for it.

In fact I have been thinking of using a subset of Liquibase for development workflow so that I can update the schema as the data model changes (model driven development.) 


I’ve had good success with the following approach:
  • Original schema (before the first update) and expected schema are checked in to source repository
  • Schema is automatically generated during the build from the model classes and build fails if it does not match the expected schema
  • When schema changes due to model class changes, expected schema is updated and a schema update is added (all in the same commit), and the “schemacheck” process verifies that original schema + all updates = new expected schema.
  • All developers review commit emails to check that nobody does something dumb like commit a schema change without a corresponding update, etc.
  • Schema updates are merged into code branches as atomic commits containing the model class change and the update. Spring XML will be invalid if an update is merged in without one of its required predecessors.
The most common error is adding and update but not including a required predecessor… because this requires developers to review and understand all prior updates to find them.