Liquibase is a great way to generate an SQL file programmatically.
We already have a database diff from an internal tool, and now we simply feed this into a changeset XML to get an SQL script for various databases. Almost perfect!
However, there are two problems: the lock tables should not be generated, and Liquibase seems to insist on a database connection even when just generating an SQL file.
Is there a “SQL-script-from-changelog-and-nothing-more” mode available programmatically?
Liquibase does currently require a database connection because some of the SQL generated by change tags depend on the database version and sometimes even the current state of database (although usually not). There may be some ways around that, but nothing yet. If you are running updateSQL, you do normally just need any database of the same type as your target with a databasechangelog table that matches your target database.
Note: you can probably create an extension liquibase.database.Database class that doesn’t need the connection. I haven’t tried it yet, but it should be possible even if it takes a bit of Java programming. Let me know if you are interested in more information on that.
The lock tables get included so that if regular liquibase runs go against the database at the same time they will know your script is updating it still. I did, however, just create an extension (https://github.com/liquibase/liquibase-nochangeloglock) that will cut out all changeloglock interaction. If you add it to your classpath, it will not use the databasechangeloglock tables at all.
I created https://liquibase.jira.com/browse/CORE-1656 for the updateSql without a live connection support. I’ll see if I can look at it with 3.1 but it is getting to be a full release already, it may not make it until 3.2.