Using Liquibase to generate SQL file only

Hi,


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?


Thanks for any input on this!


This is great news, I’ll try the nochangeloglock extension sono.


We are very interested in more information on an extension to avoid connections (but still generate correct SQL code for a target database.)


I have no idea how to write extensions, so I probably need more details than you might have hoped for :slight_smile:


Thanks!

I just tried the nochangeloglock extension.


It works for lock table, but still seems to generate inserts into DATABASECHANGELOG. I only want SQL relevant for the database changes. 


Any hints on how to avoid generating this insert?


Thanks!

Please let me know if there’s anything I can do to help make this into 3.1 - it’s really important for me, but I understand that there’s lot to do :slight_smile:


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.


Nathan



To avoid the inserts into databasechangelog you’ll have to also use the https://github.com/liquibase/liquibase-nochangelogupdate extension.


Nathan

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.


Nathan