Load Data with Liquibase

Liquibase provides a database schema management solution that allows you to add version control to your SingleStore databases, manage revisions of your database, and deploy scripts. You can connect your SingleStore databases to Liquibase using the SingleStore JDBC driver. Refer to Supported features for a list of Liquibase features that SingleStore supports.

Prerequisites

  • A SingleStore cluster running SingleStore version 8.1 or later.

  • Download the SingleStore JDBC driver .jar file.

  • Download the Liquibase extension for SingleStore.

  • Install Liquibase.

Connect with Liquibase from SingleStore

To connect to your SingleStore database with Liquibase,

  1. Run the following command to initialize a new Liquibase project:

    liquibase init project

    You may use the default properties or customize the available parameters while initializing a new project. In this guide, we'll use liquibase.properties as the defaults file.

  2. Place the downloaded SingleStore JDBC driver and Liquibase extension for SingleStore .jar files in the liquibase/lib directory. If you are using Maven, add the following dependencies to your pom.xml file:

    <dependency>
    <groupId>com.singlestore</groupId>
    <artifactId>singlestore-jdbc-client</artifactId>
    <version>1.1.5</version>
    </dependency>
    <dependency>
    <groupId>org.liquibase.ext</groupId>
    <artifactId>liquibase-singlestore</artifactId>
    <version>1.0.0</version>
    </dependency>
  3. Customize the following parameters in the liquibase.properties file:

    • url: Specify the connection string for your SingleStore database in the following format: jdbc:singlestore://<hostname>:<port>/<database>.

    • username: Specify the username of the SingleStore database user that is used to access the database.

    • password: Specify the password for the SingleStore database user.

    • driver: Specify the JDBC Driver Class as com.singlestore.jdbc.Driver.

    • classpath: Specify the path to the downloaded SingleStore JDBC driver .jar file, including the filename and the .jar extension.

    Here's a sample liquibase.properties file:

    url:jdbc:singlestore://svchost:3306/dbTest
    username:s2user
    password:pa55w0rd
    liquibaseProLicenseKey: licensekey
    liquibase.hub.APIKey: APIKey
    driver:com.singlestore.jdbc.Driver
    classpath=~/singlestore-jdbc-client-1.1.5.jar
  4. Update the changelog file in your project, and add a changeset. In this guide we'll use the following changelog.sql file:

    -- liquibase formatted sql
    -- changeset admin:1
    CREATE TABLE Stock (ID INT, Code VARCHAR(4), PRIMARY KEY(ID))
  5. Run the following command from the Liquibase installation directory:

    liquibase status --changelog-file=changelog.sql
    --
    Liquibase command 'status' was executed successfully.

    For a successful connection, the output contains a similar message.

Refer to Using Liquibase with SingleStore for more information.

Last modified: September 29, 2023

Was this article helpful?