cassandra_migrations 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,8 +61,7 @@ module CassandraMigrations
|
|
61
61
|
Rails.logger.try(:info, "Connecting to Cassandra on #{Config.host}:#{Config.port}")
|
62
62
|
|
63
63
|
begin
|
64
|
-
self.client = Cql::Client.
|
65
|
-
client.connect
|
64
|
+
self.client = Cql::Client.connect(:host => Config.host, :port => Config.port)
|
66
65
|
rescue Cql::Io::ConnectionError => e
|
67
66
|
raise Errors::ConnectionError, e.message
|
68
67
|
end
|
@@ -46,7 +46,7 @@ module CassandraMigrations
|
|
46
46
|
elsif @columns_name_type_hash.empty?
|
47
47
|
raise Errors::MigrationDefinitionError('No column to add.')
|
48
48
|
else
|
49
|
-
raise Errors::MigrationDefinitionError('Only one column
|
49
|
+
raise Errors::MigrationDefinitionError('Only one column can be added at once.')
|
50
50
|
end
|
51
51
|
|
52
52
|
cql
|
@@ -99,6 +99,16 @@ module CassandraMigrations
|
|
99
99
|
define_primary_keys(column_name) if options[:primary_key]
|
100
100
|
end
|
101
101
|
|
102
|
+
def uuid(column_name, options={})
|
103
|
+
@columns_name_type_hash[column_name.to_sym] = :uuid
|
104
|
+
define_primary_keys(column_name) if options[:primary_key]
|
105
|
+
end
|
106
|
+
|
107
|
+
def timeuuid(column_name, options={})
|
108
|
+
@columns_name_type_hash[column_name.to_sym] = :timeuuid
|
109
|
+
define_primary_keys(column_name) if options[:primary_key]
|
110
|
+
end
|
111
|
+
|
102
112
|
def define_primary_keys(*keys)
|
103
113
|
if !@primary_keys.empty?
|
104
114
|
raise Errors::MigrationDefinitionError('Primary key defined twice for the same table.')
|
@@ -9,24 +9,21 @@ describe CassandraMigrations::Cassandra do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
12
|
-
CassandraMigrations::Cassandra.
|
12
|
+
CassandraMigrations::Cassandra.client = nil
|
13
13
|
CassandraMigrations::Config.config = nil
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '.execute' do
|
17
17
|
it 'should connect to cassandra using host and port configured' do
|
18
|
-
cql_client_mock =
|
19
|
-
Cql::Client.should_receive(:
|
20
|
-
cql_client_mock.should_receive(:connect)
|
18
|
+
cql_client_mock = mock('cql_client')
|
19
|
+
Cql::Client.should_receive(:connect).with(:host => '127.0.0.1', :port => 9042).and_return(cql_client_mock)
|
21
20
|
cql_client_mock.should_receive(:execute).with('anything').and_return(nil)
|
22
21
|
|
23
22
|
CassandraMigrations::Cassandra.execute('anything').should be_nil
|
24
23
|
end
|
25
24
|
|
26
25
|
it 'raise exception if there is something wrong with the connection' do
|
27
|
-
|
28
|
-
Cql::Client.should_receive(:new).and_return(cql_client_mock)
|
29
|
-
cql_client_mock.should_receive(:connect).and_raise(Cql::Io::ConnectionError)
|
26
|
+
Cql::Client.should_receive(:connect).and_raise(Cql::Io::ConnectionError)
|
30
27
|
|
31
28
|
expect {
|
32
29
|
CassandraMigrations::Cassandra.execute('anything')
|
@@ -34,7 +31,7 @@ describe CassandraMigrations::Cassandra do
|
|
34
31
|
end
|
35
32
|
|
36
33
|
it 'should return a QueryResult if the query returns something' do
|
37
|
-
CassandraMigrations::Cassandra.client =
|
34
|
+
CassandraMigrations::Cassandra.client = mock('cql_client')
|
38
35
|
|
39
36
|
result_mock = mock('result_mock')
|
40
37
|
CassandraMigrations::Cassandra.client.should_receive(:execute).with('anything').and_return(result_mock)
|
@@ -47,9 +44,8 @@ describe CassandraMigrations::Cassandra do
|
|
47
44
|
|
48
45
|
describe '.use' do
|
49
46
|
it 'should connect to cassandra using host and port configured' do
|
50
|
-
cql_client_mock =
|
51
|
-
Cql::Client.should_receive(:
|
52
|
-
cql_client_mock.should_receive(:connect)
|
47
|
+
cql_client_mock = mock('cql_client')
|
48
|
+
Cql::Client.should_receive(:connect).with(:host => '127.0.0.1', :port => 9042).and_return(cql_client_mock)
|
53
49
|
cql_client_mock.should_receive(:use).with('anything').and_return(nil)
|
54
50
|
|
55
51
|
CassandraMigrations::Cassandra.use('anything').should be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassandra_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cql-rb
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0.
|
21
|
+
version: 1.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.0.
|
29
|
+
version: 1.0.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|