Cassandra migration tool for java is a lightweight tool used to execute schema and data migration on Cassandra database. Schema versioning state is saved in
schema_version table which stores name and description of migration along with type and timestamp.
There are two types of migrations:
We are going to follow the official DataStax Java driver versions and build our driver for each major, minor and patch version of the driver. We chose this path because of the simplicity to develop, test and deploy for different versions of the driver. This means that if you are using the driver version 2.1.9 you can add this dependency to your project:
<dependency> <groupId>io.smartcat</groupId> <artifactId>cassandra-migration-tool</artifactId> <version>22.214.171.124</version> </dependency>
or whatever the latest build version of the migration tool is. Check the version at the Maven repository.
We have two test cases which explain common problems which migration tool can solve. This is only subset of use cases but we think these are most frequent once:
First use case touches problem of adding new field and populating historic data with value. Cassandra does not have DDL
default attribute, so you must populate data on application level. MigrationEngineBooksTest can serve as an example of that use case which this tool can cover.
The initial table is simple (can be found in books.cql file) and we use migration classes to do the following:
genrecolumn with second
Second use case touches problem of query based modeling. Cassandra has good performance because you model your data as you will query it. Often after initial modeling you have request to read it based on different criteria. In Cassandra you do this with another table which is optimized for new requirements. You need to populate this new table with existing data and you can solve this with migration tool. MigrationEngineItemsTest can serve as an example of that use case which this tool can cover.
The initial table is simple (can be found in items.cql file) and we use migration classes to do the following:
items_by_number_external_idtable with second
When executing schema migrations it is necessary to wait for cluster to propagate schema on all nodes. Schema agreement is implemented based on this fix and is exposed through Migration abstract class.
To execute a statement with schema agreement you can use
© 2020 Anant Corporation, All Rights Reserved. All logos, trademarks and registered trademarks are the property of their respective owners. .