Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Summary:
There are four ways to provide parameters for Liquibase
- CLI arguments
- Environment variables
- liquibase.properties file
- Flow file
The properties file is a convenient way to store and view the properties and configurations that Liquibase uses. However, this file only has dynamic values when using either the Hashicorp Vault Extension or the AWS Secrets Manager Extension.
It can be beneficial to use different properties files if there is a single server that runs Liquibase where the CI/CD tool can pass in a dynamic value for which liquibase.properties file to use. For example, you can have a properties file configured for each database.
This article will cover how to use different liquibase.properties files for that scenario.
Environment Conditions:
- Any version of Liquibase Pro or Open Source
How to configure multiple liquibase.properties files
- Create a properties file, following Create and Configure a liquibase.properties File.
- The file name can be anything, but the type of the file needs to be properties: .properties
-
When running a Liquibase command, pass in the defaults-file property.
-
CLI argument
-
--defaults-file=.properties
-
- Environment variable
-
LIQUIBASE_DEFAULTS_FILE=.properties
-
-
Flow file
-
globalArgs: {defaults-file: ".properties"}
-
-
Properties file
-
liquibase.defaultsFile:.properties
-
-
CLI argument
-
The properties file will be picked up by Liquibase and the parameters in that file will be used.
- By default, the defaults-file parameter is set to
liquibase.properties
.
- By default, the defaults-file parameter is set to
Example:
In this example, there is a single server that is running Liquibase and there is a directory called property_files that contains two properties files.
- liquibase_postgres.properties
- liquibase_oracle.properties
And one variable will be defined in the environment
- TARGET_DATABASE
The command that is used in the pipeline script can be:
liquibase --defaults-file=/property_files/liquibase_${TARGET_DATABASE}.properties status
The environment variable TARGET_DATABASE can then be set to either Postgres or Oracle, and that is the properties file that will be used during the Liquibase command.
Related Article(s):
N/A
Comments
0 comments
Article is closed for comments.