Cassandra Scheme Update

In the world of RDBMS when we have a database with a scheme we have the issue of how to manage changes in the scheme. When updating our product, we also need the option to update our database scheme. For this we have tools like liquibase and flyway.

NonSql databases that have no scheme like mongdb do not need this functionality. But when you come to some NonSql Databases like Cassandra this functionality is missing.

Cassandra is a NonSql database, but it does have a scheme for each table.

So what are the very basic things that you need for managing your database scheme.

  • Obviously the most basic functionality is the option to register a script to run and update your database upon installation.

  • In addition you can and should write the script in a way that if it is run more than once that it will not harm your DB. This is not always feasible so we do need a way not to run a script if it has already run.

  • Another nice feature is that if you have changed a script that has run in the past (and therefor not rerun), the tool will give a warning.

  • Meta data for script is also essential to understand what happened - who is the developer that wrote the script, when it was run.

For more information about scheme migration see: schema-migrations-in-cassandra.

Liquibase has been looking into this (see liquibase cassandra), but the project does not seem to be going anywhere soon.

There are some projects out there, some are very complication and some are outdated. To see them, have a look at:

To close this gap, I have written a very simple application. This application covers the basic items written about. You can find the application and source at https://github.com/chaimt/CassandraScheme.

Usage is as simple as:

java -jar cassandra-scheme.jar --cassandra.keyspace=myspace --scheme.dir=/mydir

You can configure the default table for the metadata:

cassandra.version.table = scheme_version