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

API Migration

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

API Migration

cassandra-migration can be used within an existing application by invoking its API methods.

Configuration can be set explicitly via the API methods, or defaults set by passing in system properties JVM arguments or by using a centralised configuration file (within the application). Refer to the Configuration / Options page for more information.

Example:

String[] scriptsLocations = {"migration/cassandra"};

KeyspaceConfiguration keyspaceConfig = new KeyspaceConfiguration();
keyspaceConfig.setName(CASSANDRA_KEYSPACE);
keyspaceConfig.setConsistency(ConsistencyLevel.QUORUM);
keyspaceConfig.getClusterConfig().setContactpoints(CASSANDRA_CONTACT_POINT);
keyspaceConfig.getClusterConfig().setPort(CASSANDRA_PORT);
keyspaceConfig.getClusterConfig().setUsername(CASSANDRA_USERNAME);
keyspaceConfig.getClusterConfig().setPassword(CASSANDRA_PASSWORD);

CassandraMigration cm = new CassandraMigration();
cm.setLocations(scriptsLocations);
cm.setKeyspaceConfig(keyspaceConfig);
cm.setTablePrefix("my_app_");
cm.migrate();