cassandra_migrations 0.2.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a28e40a6fe9323547d4484bdfb6ace0bf2dee21c
4
- data.tar.gz: 7a2215ba07262a12038b7bf5cd7c6ac4582db4a9
3
+ metadata.gz: e8d4e59fbc000e68b5c8b7c386bec4a5915416f1
4
+ data.tar.gz: c7880ee677624568e49d0ae9ee32f27c8e87b311
5
5
  SHA512:
6
- metadata.gz: 2d795b210e5eefd853eb25ba8b3d8bfce1955aa1645e751e6a98cc995cdc96b6f7be46367ddec6263ed29fb2a94bb55634adf68ffcb49b643bddbad8e2a4ed3e
7
- data.tar.gz: e602f7cec7715b2d7bc16bdd5390cb1b75fa269d09bd038b0f0ff562a7bb71898e8ab1d273df4cbdc6e56fcf8591dc5436ceb1a4679d33f2104806c7d1254c63
6
+ metadata.gz: 2c842bbb256c3386f1756323905495f5697e2a0d0ca1116b0e8543e42e1809647968056080ad057cfb4e6347742282afcfaa26c9c4b3650d846d649b51a527c0
7
+ data.tar.gz: 57392a61ed5ca9003a9c7f84389e4dba9462cff8ef7cd02632f66a8af3fca47083358d09e506e41293f7ba4e5b20539b7d183540e013ff00af341f92c8fbfd0b
@@ -106,28 +106,9 @@ module CassandraMigrations
106
106
 
107
107
  private
108
108
 
109
- SYMBOL_FOR_TYPE = {
110
- 'SetType' => :set,
111
- 'ListType' => :list,
112
- 'MapType' => :map,
113
- 'BooleanType' => :boolean,
114
- 'FloatType' => :float,
115
- 'Int32Type' => :int,
116
- 'DateType' => :timestamp,
117
- 'UTF8Type' => :string,
118
- 'BytesType' => :blob,
119
- 'UUIDType' => :uuid,
120
- 'DoubleType' => :double,
121
- 'InetAddressType' => :inet,
122
- 'AsciiType' => :ascii,
123
- 'LongType' => :bigint ,
124
- 'DecimalType' => :decimal,
125
- 'TimeUUIDType' => :timeuuid
126
- }
127
-
128
109
  def get_column_type(table, column)
129
- column_info = client.execute("SELECT VALIDATOR FROM system.schema_columns WHERE keyspace_name = '#{client.keyspace}' AND columnfamily_name = '#{table}' AND column_name = '#{column}'")
130
- SYMBOL_FOR_TYPE[(column_info.first['validator'].split(/[\.(]/) & SYMBOL_FOR_TYPE.keys).first]
110
+ column_type = client.execute("SELECT type FROM system_schema.columns WHERE keyspace_name = '#{client.keyspace}' AND table_name = '#{table}' AND column_name = '#{column}'").first['type']
111
+ column_type.split("<").first.to_sym
131
112
  end
132
113
 
133
114
  def to_cql_value(column, value, table, options={})
@@ -35,6 +35,22 @@ module CassandraMigrations
35
35
 
36
36
  execute create_cql
37
37
  end
38
+
39
+ def alter_table(table_name, options={})
40
+ table_definition = TableDefinition.new
41
+ table_definition.define_options(options[:options]) if options[:options]
42
+
43
+ yield table_definition if block_given?
44
+
45
+ announce_operation "alter_table #{table_name}"
46
+
47
+ create_cql = "ALTER TABLE #{table_name}"
48
+ create_cql << table_definition.options
49
+
50
+ announce_suboperation create_cql
51
+
52
+ execute create_cql
53
+ end
38
54
 
39
55
  def create_index(table_name, column_name, options = {})
40
56
  announce_operation "create_index(#{table_name})"
@@ -1,3 +1,3 @@
1
1
  module CassandraMigrations
2
- VERSION = '0.2.7'
2
+ VERSION = '1.0.0'
3
3
  end
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.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique Gubert
@@ -18,9 +18,6 @@ dependencies:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '3.0'
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.1.1
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,9 +25,6 @@ dependencies:
28
25
  - - "~>"
29
26
  - !ruby/object:Gem::Version
30
27
  version: '3.0'
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.1.1
34
28
  - !ruby/object:Gem::Dependency
35
29
  name: rake
36
30
  requirement: !ruby/object:Gem::Requirement
@@ -216,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
210
  version: 1.8.0
217
211
  requirements: []
218
212
  rubyforge_project:
219
- rubygems_version: 2.4.8
213
+ rubygems_version: 2.6.8
220
214
  signing_key:
221
215
  specification_version: 4
222
216
  summary: Cassandra schema management for a multi-environment developer.