cassandra_migrations 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTU2OWUzZTUzYjcxMDk1NzMxNjMwZWI4ZjE2NzY0YjcxZjc1ODE0Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2IyMWVkNTc1YjdkMTNiZjZmMjE1YTBkZDdhNzA1ZGVlNTliZWMwYw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzQxOWNkN2IyZGVlMTgxZWIwMzI3MzYxOTQ0MGEyNDM3MGQyMWU2YWEwZGI0
|
10
|
+
ZjY3ZGIyMzY2NTc2ZGRjMjVmMzJmODkyODMxNzZhNmU3ZTQ0ZTIyYmJiMWQ0
|
11
|
+
NTI2OTFhOTljOWVmZjE1MmFjOTIyNzNiYWQ0Y2FlYzUzNjNhMjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Yzg3NzE4YTEzZmZiYzMyOTI3NzQ2NzEyMjAzYTdlODQwMGU0ZThiNWJhOGU1
|
14
|
+
NGU0ZGNhYjMwOWMwMjk0NTczODRiNWI1ZWNlMzllZWJhMzAxOGY2YzYwZjdh
|
15
|
+
MzBhZDAzNDgyNzhjNjBiZGM3NDU4NzM5MGYyNzBjMDk2ZDdhZGU=
|
@@ -16,6 +16,7 @@ module CassandraMigrations
|
|
16
16
|
def initialize()
|
17
17
|
@columns_name_type_hash = {}
|
18
18
|
@primary_keys = []
|
19
|
+
@partition_keys = []
|
19
20
|
end
|
20
21
|
|
21
22
|
def to_create_cql
|
@@ -29,8 +30,11 @@ module CassandraMigrations
|
|
29
30
|
raise Errors::MigrationDefinitionError, 'No columns defined for table.'
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
key_info = (@primary_keys - @partition_keys)
|
34
|
+
key_info = ["(#{@partition_keys.join(', ')})", *key_info] if @partition_keys.any?
|
35
|
+
|
36
|
+
if key_info.any?
|
37
|
+
cql << "PRIMARY KEY(#{key_info.join(', ')})"
|
34
38
|
else
|
35
39
|
raise Errors::MigrationDefinitionError, 'No primary key defined.'
|
36
40
|
end
|
@@ -152,7 +156,15 @@ module CassandraMigrations
|
|
152
156
|
|
153
157
|
@primary_keys = keys.flatten
|
154
158
|
end
|
155
|
-
|
159
|
+
|
160
|
+
def define_partition_keys(*keys)
|
161
|
+
if !@partition_keys.empty?
|
162
|
+
raise Errors::MigrationDefinitionError, 'Partition key defined twice for the same table.'
|
163
|
+
end
|
164
|
+
|
165
|
+
@partition_keys = keys.flatten
|
166
|
+
end
|
167
|
+
|
156
168
|
private
|
157
169
|
|
158
170
|
def column_type_for(ruby_type, options={})
|
@@ -19,6 +19,7 @@ module CassandraMigrations
|
|
19
19
|
def create_table(table_name, options = {})
|
20
20
|
table_definition = TableDefinition.new
|
21
21
|
table_definition.define_primary_keys(options[:primary_keys]) if options[:primary_keys]
|
22
|
+
table_definition.define_partition_keys(options[:partition_keys]) if options[:partition_keys]
|
22
23
|
|
23
24
|
yield table_definition if block_given?
|
24
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Gubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cql-rb
|