Applies to
- Liquibase Pro
- Liquibase Open Source (Community)
Summary
Liquibase is a versatile database change management tool that can be configured to deploy changes to multiple types of databases, such as Oracle and PostgreSQL, from a single instance. Below is a general guide to setting up Liquibase for this purpose.
Environment Conditions
- Any version of Liquibase Pro or Open Source
How to Configure a Single Instance of Liquibase for Multiple Databases
This article will review two popular ways to configure a single instance of Liquibase to run on multiple databases.
Liquibase Properties Files
Step 1: Create separate configuration files for each database
Example for Oracle (liquibase.oracle.properties):
changeLogFile=oracle_changelog.xml
url=jdbc:oracle:thin:@//hostname:1521/service_name
username=oracle_user
password=oracle_password
Example for PostgreSQL (liquibase.postgres.properties):
changeLogFile=postgres_changelog.xml
url=jdbc:postgresql://hostname:5432/database_name
username=postgres_user
password=postgres_password
Step 2: Run Liquibase for Each Database
For Oracle:
liquibase --defaultsFile=liquibase.oracle.properties update
For PostgreSQL:
liquibase --defaultsFile=liquibase.postgres.properties update
CLI Arguments
The other alternative is to pass the required database information in as CLI arguments.
liquibase \
--changeLogFile=${CHANGELOG} \
--url=${DB_URL} \
--username=${DB_USERNAME} \
--password=${DB_PASSWROD} \
update
All of the variables can be defined in the pipeline/environment. When Liquibase runs, it will deploy and connect to whatever database is given.
This strategy is preferred when Liquibase runs inside a CI/CD platform.
Related Article(s)
N/A
Comments
0 comments
Article is closed for comments.