Offline Database Support

If you cannot run Liquibase directly against a database, there are two major options to ensure your database is kept up to date.

update-sql

The most common way to manage "offline" databases is to use the update-sql functionality.

The update-sql command reads a database's DATABASECHANGELOG table and outputs the SQL that would run as part of the upgrade. This SQL includes inserts into the DATABASECHANGELOG table and can be ran against any database to both upgrade it and keep its history correct.

It is important that the database you generate the SQL from is the same as the database(s) you plan to run the SQL against.

Unless you have preconditions in your changelog file, the update-sql process only reads the DATABASECHANGELOG table to determine what changesets to run. Therefore if, for example, you have a production database that you cannot run Liquibase against directly and it may be different than your test databases, you can copy or restore just the DATABASECHANGELOG table from the production database into a database you can run update-sql against. Then run the generated SQL against the actual production database.

Offline Database

Since 3.1.0

If your environment does not lend itself to using update-sqlwith test and backup databases, you can run Liquibase using an “offline” database.

Running in offline mode only supports update-sql, rollback-sql, tag, and tag-exists. It does not support direct update, diff, or preconditions as there is nothing to actually update or state to check.

An offline database is “connected” to using a URL syntax of offline:DATABASE_TYPE?param1=value1&aparam2=value2.

Available parameters

Attribute Description
changelog-file Specify the file acting as the DATABASECHANGELOG table. Defaults to databasechangelog.csv in the working directory.
version Specify the database version to ensure generated SQL matches target database version. Example: 5.4.2 or 12.1.0.3
productName Specify "product name" seen by the JDBC driver.
catalog Specify the connection catalog
caseSensitive Specify if the database is case sensitive or not
outputLiquibaseSql If set to true, output from update-sql will include create/insert statements for the DATABASECHANGELOG table. Defaults to false.

Examples

  • offline:oracle
  • offline:mssql?changelog-file=/src/changelog.csv
  • offline:mysql?version=5.4.21&changelog-file=/src/changelog.csv