database-class parameter

The database-class global parameter is a string that specifies which implementation of our Database class to use. By default, Liquibase automatically determines the correct class based on your database connection.

Uses

When Liquibase connects to a database, it selects an implementation of our Database class that represents the type of database you have connected to. We use that selection to know what kind of database you have and what functionality it supports.

You should generally rely on Liquibase’s auto-detection logic to implement the Database class. However, you can override the selected class with the database-class parameter.

Setting the database-class parameter

You can set database-class in four ways:

  • As a JVM system property
  • In your liquibase.properties file
  • As a global parameter in the CLI
  • As an environment variable (Liquibase Pro)

Java system property

You can set database-class as a Java system property by using the JAVA_OPTS Environment Variable in your command line. The syntax on Mac/Linux is as follows:

JAVA_OPTS=-Dliquibase.databaseClass=YOUR_CLASS && liquibase update --changelog-file=dbchangelog.xml

The syntax on Windows requires the set command:

set JAVA_OPTS=-Dliquibase.databaseClass=YOUR_CLASS && liquibase update --changelog-file=dbchangelog.xml

liquibase.properties parameter

In Liquibase 4.1+, you can set database-class by adding the following to your liquibase.properties file:

liquibase.databaseClass: YOUR_CLASS

CLI global parameter

You can use database-class as a global parameter in your command line with a single Liquibase command, such as update:

liquibase --database-class=YOUR_CLASS update --changelog-file=dbchangelog.xml

Environment variable (Liquibase Pro)

If you use Liquibase Pro, you can set database-class as an environment variable. The syntax on Mac/Linux is as follows:

LIQUIBASE_DATABASE_CLASS=YOUR_CLASS

The syntax on Windows requires the set command:

set LIQUIBASE_DATABASE_CLASS=YOUR_CLASS

Note: The commands shown above only apply to the current shell. If you need to pass an environment variable to a child process without affecting the parent process, you can use the export command on Mac/Linux or the setx command on Windows.