Extend Changeset


I am saving changelog.xml in database, then parsing back to objects and working with them on my web application.

But I got a demand that needs to flag each change with a boolean to verify it will be generated on final sql script.

As far as I know, I could extend each Change adding something like shouldBeProcessed attribute, but it demands modifying all Changes. 

Since I am using 1 Change with one Changeset, it could be better to adding that attribute to Changeset. 

How could I do that?

It would probably make most sense to put on the changeSet. You would have to create a subclass of ChangeSet that is created by your ChangeLogParser. Are you using a standard changelog parser class? Or did you write your own?

Alternately, you could create a custom shouldBeProcessed precondition that you could add to all applicable changeSets. That would probably be less intrusive code-wise than a changeSet subclass but would result in a larger changelog file.


Actually I didn’t know that I could write my own ChangeLogParser. But I found another way:

  • created an enum called something like Process with atributes “process” and “dont_process”

  • when I create a new changeset, I use that flag as a context value

  • then when I generate my sql file, I just process changesets with contexts that have “process” value

Is it a good approach?

If it is working for you, that is the main thing. Seems like a reasonable approach.



Just to clarify in my next changes, how are the steps to create my own tags inside a ChangeSet?

  • extend ChangeSet class adding needed attributes;
  • create my own implementation of ChangeLogParser
  • create my own handler by extending org.xml.sax.helpers.DefaultHandler (since XMLChangeLogSAXHandler is default package) - what about dbchangelog.xsd?

Those steps sound about right. You probably don’t want to try to modify dbchangelog.xsd but instead use a separate XSD/namespace for your new attributes.