Using Liquibase with AWS Redshift
Amazon Web Services Redshift is a fully managed, petabyte-scale data warehouse service in the cloud. An AWS Redshift data warehouse is a collection of computing resources called nodes. The nodes are organized into a group called a cluster. Each cluster runs an AWS Redshift engine and contains one or more databases.
Note: For more information, see the Amazon Redshift documentation page.
Supported Versions
- 3.0.28 – officially supported and tested with Test Harness
Prerequisites
Before using Liquibase with your database, ensure you have:
- Installed Liquibase.
- Created a Liquibase project folder to store all Liquibase files.
- Created a new Liquibase properties file or are using the existing
liquibase.properties
file included in the installation package. For more information, see Specifying Properties in a Connection Profile.
Driver Information
To use Liquibase and AWS Redshift, you need to have two jar files: JDBC and the Liquibase Redshift extension:
- Ensure you have downloaded the Amazon Redshift JDBC driver. You can download the JDBC 4.2–compatible driver (without the AWS SDK). If you use the Amazon Redshift JDBC driver for database authentication, make sure that you have AWS SDK for Java 1.11.118 or later in your Java class path. If you don't have AWS SDK for Java installed, download the ZIP file with the JDBC 4.2–compatible driver (without the AWS SDK) and driver dependent libraries for the AWS SDK.
- Place the
redshift-jdbc<version>.jar
file in theliquibase/lib
directory.
Example: redshift-jdbc42-2.0.0.4.jar
- Open the Liquibase properties file and add the driver value:
driver: com.amazon.redshift.jdbc42.Driver
- Go to the liquibase-redshift repository and download the latest released Liquibase extension
liquibase-redshift-<version>.jar
file. - Place the
liquibase-redshift-<version>.jar
file in theliquibase/lib
directory.
If you put the redshift-jdbc<version>.jar
and liquibase-redshift-<version>.jar
files in a different directory, specify the path in the Liquibase properties file, as follows:
Windows example:
classpath:"..path_to_your\\drivers\\redshift-jdbc<version>.jar; ..path_to_your\\liquibase-redshift-<version>.jar"
Linux example:
classpath:"../path_to_your/drivers/redshift-jdbc<version>.jar; ..path_to_your/liquibase-redshift-<version>.jar"
If you use Maven, you also need to download the AWS Redshift driver JAR file and put the driver in a location that your Maven build can access. Configure the Maven pom.xml
file to use the local copy of the driver JAR file. For example:
<dependency>
<groupId>com.amazon.redshift</groupId>
<artifactId>redshift-jdbc42</artifactId>
<version>2.0.0.4</version>
</dependency>
Additionally, you need to specify the Liquibase Redshift extension in your pom.xml
file as explained in Configuring Liquibase Attributes in your Maven POM File. Make sure that the Liquibase plugin and the extension have the same version.
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-redshift</artifactId>
<version>4.4.0</version>
</dependency>
Testing Your Connection
For Liquibase and AWS Redshift to work, you need to:
- Ensure your AWS Redshift database is configured. You can check the connection to an Amazon Redshift cluster.
- Specify the database URL in the Liquibase properties file, as follows:
-
Create a text file called changelog (
.xml
,.sql
,.json
, or.yaml
) in your project directory and add a changeset.
url: jdbc:redshift://endpoint:port/database
Example: url: jdbc:redshift://<cluster-identifier>.us-east-1.redshift.amazonaws.com:5439/databasename
Note: To get your JDBC connection, see Finding your cluster connection string.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.9.xsd">
<changeSet id="1" author="Liquibase">
<createTable tableName="test_table">
<column name="test_id" type="int">
<constraints primaryKey="true"/>
</column>
<column name="test_column" type="varchar"/>
</createTable>
</changeSet>
</databaseChangeLog>

-- liquibase formatted sql
-- changeset liquibase:1
CREATE TABLE test_table (test_id INT, test_column VARCHAR, PRIMARY KEY (test_id))
Note: Formatted SQL changelogs generated by using Liquibase versions previous to 4.2 might cause issues because of the lack of space after a double dash ( -- ).
Tip: To fix those issues, add a space after the double dash. For example: -- liquibase formatted sql
instead of --liquibase formatted sql
and -- changeset myname:create-table
instead of --changeset myname:create-table

databaseChangeLog:
- changeSet:
id: 1
author: Liquibase
changes:
- createTable:
columns:
- column:
name: test_column
type: INT
constraints:
primaryKey: true
nullable: false
tableName: test_table

{
"databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "Liquibase",
"changes": [
{
"createTable": {
"columns": [
{
"column":
{
"name": "test_column",
"type": "INT",
"constraints":
{
"primaryKey": true,
"nullable": false
}
}
}]
,
"tableName": "test_table"
}
}]
}
}]
}
- Navigate to your project folder in the CLI and run the Liquibase status command to see whether the connection is successful. You can pass arguments in the CLI or keep them in the Liquibase properties file.
- Run your first update with the update command, which makes changes to your database. You can also run the update-sql command to inspect the SQL before running the
update
command.
liquibase --username=test --password=test --changelog-file=<changelog.xml> status
liquibase --changelog-file=<changelog.xml> update-sql
liquibase --changelog-file=<changelog.xml> update
From a database UI tool, ensure that your database contains the table you added along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table.

