Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Script Types

Herdy Handoko edited this page Apr 3, 2017 · 1 revision

Supported Migration Script Types

Two main migrations script types are supported: CQL and Java classes. One or a combination of both can be used, with the limitation that no version numbers conflict exists, e.g. having a CQL script and Java class that resolves to both version 2 will throw an exception.

.cql files

Example:

CREATE TABLE test1 (
  space text,
  key text,
  value text,
  PRIMARY KEY (space, key)
) with CLUSTERING ORDER BY (key ASC);

INSERT INTO test1 (space, key, value) VALUES ('foo', 'blah', 'meh');

UPDATE test1 SET value = 'profit!' WHERE space = 'foo' AND key = 'blah';

Java classes

Example:

public class V3_0__Third implements JavaMigration {

    @Override
    public void migrate(Session session) throws Exception {
        Insert insert = QueryBuilder.insertInto("test1");
        insert.value("space", "web");
        insert.value("key", "google");
        insert.value("value", "google.com");

        session.execute(insert);
    }
}