How do I modify createTable in an extension?

Google’s spanner database special syntax on createTable change type, the feature “interleaved tables”

Spanner is a distributed database. Interleaved tables are basically a way to indicate that the tables are often queried together and data should be located close together when possible. I’ll be updating the spanner extension here

What would be the best way to add an interleaved attribute to createTable? It seems there could be many ways.

  • modifySql type, checking for spanner only, to append the interleaved syntax. No extension needed.
  • make a new createTableSpanner element, which copies dbchangelog-4.2.xsd but with interleaved as an attribute. This would make more obvious that non-standard features are being used.
  • Have the spanner extension extend the createTable adding in the interleaved attribute. If commands were copied to another database, liquibase would probably just ignore the interleaved element because of the “namespace=”##other" processContents=lax" in the xsd
  • Some other way with the Change type?

Is there a best practice on this?

Hi @jimmyrcom,

Great question, thanks for working on the extension. Here are a couple resources:



How common is the use of interleave? If not very common, I’d tend to leave it up to users adding to append it on. The built-in change functions like createTable aren’t supposed to be a replacement for SQL, they are there as convenience functions for commonly used changes. The modifySql tag is there for all the cases where the SQL a user wants is ALMOST what the change function can support but is missing just a little bit.

For example, the createTable doesn’t have support for the engine clause for mysql. If people want to specify that, they can use createTable with <modifySql><append> ENGINE=MyISAM</append></modifySql>. If they expect their changelog to be ran against multiple databases, they can add dbms="mysql" into the modifySql tag.

That being said, at some point a clause is commonly used enough that you don’t want your users to deal with the modifySql tag and just be able to add an interleaveInParent="singers" to the createTable tag.

The best way to do that is your option #3, of defining it in a separate namespace. We have an “ext” xsd ( which is a simple “allow anything” so you can have <createTable name="albums" ext:interleaveInParent="singers"> or you can define your own xsd so it would be <createTable name="albums" spanner:interleaveInParent="singers">.

The main problem with defining a custom xsd is where and how to store it on the internet. Currently you can send us the file and we can put it up on the site along with the others, but it is a bit of a manual process currently. We’re working to improve that in the future, though.

Whether you use the generic xsd or a custom one is only used by the XML parser and xsd-aware tools like IDEs. One the attribute gets past the xml parser, liquibase no longer cares about what namespace the attributes came in on.