sandra-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,29 @@
1
1
  namespace :sandra do
2
2
  task :migrate => :environment do
3
- sandra_config = YAML::load_file("#{::Rails.root.to_s}/config/sandra.yml")[::Rails.env]
3
+ sandra_config = YAML::load_file("#{::Rails.root.to_s}/config/sandra.yml")[::Rails.env].symbolize_keys
4
4
  keyspace = sandra_config[:keyspace]
5
5
  store = Cassandra.new(keyspace)
6
6
  cfs = sandra_config[:column_families]
7
- cfs.each do |name, options|
8
- options = Hash(options)
7
+ current_cfs = {}
8
+ store.schema.cf_defs.each do |cfdef|
9
+ current_cfs[cfdef.name] = cfdef
10
+ end
11
+ updated_cfs = current_cfs.keys & cfs.keys
12
+ deleted_cfs = current_cfs.keys - cfs.keys
13
+ new_cfs = cfs.keys - current_cfs.keys
14
+ new_cfs.each do |name, options|
15
+ options = options.is_a?(Hash) ? options : {}
9
16
  cf_def = CassandraThrift::CfDef.new({:keyspace => keyspace, :name => name}.merge(options))
10
17
  store.add_column_family(cf_def)
18
+ end
19
+ # TODO: Update existing column families
20
+ #updated_cfs.each do |name, options|
21
+ #options = options.is_a?(Hash) ? options : {}
22
+ #cf_def = update_cf(current_cfs[name], options)
11
23
  store.update_column_family(cf_def)
24
+ #end
25
+ deleted_cfs.each do |name|
26
+ store.drop_column_family(name)
12
27
  end
13
28
  end
14
29
  end
@@ -1,5 +1,5 @@
1
1
  module Sandra
2
2
  module Rails
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
data/sandra-rails.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  s.add_runtime_dependency "sandra"
23
- s.add_runtime_dependency "actionpack", ["~> 3.2.0"]
24
- s.add_runtime_dependency "railties", ["~> 3.2.0"]
23
+ s.add_runtime_dependency "actionpack", ["~> 3.1.0"]
24
+ s.add_runtime_dependency "railties", ["~> 3.1.0"]
25
25
  # s.add_runtime_dependency "rest-client"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandra-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-05 00:00:00.000000000Z
12
+ date: 2012-03-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sandra
16
- requirement: &70324487139080 !ruby/object:Gem::Requirement
16
+ requirement: &70208568698540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,29 +21,29 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70324487139080
24
+ version_requirements: *70208568698540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &70324487138540 !ruby/object:Gem::Requirement
27
+ requirement: &70208568697860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 3.2.0
32
+ version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70324487138540
35
+ version_requirements: *70208568697860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: railties
38
- requirement: &70324487137980 !ruby/object:Gem::Requirement
38
+ requirement: &70208568697200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 3.2.0
43
+ version: 3.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70324487137980
46
+ version_requirements: *70208568697200
47
47
  description: Connect Sandra with Rails
48
48
  email:
49
49
  - chuck@teachmetocode.com