cassandra_migrations 0.2.5 → 0.2.6
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c965a29df3ab284126e40f87b121b36ac7265bd8
|
4
|
+
data.tar.gz: 1f51f693edccafb89757145d09d110e1e80906f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46a1436db58fb04065c16cefb5438131b45fe64f129ced77eaeade85844b301f8855d8aabd51acfae5c0b6f388065a8a79ef66a4e5473f4c2a80f23ac0256959
|
7
|
+
data.tar.gz: 86926b224d24685da9b83ab312754446135f346618e5489d91bf4e3fc63f25f00c6806f1be4043f26b1198bf5b345ed63e3dbfe8114fac8b3a5f69c691775b68
|
@@ -7,23 +7,26 @@ module CassandraMigrations
|
|
7
7
|
|
8
8
|
def create_keyspace!(env)
|
9
9
|
config = Config.configurations[env]
|
10
|
-
|
11
|
-
|
12
|
-
execute(
|
13
|
-
"CREATE KEYSPACE #{config.keyspace} \
|
14
|
-
WITH replication = { \
|
15
|
-
'class':'#{config.replication['class']}', \
|
16
|
-
'replication_factor': #{config.replication['replication_factor']} \
|
17
|
-
}"
|
18
|
-
)
|
10
|
+
execute(create_keyspace_statement(config))
|
19
11
|
begin
|
20
12
|
use(config.keyspace)
|
21
|
-
rescue
|
13
|
+
rescue StandardError => exception
|
22
14
|
drop_keyspace!(env)
|
23
15
|
raise exception
|
24
16
|
end
|
25
17
|
end
|
26
18
|
|
19
|
+
def create_keyspace_statement(config)
|
20
|
+
validate_config(config)
|
21
|
+
<<-CQL.strip_heredoc
|
22
|
+
CREATE KEYSPACE #{config.keyspace}
|
23
|
+
WITH replication = {
|
24
|
+
'class': '#{config.replication['class']}',
|
25
|
+
#{replication_options_statement(config)}
|
26
|
+
}
|
27
|
+
CQL
|
28
|
+
end
|
29
|
+
|
27
30
|
def drop_keyspace!(env)
|
28
31
|
config = Config.configurations[env]
|
29
32
|
begin
|
@@ -37,19 +40,30 @@ module CassandraMigrations
|
|
37
40
|
|
38
41
|
def validate_config(config)
|
39
42
|
if config.keyspace.nil?
|
40
|
-
raise Errors::MissingConfigurationError.new("Configuration of 'keyspace' is required in config.yml, but none is defined.")
|
41
|
-
|
42
|
-
|
43
|
-
raise Errors::MissingConfigurationError.new("Configuration for 'replication' is required in config.yml, but none is defined.")
|
43
|
+
raise Errors::MissingConfigurationError.new("Configuration of 'keyspace' is required in config/cassandra.yml, but none is defined.")
|
44
|
+
elsif config_requires_replication?(config) && !config_includes_replication?(config)
|
45
|
+
raise Errors::MissingConfigurationError.new("Configuration for 'replication' is required in config/cassandra.yml, but none is defined.")
|
44
46
|
end
|
45
47
|
true
|
46
48
|
end
|
47
49
|
|
50
|
+
def config_requires_replication?(config)
|
51
|
+
config.replication['class'] == 'SimpleStrategy'
|
52
|
+
end
|
53
|
+
|
48
54
|
def config_includes_replication?(config)
|
49
55
|
config.replication &&
|
50
56
|
config.replication['class'] &&
|
51
57
|
config.replication['replication_factor']
|
52
58
|
end
|
59
|
+
|
60
|
+
def replication_options_statement(config)
|
61
|
+
if config.replication['class'] == "SimpleStrategy"
|
62
|
+
"'replication_factor': #{config.replication['replication_factor']}"
|
63
|
+
elsif config.replication['class'] == "NetworkTopologyStrategy"
|
64
|
+
config.replication.reject{ |k,v| k == 'class' }.map { |k,v| "'#{k}': #{v}" }.join(", ")
|
65
|
+
end
|
66
|
+
end
|
53
67
|
end
|
54
68
|
end
|
55
69
|
end
|
data/lib/cassandra_migrations.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Gubert
|
@@ -9,13 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cassandra-driver
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '2.1'
|
21
|
+
- - ">="
|
19
22
|
- !ruby/object:Gem::Version
|
20
23
|
version: 2.1.1
|
21
24
|
type: :runtime
|
@@ -23,6 +26,9 @@ dependencies:
|
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '2.1'
|
31
|
+
- - ">="
|
26
32
|
- !ruby/object:Gem::Version
|
27
33
|
version: 2.1.1
|
28
34
|
- !ruby/object:Gem::Dependency
|
@@ -43,14 +49,14 @@ dependencies:
|
|
43
49
|
name: rails
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
|
-
- - "
|
52
|
+
- - "~>"
|
47
53
|
- !ruby/object:Gem::Version
|
48
54
|
version: '3.2'
|
49
55
|
type: :runtime
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
|
-
- - "
|
59
|
+
- - "~>"
|
54
60
|
- !ruby/object:Gem::Version
|
55
61
|
version: '3.2'
|
56
62
|
- !ruby/object:Gem::Dependency
|
@@ -72,6 +78,9 @@ dependencies:
|
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
73
79
|
requirements:
|
74
80
|
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.1'
|
83
|
+
- - ">="
|
75
84
|
- !ruby/object:Gem::Version
|
76
85
|
version: 3.1.0
|
77
86
|
type: :development
|
@@ -79,6 +88,9 @@ dependencies:
|
|
79
88
|
version_requirements: !ruby/object:Gem::Requirement
|
80
89
|
requirements:
|
81
90
|
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '3.1'
|
93
|
+
- - ">="
|
82
94
|
- !ruby/object:Gem::Version
|
83
95
|
version: 3.1.0
|
84
96
|
- !ruby/object:Gem::Dependency
|
@@ -137,6 +149,20 @@ dependencies:
|
|
137
149
|
- - "~>"
|
138
150
|
- !ruby/object:Gem::Version
|
139
151
|
version: '0.7'
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: appraisal
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '1.0'
|
159
|
+
type: :development
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1.0'
|
140
166
|
description: A gem to manage Cassandra database schema for Rails. This gem offers
|
141
167
|
migrations and environment specific databases out-of-the-box for Rails users.
|
142
168
|
email:
|
@@ -169,6 +195,7 @@ files:
|
|
169
195
|
- lib/cassandra_migrations/railtie/generators/cassandra_migration/templates/empty_migration.rb.erb
|
170
196
|
- lib/cassandra_migrations/railtie/initializer.rb
|
171
197
|
- lib/cassandra_migrations/railtie/tasks.rake
|
198
|
+
- lib/cassandra_migrations/version.rb
|
172
199
|
homepage: https://github.com/hsgubert/cassandra_migrations
|
173
200
|
licenses:
|
174
201
|
- MIT
|