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?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK