Using programmatically

Hi all,

  1. I would like to generate DDL SQL from a changelog file programmatically. Can I somehow accomplish this through the Liquibase class? I’m trying to embed the library in another application.

  1. Can the changelog file be created programmatically (that would require an object model to be exposed I guess) ?


Yes, you can generate the SQL and changelog files programmatically.

The SQL gets generated through a few steps, the easiest hook is from the SqlGeneratorFactory.generateSql(SqlStatement, database) method although depending on what you are wanting to do there are other approaches as well.

The liquibase.changelog.DatabaseChangeLog class is the in-memory representation of the changelog file that gets parsed from xml/json/etc. You can create instances of that class however you want and liquibase can use it.