public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); db.ExecuteNonQuery(@" CREATE TABLE users ( id int , name ascii, email ascii, age int, PRIMARY KEY(id, email) );"); ResetUsersFamily(db); } }
public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); keyspace.TryCreateColumnFamily <AsciiType>("Standard"); keyspace.TryCreateColumnFamily <AsciiType, AsciiType>("Super"); keyspace.TryCreateColumnFamily <AsciiType>("StandardAsciiType"); keyspace.TryCreateColumnFamily <BytesType>("StandardBytesType"); keyspace.TryCreateColumnFamily <IntegerType>("StandardIntegerType"); keyspace.TryCreateColumnFamily <LexicalUUIDType>("StandardLexicalUUIDType"); keyspace.TryCreateColumnFamily <LongType>("StandardLongType"); keyspace.TryCreateColumnFamily <TimeUUIDType>("StandardTimeUUIDType"); keyspace.TryCreateColumnFamily <UTF8Type>("StandardUTF8Type"); keyspace.TryCreateColumnFamily <UUIDType>("StandardUUIDType"); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardCompositeType", ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType }) }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDynamicCompositeType", ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary <char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } }) }); db.ExecuteNonQuery(string.Format(@" CREATE TABLE {0} ( id int , name ascii, email ascii, age int, PRIMARY KEY(id) );", toLowerIf(toLower, "Users"))); //db.ExecuteNonQuery(@"CREATE INDEX User_Age ON users (Age);"); db.Keyspace.ClearCachedKeyspaceSchema(); var family = db.GetColumnFamily <AsciiType>("Standard"); var superFamily = db.GetColumnFamily <AsciiType, AsciiType>("Super"); var userFamily = db.GetColumnFamily(toLowerIf(toLower, "Users")); ResetFamily(family); ResetSuperFamily(superFamily); ResetUsersFamily(userFamily); } }
public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); } }
public void ResetDatabase() { using (var session = new CassandraSession(ConnectionBuilder)) using (var db = new CassandraContext(session)) { db.ThrowErrors = true; db.TryDropKeyspace(Keyspace); var keyspace = new CassandraKeyspace(new CassandraKeyspaceSchema { Name = Keyspace }, db); db.Keyspace = keyspace; keyspace.TryCreateSelf(); keyspace.TryCreateColumnFamily <AsciiType>("Standard"); keyspace.TryCreateColumnFamily <AsciiType, AsciiType>("Super"); keyspace.TryCreateColumnFamily <AsciiType>("StandardAsciiType"); keyspace.TryCreateColumnFamily <BytesType>("StandardBytesType"); keyspace.TryCreateColumnFamily <IntegerType>("StandardIntegerType"); keyspace.TryCreateColumnFamily <LexicalUUIDType>("StandardLexicalUUIDType"); keyspace.TryCreateColumnFamily <LongType>("StandardLongType"); keyspace.TryCreateColumnFamily <TimeUUIDType>("StandardTimeUUIDType"); keyspace.TryCreateColumnFamily <UTF8Type>("StandardUTF8Type"); keyspace.TryCreateColumnFamily <UUIDType>("StandardUUIDType"); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema() { FamilyName = "Counters", ColumnNameType = CassandraType.AsciiType, DefaultColumnValueType = CassandraType.CounterColumnType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDecimalType", ColumnNameType = CassandraType.DecimalType }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardCompositeType", ColumnNameType = CassandraType.CompositeType(new[] { CassandraType.AsciiType, CassandraType.DoubleType }) }); keyspace.TryCreateColumnFamily(new CassandraColumnFamilySchema { FamilyName = "StandardDynamicCompositeType", ColumnNameType = CassandraType.DynamicCompositeType(new Dictionary <char, CassandraType> { { 'a', CassandraType.AsciiType }, { 'd', CassandraType.DoubleType } }) }); db.ExecuteNonQuery(@" CREATE COLUMNFAMILY Users ( Id int PRIMARY KEY, Name ascii, Email ascii, Age int );", CqlVersion.Cql); db.ExecuteNonQuery(@"CREATE INDEX User_Age ON Users (Age);", CqlVersion.Cql); db.Keyspace.ClearCachedKeyspaceSchema(); var family = db.GetColumnFamily <AsciiType>("Standard"); var superFamily = db.GetColumnFamily <AsciiType, AsciiType>("Super"); var userFamily = db.GetColumnFamily("Users"); var counterFamily = db.GetColumnFamily("Counters"); ResetFamily(family); ResetSuperFamily(superFamily); ResetUsersFamily(userFamily); ResetCounterColumnFamily(counterFamily); } }