Unable to create DATABASECHANGELOG in Cassandra

I’m trying to setup Liquibase with Cassandra and while I appear to be able to connect, the problem begins when Liquibase tries to create a DATABASECHANGELOG table into the database.

I have been referencing the following information:

The version of Liquibase being used is 4.27.0.
The version of Cassandra being used is 3.11.9.

I downloaded the following wrapper and extension files from their recommended sources:

  • cassandra-jdbc-wrapper-4.12.0-bundle.jar
  • liquibase-cassandra-4.27.0.jar

My liquibase.properties file:

classpath=liquibase_libs/cassandra-jdbc-wrapper-4.12.0-bundle.jar
driver=com.ing.data.cassandra.jdbc.CassandraDriver
changeLogFile=changelog/changelog-root.yaml

When I run the following from the root directory of my Liquibase project folder:

liquibase status --username=<username> --password=<password> --url=jdbc:cassandra://localhost:9042/<database_name>?localdatacenter=datacenter1&compliancemode=Liquibase

I get the following output:

##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##                                                ##
####################################################
Starting Liquibase at 17:49:55 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
Liquibase Version: 4.27.0
Liquibase Open Source 4.27.0 by Liquibase
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
ERROR: Exception Details
ERROR: Exception Primary Class:  SyntaxError
ERROR: Exception Primary Reason:  line 1:42 no viable alternative at input '(' (CREATE TABLE DATABASECHANGELOG (ID [VARCHAR](...)
ERROR: Exception Primary Source:  Cassandra 3.11.9

Unexpected error running Liquibase: line 1:42 no viable alternative at input '(' (CREATE TABLE DATABASECHANGELOG (ID [VARCHAR](...) [Failed SQL: (0) CREATE TABLE DATABASECHANGELOG (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID VARCHAR(10))]

For more information, please use the --log-level flag

Would anyone be able to provide more assistance to why this is happening? Thanks

Another odd “bug” I noticed is that the order seems to matter for the options with compliancemode and localdatacenter.

When I order it as follows:
compliancemode=Liquibase&localdatacenter=datacenter1

like in the example link liquibase-cassandra/liquibase.properties at main · liquibase/liquibase-cassandra · GitHub, I get a different error:

##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##                                                ##
####################################################
Starting Liquibase at 10:07:11 (version 4.27.0 #1525 built at 2024-03-25 17:08+0000)
Liquibase Version: 4.27.0
Liquibase Open Source 4.27.0 by Liquibase
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
ERROR: Exception Details
ERROR: Exception Primary Class:  IllegalStateException
ERROR: Exception Primary Reason:  Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=127.0.0.1/<unresolved>:9042, hostId=<...>, hashCode=<...>)=datacenter1. Current DCs in this cluster are: datacenter1
ERROR: Exception Primary Source:  4.27.0

Unexpected error running Liquibase: Connection could not be created to jdbc:cassandra://127.0.0.1:9042/<db_name>?compliancemode=Liquibase with driver com.ing.data.cassandra.jdbc.CassandraDriver.  Unexpected error while creating connection.
  - Caused by: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=127.0.0.1/<unresolved>:9042, hostId=<...>, hashCode=<...>)=datacenter1. Current DCs in this cluster are: datacenter1

For some reason, Liquibase considers the DB as <unresolved>.

I believe the problem is the even when I set compliancemode=Liquibase, LIquibase still acts as if it where in normal SQL mode.

One tall tell sign it that it’s trying to create a DATABASECHANGELOG table with ID VARCHAR(255) and there is no VARCHAR type in Cassandra. The type should be TEXT instead.

Still, I don’t know what more needs to be set to make Liquibase be in Cassandra mode.

I tried using an older version of Liquibase (4.24.0) via container and it works:

liquibase@nixos:/liquibase/changeset$ liquibase status
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ## 
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ## 
##                                                ##
####################################################
Starting Liquibase at 17:41:35 (version 4.24.0 #14062 built at 2023-09-28 12:18+0000)
Liquibase Version: 4.24.0
Liquibase Open Source 4.24.0 by Liquibase
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
@jdbc:cassandra://localhost:9042/<database_name> is up to date
Liquibase command 'status' was executed successfully.

I think there is a bug with Liquibase version 2.27.0.

1 Like

Did you ever figure out a fix for this? I’m having the exact same issue. Though I’m using Liquibase 4.25, with 4.25 for the Liquibase Cassandra jar, and 4.13.1 for the Liquibase JDBC Wrapper jar.

@IdleThought have you tried a more recent version of Liquibase? The latest is 4.29.2. I’m sure that we’ve added quite a few updates to Liquibase and Cassandra support since 4.25.

If you keep running into this issue and believe it’s a bug, you could also file an issue in the liquibase-cassandra extension repo here: GitHub · Where software is built

So how I resolved the issue was not specifying class path. For some reason when trying to run liquibase and specifying the JDBC jar and the extension jar via classpath, the extension jar seems to be ignored. Not sure why, but the moment I just simply placed both jars in the lib folder (that contained the liquibase-core.jar) and then ran the liquibase command, everything worked perfectly. I really wish these jars were simply included when you installed liquibase from the getgo.

@IdleThought I’m glad you were able to get this resolved. As to your comment:

This is something that we are aware of and plan to address in the future for a better developer experience.