Using Liquibase with ScyllaDB
ScyllaDB is a high-performance NoSQL database that offers drop-in compatibility with Apache Cassandra. ScyllaDB implements the Cassandra Query Language (CQL) and uses the same wire protocol, making it fully compatible with the Liquibase Cassandra extension without any code modifications.
For more information about ScyllaDB, see the ScyllaDB Documentation.
Compatibility
ScyllaDB works seamlessly with the Liquibase Cassandra extension as a drop-in replacement for Apache Cassandra. All core Liquibase operations are supported, including:
- Schema migrations (DDL operations)
- Data manipulation (DML operations)
- Changelog tracking
- Distributed locking
- Rollback functionality
For detailed compatibility information and test results, see the ScyllaDB Compatibility section in the extension repository.
Prerequisites
Setup Liquibase
- Dive into Liquibase concepts with an Introduction to Liquibase.
- Download and install Liquibase on your machine.
-
(optional) Enable Liquibase Pro capabilities
To apply a Liquibase Pro key to your project, add the following property to the Liquibase properties file:
liquibase.licenseKey: <paste key here>
Setup ScyllaDB
-
Using Docker (recommended for local development)
ScyllaDB can be easily run using Docker:
Standard setup:
docker run --name scylladb -p 9042:9042 -d scylladb/scylla --smp 1macOS setup (requires additional flag):
docker run --name scylladb -p 9042:9042 -d scylladb/scylla --reactor-backend=epoll --smp 1Note
macOS users must include the
--reactor-backend=epollflag due to reactor backend requirements.Wait 15-20 seconds for ScyllaDB to fully initialize before connecting.
-
Production deployments
For production environments, follow the official ScyllaDB Installation Guide.
-
Create your Keyspace
Connect to ScyllaDB using
cqlshand create a keyspace:docker exec -it scylladb cqlshCREATE KEYSPACE my_keyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };The keyspace will be referenced in your Liquibase configuration as the schema.
Install drivers
ScyllaDB uses the same drivers and extension as Apache Cassandra. No ScyllaDB-specific drivers are needed.
Follow the installation instructions in the Apache Cassandra tutorial, which covers:
- Downloading the Cassandra JDBC wrapper
- Downloading the Liquibase Cassandra extension
- Placing JAR files in the correct directory
- Configuring the JDBC driver
- Maven configuration (if applicable)
Database connection
Configure connection
ScyllaDB uses the same JDBC connection format as Apache Cassandra.
-
Specify the database JDBC URL in the
liquibase.propertiesfile:url: jdbc:cassandra://<host>[:<port>]/<keyspace>?compliancemode=Liquibase&localdatacenter=<datacenter_name>Example for local Docker setup:
url: jdbc:cassandra://localhost:9042/my_keyspace?compliancemode=Liquibase&localdatacenter=datacenter1 -
Configure credentials:
username: cassandra password: cassandraNote
ScyllaDB uses
cassandra/cassandraas default credentials. For production, configure appropriate authentication following the ScyllaDB Security Guide.Note
Always specify the
compliancemode=Liquibaseparameter to ensure correct behavior.Tip
For complete JDBC connection string options, see the Cassandra JDBC connection strings documentation.
Test connection
-
Create a text file called changelog (
.xml,.sql,.json, or.yaml) in your project directory and add a changeset.If you already created a changelog using the
init projectcommand, 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.-- liquibase formatted sql -- changeset my_name:1 CREATE TABLE test_table ( test_id INT, test_column INT, PRIMARY KEY (test_id) )
<?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-latest.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-latest.xsd"> <changeSet id="1" author="my_name"> <createTable tableName="test_table"> <column name="test_id" type="int"> <constraints primaryKey="true"/> </column> <column name="test_column" type="INT"/> </createTable> </changeSet> </databaseChangeLog>
databaseChangeLog: - changeSet: id: 1 author: my_name changes: - createTable: tableName: test_table columns: - column: name: test_column type: INT constraints: primaryKey: true nullable: false
{ "databaseChangeLog": [ { "changeSet": { "id": "1", "author": "my_name", "changes": [ { "createTable": { "tableName": "test_table", "columns": [ { "column": { "name": "test_column", "type": "INT", "constraints": { "primaryKey": true, "nullable": false } } } ] } } ] } } ] }
-
Navigate to your project folder in the CLI and run the Liquibase
statuscommand to see whether the connection is successful:liquibase status --username=test --password=test --changelog-file=<changelog.xml>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:
1 changeset has not been applied to <your_jdbc_url> Liquibase command 'status' was executed successfully. -
Inspect the SQL with the
update-sqlcommand. Then make changes to your database with theupdatecommand.liquibase update-sql --changelog-file=<changelog.xml> liquibase update --changelog-file=<changelog.xml>If your
updateis successful, Liquibase runs each changeset and displays a summary message ending with:Liquibase: Update has been successful. Liquibase command 'update' was executed successfully. -
From a database UI tool, ensure that your database contains the
test_tableyou added along with the DATABASECHANGELOG table and DATABASECHANGELOGLOCK table.
Now you're ready to start making deployments with Liquibase!
Additional resources
- ScyllaDB Documentation
- ScyllaDB Compatibility - Detailed compatibility information in the extension README
- Apache Cassandra tutorial - Complete reference for driver installation and configuration
- Liquibase Cassandra Extension Repository