Generate sql without database connection

Hi, I am evaluating Liquibase for the following purpose: Programmatically generate an SQL script to run on a production server later on.


I have two constraints: 


  1. I cannot access the database when generating the SQL.


  1. I cannot add auxiliary tables to production databases, like the liquibase lock tables


I wonder if anyone has succeeded in using liquibase without a connection, and if there is some setting not to generate lock tables?


Thanks!


Currently a connection is required for a couple reasons:

  • The generated SQL to execute depends on the type of database you are connecting to, version, and runtime database settings.

  • Preconditions and some changes may try to access the database for current state


Liquibase also only supports managing the databasechangelog and databasechangeloglock table within the database.


It should be possible to create extensions to get around both requirements but I have not tried creating them yet. 


What I normally suggest for people running against a locked down production database is to use the updateSQL functionality against a copy of production (often times the final QA database) to generate the SQL needed to update the copy and the real production database. Then you can just use the generated script whenever you need to deploy to production. In this case, the <a href=“https://github.com/liquibase/liquibase-nochangelogupdate” statements.


Nathan



  1. Shouldn’t there be a way to obtain type of db, version without a connection? This is a real annoyance and I’m not sure how to solve it with extensions. Please advice.


2. A copy of the production db is not practical, so I will try to create an extension.


An extension would be able to specify the type of database even without a connection. Off hand, I would think you would specify everything in your JDBC url. Something like:


“jdbc:disconnected:oracle” or “jdbc:disconnected:oracle?version=10.2”


You could then create subclasses of the standard database types that respond to those URLs and then mock out normal calls that need to access the database. You will need to create a subclass for each database you care about, because the “if” logic in the SQL generators say “if database instanceof OracleDatabase” so you will need a “DisconnectedOracleDatabase extends OracleDatabase” class, not just a single “DisconnectedDatabase implements Database” class for all databases.


Let me know if you need more help with the extension.


Nathan