gotime-cassandra_object 4.4.4 → 4.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/schema.rb +12 -3
- data/lib/cassandra_object/tasks/ks.rake +18 -2
- data/test/support/connect.rb +1 -2
- data/test/support/teardown.rb +1 -5
- data/test/unit/schema_test.rb +13 -0
- metadata +3 -2
@@ -15,9 +15,18 @@ module CassandraObject
|
|
15
15
|
system_execute "DROP KEYSPACE #{keyspace}"
|
16
16
|
end
|
17
17
|
|
18
|
-
def create_column_family(column_family)
|
19
|
-
|
20
|
-
|
18
|
+
def create_column_family(column_family, options = {})
|
19
|
+
stmt = "CREATE COLUMNFAMILY #{column_family} " +
|
20
|
+
"(KEY varchar PRIMARY KEY)"
|
21
|
+
|
22
|
+
if options.any?
|
23
|
+
with_stmt = options.map do |k,v|
|
24
|
+
"#{k} = #{CassandraCQL::Statement.quote(v)}"
|
25
|
+
end.join(' AND ')
|
26
|
+
stmt << " WITH #{with_stmt}"
|
27
|
+
end
|
28
|
+
|
29
|
+
execute stmt
|
21
30
|
end
|
22
31
|
|
23
32
|
def alter_column_family_with(with)
|
@@ -1,11 +1,27 @@
|
|
1
1
|
ks_namespace = namespace :ks do
|
2
2
|
desc 'Create the keyspace in cassandra_config/cassandra.yml for the current environment'
|
3
3
|
task create: :environment do
|
4
|
-
|
4
|
+
begin
|
5
|
+
CassandraObject::Schema.create_keyspace cassandra_config['keyspace']
|
6
|
+
rescue Exception => e
|
7
|
+
if e.message =~ /conflicts/
|
8
|
+
p "Keyspace #{cassandra_config['keyspace']} already exists"
|
9
|
+
else
|
10
|
+
raise e
|
11
|
+
end
|
12
|
+
end
|
5
13
|
end
|
6
14
|
|
7
15
|
task drop: :environment do
|
8
|
-
|
16
|
+
begin
|
17
|
+
CassandraObject::Schema.drop_keyspace cassandra_config['keyspace']
|
18
|
+
rescue Exception => e
|
19
|
+
if e.message =~ /non existing keyspace/
|
20
|
+
p "Keyspace #{cassandra_config['keyspace']} does not exist"
|
21
|
+
else
|
22
|
+
raise e
|
23
|
+
end
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
11
27
|
task reset: [:drop, :setup]
|
data/test/support/connect.rb
CHANGED
data/test/support/teardown.rb
CHANGED
@@ -8,11 +8,7 @@ CassandraObject::Base.class_eval do
|
|
8
8
|
|
9
9
|
def self.delete_after_test
|
10
10
|
# created_records.reject(&:destroyed?).each(&:destroy)
|
11
|
-
|
12
|
-
begin
|
13
|
-
cql.execute "TRUNCATE Issues"
|
14
|
-
rescue
|
15
|
-
end
|
11
|
+
Issue.delete_all
|
16
12
|
created_records.clear
|
17
13
|
end
|
18
14
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CassandraObject::SchemaTest < CassandraObject::TestCase
|
4
|
+
test "create_column_family" do
|
5
|
+
CassandraObject::Schema.create_column_family 'TestRecords', 'compression_parameters:sstable_compression' => 'SnappyCompressor'
|
6
|
+
|
7
|
+
begin
|
8
|
+
CassandraObject::Schema.create_column_family 'TestRecords'
|
9
|
+
assert false, 'TestRecords should already exist'
|
10
|
+
rescue Exception => e
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- test/unit/persistence_test.rb
|
157
157
|
- test/unit/savepoints_test.rb
|
158
158
|
- test/unit/schema/tasks_test.rb
|
159
|
+
- test/unit/schema_test.rb
|
159
160
|
- test/unit/scope/batches_test.rb
|
160
161
|
- test/unit/scope/finder_methods_test.rb
|
161
162
|
- test/unit/scope/query_methods_test.rb
|