public void Init()
{
const string createKsCql =
@"CREATE KEYSPACE Test WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1} and durable_writes = 'false';";
const string createTableCql = @"create table Test.BasicFlow (id int primary key, value text);";
const string truncateTableCql = @"truncate Test.BasicFlow;";
using (var connection = new CqlConnection(ConnectionString))
{
connection.Open();
try
{
var createKs = new CqlCommand(connection, createKsCql);
createKs.ExecuteNonQuery();
}
catch (AlreadyExistsException)
{
//ignore
}
try
{
var createTable = new CqlCommand(connection, createTableCql);
createTable.ExecuteNonQuery();
}
catch (AlreadyExistsException)
{
var truncTable = new CqlCommand(connection, truncateTableCql);
truncTable.ExecuteNonQuery();
}
}
}