cassandra-loader

A version loader for CQL scripts

License

License

Categories

Categories

Cassandra Data Databases
GroupId

GroupId

io.paradoxical
ArtifactId

ArtifactId

cassandra.loader
Last Version

Last Version

1.6.1
Release Date

Release Date

Type

Type

jar
Description

Description

cassandra-loader
A version loader for CQL scripts
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

http://github.com/paradoxical-io/cassandra-loader

Download cassandra.loader

How to add to project

<!-- https://jarcasting.com/artifacts/io.paradoxical/cassandra.loader/ -->
<dependency>
    <groupId>io.paradoxical</groupId>
    <artifactId>cassandra.loader</artifactId>
    <version>1.6.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.paradoxical/cassandra.loader/
implementation 'io.paradoxical:cassandra.loader:1.6.1'
// https://jarcasting.com/artifacts/io.paradoxical/cassandra.loader/
implementation ("io.paradoxical:cassandra.loader:1.6.1")
'io.paradoxical:cassandra.loader:jar:1.6.1'
<dependency org="io.paradoxical" name="cassandra.loader" rev="1.6.1">
  <artifact name="cassandra.loader" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.paradoxical', module='cassandra.loader', version='1.6.1')
)
libraryDependencies += "io.paradoxical" % "cassandra.loader" % "1.6.1"
[io.paradoxical/cassandra.loader "1.6.1"]

Dependencies

compile (10)

Group / Artifact Type Version
com.datastax.cassandra : cassandra-driver-core jar 3.3.0
org.cassandraunit : cassandra-unit jar 3.1.3.2
commons-cli : commons-cli jar 1.3
ch.qos.logback : logback-classic jar 1.1.3
com.godaddy : logging jar 1.0
org.slf4j : slf4j-api jar 1.7.22
com.google.guava : guava jar 22.0
com.esotericsoftware : reflectasm jar 1.10.1
commons-io : commons-io jar 2.4
junit : junit jar 4.12

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.12

test (4)

Group / Artifact Type Version
uk.co.jemos.podam : podam jar 4.7.3.RELEASE
org.assertj : assertj-core jar 3.0.0
org.slf4j : slf4j-log4j12 jar 1.7.22
org.mockito : mockito-all jar 1.10.19

Project Modules

There are no modules declared in this project.

cassandra-loader

Build Status Maven Central

This is a simple cassandra migration runner. It will manage your cassandra keyspace versions by keeping track of a dbversion and letting you run versioned db scripts. Leverage this project to also run in memory cassandra migrations (if you have tests you want to run for your cassandra scripts).

Cql Scripts

Cassandra loader works by tracking your db version and applying lexically ordered cql scripts against the current db.

For example, if you have a folder like:

01_initial.cql
02_add_users.cql
03_add_tracking_column.cql

This corresponds to DB version 3. Cassandra loader will apply migrations only when needed, so if you already are at db version 3 nothing happens. If your db version table is at 2, then the 03 script is run.

When you first set up a keyspace with the loader, the loader will bootstrap a db_version table to track this for you. It tracks the history of when scripts were applied and which version its at now.

Installation

In process upgrades

<dependency>
    <groupId>io.paradoxical</groupId>
    <artifactId>cassandra.loader</artifactId>
    <version>1.3</version>
</dependency>

The loader allows you to create a cassandra session instance from a db folder of cql scripts. For example:

public static Session create() throws Exception {
    return CqlUnitDb.create("../db/scripts");
}

This will create a fresh DB based on your cql scripts. The db created with this function is cached because creating sessions isn't a lightweight process. To create a fresh db do the following

public static Session createFresh() throws Exception {
    return CqlUnitDb.unCached("../db/scripts");
}

Standalone running:

You can also run the loader as a standalone jar. This way you can use it as part of a CICD pipeline, instead of in integration tests.

To install:

<dependency>
    <groupId>io.paradoxical</groupId>
    <artifactId>cassandra.loader</artifactId>
    <version>1.3</version>
    <classifier>runner</classifier>
</dependency>

Or pull it directly from maven.

To use it:

> java -jar cassandra.loader-runner.jar

Unexpected exception:Missing required options: ip, u, pw, k
Usage: Main
 -createKeyspace              Creates the keyspace
 --debug                      Optional debug flag. Spits out all logs
 -f,--file-path <arg>         CQL File Path (default =
                              ../db/src/main/resources)
 -ip <arg>                    Cassandra IP Address
 -k,--keyspace <arg>          Cassandra Keyspace
 -p,--port <arg>              Cassandra Port (default = 9042)
 -pw,--password <arg>         Cassandra Password
 -recreateDatabase            Deletes all tables. WARNING all data will be
                              deleted!
 -u,--username <arg>          Cassandra Username
 -v,--upgrade-version <arg>   Upgrade to Version
io.paradoxical

Paradoxical Devs

Libraries and dockerized applications. Pull requests welcome!

Versions

Version
1.6.1
1.6
1.5
1.4
1.3
1.2
1.1
1.0