Connect Liquibase to Snowflake

Before you begin

  • Install Liquibase

  • Ensure you have Java installed. Liquibase requires Java to run. If you used the Liquibase Installer, Java is included automatically. Otherwise, you must install Java manually.

Procedure

1

Install drivers

The latest version of Liquibase has a pre-installed driver for this database in the $LIQUIBASE_HOME/internal/lib directory, so you don't need to install it yourself.

If you prefer, you can use environment variables to point to the directory where Liquibase is installed on your machine. You can set environment variables using your operating system's shell. The location of $LIQUIBASE_HOME will depend on where Liquibase was installed on your machine.

Note for Maven users: If you're running Liquibase using the Maven plugin using mvn liquibase:update, installing the extension with Maven ensures the right files are available and everything works together automatically. You can manage these extensions by adding them as dependencies in your project’s pom.xml file. Configuring Maven this way ensures that the necessary JAR files are retrieved from Maven Central during the build phase.

2

Configure your connection

Add your Snowflake connection details to your liquibase.properties file.

Be sure to:

  • Replace your_account_id with your account identifier. You can find this in the Account Details section of your Snowlake profile. This will be in the format ABC123-PROD.

  • Replace your_database with the name of your database.

  • Replace your_schema with the name of your schema (often PUBLIC).

  • Replace your_username with your Snowflake username.

  • Replace your_password with your Snowflake password.

Note: Make sure your Snowflake user has permission to create and modify tables in your target schema.

liquibase.command.url=jdbc:snowflake://your_account_id.snowflakecomputing.com/?db=your_database&schema=your_schema
liquibase.command.username=your_username
liquibase.command.password=your_password
3

Test your connection

1. Create a text file called changelog (.sql, .yaml, .json, or .xml) in your project directory and add a changeset.

If you already created a changelog using the init project command, you can use that instead of creating a new file. When adding onto an existing changelog, be sure to only add the changeset and to not duplicate the changelog header.

loading

2. Navigate to your project folder in the CLI and run the Liquibase status command to see whether the connection is successful:

liquibase status

Note: You can specify arguments in the CLI or keep them in the Liquibase properties file.

If your connection is successful, you'll see a message like this:

4 changesets have not been applied to <your_connection_url> Liquibase command 'status' was executed successfully.

3. Inspect the deployment SQL with the update-sql command

liquibase update-sql

If the SQL that Liquibase generates isn't what you expect, you should review your changelog file and make any necessary adjustments.

4. Then execute these changes to your database with the update command:

liquibase update

If your update is successful, Liquibase runs each changeset and displays a summary message ending with:

Liquibase: Update has been successful. Liquibase command 'update' was executed successfully.

5. Verify that the database contains your test_table and the DATABASECHANGELOG, and DATABASECHANGELOGLOCK tables.