public static void initDatabase(boolean dropDb,String replicationString,Session session){
  if (replicationString.startsWith("{") && replicationString.endsWith("}") && replicationString.contains("Strategy")&& replicationString.contains("'class'")) {
    logger.info("Initing Docussandra Cassandra Database with replication factor: \"" + replicationString + "\".");
  }
 else {
    throw new IllegalArgumentException("Replication String: \"" + replicationString + "\" does not appear to be valid.");
  }
  if (dropDb) {
    logger.warn("WARNING: DROPPING EXISTING DOCUSSANDRA database! You have 5 seconds to kill this process before the data will be dropped.");
    try {
      Thread.sleep(5000);
    }
 catch (    InterruptedException e) {
    }
    executeWithLog(session,"drop keyspace if exists docussandra;");
  }
  executeWithLog(session,"create keyspace IF NOT EXISTS docussandra with replication = " + replicationString + ";");
  executeWithLog(session,"use docussandra;");
  executeWithLog(session,"create table IF NOT EXISTS sys_meta (\n" + "	id text,\n" + "	version text,\n"+ "	created_at timestamp,\n"+ "	updated_at timestamp,\n"+ "	primary key ((id), updated_at))\n"+ "with clustering order by (updated_at DESC);");
  executeWithLog(session,"create table IF NOT EXISTS sys_db (\n" + "	db_name text primary key,\n" + "	description text,\n"+ "	created_at timestamp,\n"+ "	updated_at timestamp\n"+ ");");
  executeWithLog(session,"create table IF NOT EXISTS sys_tbl (\n" + "	db_name text,\n" + "	tbl_name text,\n"+ "	description text,\n"+ "	created_at timestamp,\n"+ "	updated_at timestamp,\n"+ "	primary key ((db_name), tbl_name)\n"+ ");");
  executeWithLog(session,"create table IF NOT EXISTS sys_idx (\n" + "	db_name text,\n" + "	tbl_name text,\n"+ "	name text,\n"+ "	is_unique boolean,\n"+ "	fields list<text>,\n"+ "	fields_type list<text>,\n"+ "	only list<text>,\n"+ "     is_active boolean,\n"+ "	created_at timestamp,\n"+ "	updated_at timestamp,\n"+ "	primary key ((db_name), tbl_name, name)\n"+ ");");
  executeWithLog(session,"create table IF NOT EXISTS sys_idx_status (\n" + "     id uuid,\n" + "	db_name text,\n"+ "	tbl_name text,\n"+ "	index_name text,\n"+ "	records_completed bigint,\n"+ "	total_records bigint,\n"+ "	started_at timestamp,\n"+ "	updated_at timestamp,\n"+ "     errors list<text>,\n"+ "     fatal_error text,\n"+ "	primary key (id)\n"+ ");");
  executeWithLog(session,"create table IF NOT EXISTS sys_idx_not_done (\n" + "    id uuid primary key\n" + ");");
}

public static void initDatabase ( boolean dropDb , String replicationString , Session session ) { if ( replicationString . startsWith ( "{" ) && replicationString . endsWith ( "}" ) && replicationString . contains ( "Strategy" ) && replicationString . contains ( "'class'" ) ) { logger . info ( "Initing Docussandra Cassandra Database with replication factor: \"" + replicationString + "\"." ) ; } else { throw new IllegalArgumentException ( "Replication String: \"" + replicationString + "\" does not appear to be valid." ) ; } if ( dropDb ) { logger . warn ( "WARNING: DROPPING EXISTING DOCUSSANDRA database! You have 5 seconds to kill this process before the data will be dropped." ) ; try { Thread . sleep ( 5000 ) ; } catch ( InterruptedException e ) { } executeWithLog ( session , "drop keyspace if exists docussandra;" ) ; } executeWithLog ( session , "create keyspace IF NOT EXISTS docussandra with replication = " + replicationString + ";" ) ; executeWithLog ( session , "use docussandra;" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_meta (\n" + "	id text,\n" + "	version text,\n" + "	created_at timestamp,\n" + "	updated_at timestamp,\n" + "	primary key ((id), updated_at))\n" + "with clustering order by (updated_at DESC);" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_db (\n" + "	db_name text primary key,\n" + "	description text,\n" + "	created_at timestamp,\n" + "	updated_at timestamp\n" + ");" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_tbl (\n" + "	db_name text,\n" + "	tbl_name text,\n" + "	description text,\n" + "	created_at timestamp,\n" + "	updated_at timestamp,\n" + "	primary key ((db_name), tbl_name)\n" + ");" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_idx (\n" + "	db_name text,\n" + "	tbl_name text,\n" + "	name text,\n" + "	is_unique boolean,\n" + "	fields list<text>,\n" + "	fields_type list<text>,\n" + "	only list<text>,\n" + "     is_active boolean,\n" + "	created_at timestamp,\n" + "	updated_at timestamp,\n" + "	primary key ((db_name), tbl_name, name)\n" + ");" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_idx_status (\n" + "     id uuid,\n" + "	db_name text,\n" + "	tbl_name text,\n" + "	index_name text,\n" + "	records_completed bigint,\n" + "	total_records bigint,\n" + "	started_at timestamp,\n" + "	updated_at timestamp,\n" + "     errors list<text>,\n" + "     fatal_error text,\n" + "	primary key (id)\n" + ");" ) ; executeWithLog ( session , "create table IF NOT EXISTS sys_idx_not_done (\n" + "    id uuid primary key\n" + ");" ) ; }
creates the initial docussandra database .
