Class: CassandraObject::Schema
- Inherits:
-
Object
- Object
- CassandraObject::Schema
show all
- Extended by:
- Tasks
- Defined in:
- lib/cassandra_object/schema.rb,
lib/cassandra_object/schema/tasks.rb
Defined Under Namespace
Modules: Tasks
Constant Summary
collapse
- DEFAULT_CREATE_KEYSPACE =
{
'strategy_class' => 'SimpleStrategy',
'strategy_options:replication_factor' => 1
}
Class Method Summary
collapse
Methods included from Tasks
column_families, dump, load
Class Method Details
.add_index(column_family, column, index_name = nil) ⇒ Object
44
45
46
47
|
# File 'lib/cassandra_object/schema.rb', line 44
def add_index(column_family, column, index_name = nil)
stmt = "CREATE INDEX #{index_name.nil? ? '' : index_name} ON #{column_family} (#{column})"
execute stmt
end
|
.alter_column_family(column_family, instruction, options = {}) ⇒ Object
34
35
36
37
|
# File 'lib/cassandra_object/schema.rb', line 34
def alter_column_family(column_family, instruction, options = {})
stmt = "ALTER TABLE #{column_family} #{instruction}"
execute statement_with_options(stmt, options)
end
|
.create_column_family(column_family, options = {}) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/cassandra_object/schema.rb', line 27
def create_column_family(column_family, options = {})
stmt = "CREATE COLUMNFAMILY #{column_family} " +
"(KEY varchar PRIMARY KEY)"
execute statement_with_options(stmt, options)
end
|
.create_keyspace(keyspace, options = {}) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/cassandra_object/schema.rb', line 13
def create_keyspace(keyspace, options = {})
stmt = "CREATE KEYSPACE #{keyspace}"
if options.empty?
options = DEFAULT_CREATE_KEYSPACE
end
system_execute statement_with_options(stmt, options)
end
|
.drop_column_family(column_family) ⇒ Object
39
40
41
42
|
# File 'lib/cassandra_object/schema.rb', line 39
def drop_column_family(column_family)
stmt = "DROP TABLE #{column_family}"
execute stmt
end
|
.drop_index(index_name) ⇒ Object
49
50
51
52
53
|
# File 'lib/cassandra_object/schema.rb', line 49
def drop_index(index_name)
stmt = "DROP INDEX #{index_name}"
execute stmt
end
|
.drop_keyspace(keyspace) ⇒ Object
23
24
25
|
# File 'lib/cassandra_object/schema.rb', line 23
def drop_keyspace(keyspace)
system_execute "DROP KEYSPACE #{keyspace}"
end
|