jets 1.4.9 → 1.4.10

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
  SHA256:
3
- metadata.gz: 55f7e0617aa3aa49745617e3735c5b40128b7841375fd69f0d7fecee71881ae8
4
- data.tar.gz: 607038061932882b1f01284923dab863d33c71b5b6663aabcde5580382449148
3
+ metadata.gz: 0732e4d712b717146a73dd2422817525ed0a45d1aa6b1a91f0230688a7a66412
4
+ data.tar.gz: e1ea0a9ede83b5efee168cf85dcb0edfc3ca364a4937cfad0e9ba6fb0dfe8c2a
5
5
  SHA512:
6
- metadata.gz: ba6369902500a57919efa3b4545205b8fde1f055da176299df779d8026ac474f954c56d69e5b417ed04ea5fd0967ca556afc0918e3ec8e412cdcf8bd0c7e8872
7
- data.tar.gz: b59ee42c12ffd6bc68b5026fd13b608ba298152529cfd43bd14a74b253d4cf9403f29ebe5b9c3832d4a8d57dbce90b34583bf696198b48e0427874b3876a01d5
6
+ metadata.gz: 9faf4666841f6c94bbc5c18e718768e289d0b068a5ff75f85fe8c60faf7664970467a6a0c5721468f2244d90b84a6babd381c496a31009d424ead14d0ec8f9a9
7
+ data.tar.gz: 688d165e578e7db64e361f0e33e852f1b75006193f04a9b0194a7d60b2be96f0b9f8cf94d93089580ee6a0d87ee2b60442dbf62e74a896a1325a3612059fc2e3
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [1.4.10]
7
+ - update vendor/dynomite: fix index creation dsl
8
+
6
9
  ## [1.4.9]
7
10
  - update vendor/dynomite
8
11
  - #128 from Atul9/update-license: update copyright year
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (1.4.9)
14
+ jets (1.4.10)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -67,7 +67,7 @@ GEM
67
67
  tzinfo (~> 1.1)
68
68
  arel (9.0.0)
69
69
  aws-eventstream (1.0.1)
70
- aws-partitions (1.128.0)
70
+ aws-partitions (1.129.0)
71
71
  aws-sdk-apigateway (1.23.0)
72
72
  aws-sdk-core (~> 3, >= 3.39.0)
73
73
  aws-sigv4 (~> 1.0)
@@ -113,7 +113,7 @@ GEM
113
113
  gems (1.1.1)
114
114
  json
115
115
  hashie (3.6.0)
116
- i18n (1.4.0)
116
+ i18n (1.5.1)
117
117
  concurrent-ruby (~> 1.0)
118
118
  jmespath (1.4.0)
119
119
  json (2.1.0)
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.4.9"
2
+ VERSION = "1.4.10"
3
3
  end
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [1.1.0]
7
+ - Merge pull request #5 from tongueroo/fix-index-creation
8
+ - fix index creation dsl among other things
9
+
6
10
  ## [1.0.9]
7
11
  - allow item.replace(hash) to work
8
12
  - Merge pull request #3 from mveer99/patch-1 Update comments: Fixed typo in project_name
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynomite (1.0.9)
4
+ dynomite (1.1.0)
5
5
  activesupport
6
6
  aws-sdk-dynamodb
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
16
  aws-eventstream (1.0.1)
17
- aws-partitions (1.128.0)
17
+ aws-partitions (1.129.0)
18
18
  aws-sdk-core (3.44.2)
19
19
  aws-eventstream (~> 1.0)
20
20
  aws-partitions (~> 1.0)
@@ -26,7 +26,7 @@ GEM
26
26
  aws-sigv4 (1.0.3)
27
27
  concurrent-ruby (1.1.4)
28
28
  diff-lcs (1.3)
29
- i18n (1.4.0)
29
+ i18n (1.5.1)
30
30
  concurrent-ruby (~> 1.0)
31
31
  jmespath (1.4.0)
32
32
  minitest (5.11.3)
@@ -3,14 +3,19 @@ class CreateCommentsMigration < Dynomite::Migration
3
3
  create_table :comments do |t|
4
4
  t.partition_key "post_id:string" # required
5
5
  t.sort_key "created_at:string" # optional
6
- t.provisioned_throughput(5) # sets both read and write, defaults to 5 when not set
6
+ t.provisioned_throughput(1) # sets both read and write, defaults to 5 when not set
7
7
 
8
8
  t.lsi do |i|
9
- i.partition_key "user_id:string"
10
- i.sort_key "updated_at:string" # optional
11
-
12
- i.provisioned_throughput(10)
9
+ i.partition_key "post_id:string"
10
+ i.sort_key "updated_at:string" # required for lsi
11
+ i.provisioned_throughput(2)
13
12
  end
13
+
14
+ # t.gsi do |i|
15
+ # i.partition_key "post_id:string"
16
+ # i.sort_key "deleted_at:string" # optional for gsi
17
+ # i.provisioned_throughput(2)
18
+ # end
14
19
  end
15
20
  end
16
21
  end
@@ -20,13 +25,12 @@ class UpdateCommentsMigration < Dynomite::Migration
20
25
  update_table :comments do |t|
21
26
  t.gsi(:create) do |i|
22
27
  i.partition_key "post_id:string"
23
- i.sort_key "updated_at:string" # optional
24
-
25
- i.provisioned_throughput(10)
28
+ i.sort_key "flagged_at:string" # optional for gsi
29
+ i.provisioned_throughput(3)
26
30
  end
27
31
 
28
32
  t.gsi(:update, "update-me-index") do |i|
29
- i.provisioned_throughput(10)
33
+ i.provisioned_throughput(5)
30
34
  end
31
35
 
32
36
  t.gsi(:delete, "delete-me-index")
@@ -35,7 +35,7 @@ class Dynomite::Migration
35
35
  # i.partition_key = "category:string"
36
36
  # i.sort_key = "created_at:string" # optional
37
37
  # end
38
- def gsi(action, index_name=nil, &block)
38
+ def gsi(action=:create, index_name=nil, &block)
39
39
  gsi_index = GlobalSecondaryIndex.new(action, index_name, &block)
40
40
  @gsi_indexes << gsi_index # store @gsi_index for the parent Dsl to use
41
41
  end
@@ -50,7 +50,7 @@ class Dynomite::Migration
50
50
  lsi_index = LocalSecondaryIndex.new(index_name, &block)
51
51
  @lsi_indexes << lsi_index # store @lsi_index for the parent Dsl to use
52
52
  end
53
- alias_method :local_secondary_index, :gsi
53
+ alias_method :local_secondary_index, :lsi
54
54
 
55
55
  def evaluate
56
56
  return if @evaluated
@@ -74,6 +74,9 @@ class Dynomite::Migration
74
74
  end
75
75
 
76
76
  def params_create_table
77
+ merge_lsi_attribute_definitions!
78
+ merge_gsi_attribute_definitions!
79
+
77
80
  params = {
78
81
  table_name: namespaced_table_name,
79
82
  key_schema: @key_schema,
@@ -81,14 +84,31 @@ class Dynomite::Migration
81
84
  provisioned_throughput: @provisioned_throughput
82
85
  }
83
86
 
84
- params[:local_secondary_index_creates] = local_secondary_index_creates unless @lsi_indexes.empty?
87
+ params[:local_secondary_indexes] = lsi_secondary_index_creates unless @lsi_indexes.empty?
88
+ params[:global_secondary_indexes] = gsi_secondary_index_creates unless @gsi_indexes.empty?
89
+ params
90
+ end
91
+
92
+ def params_update_table
93
+ merge_gsi_attribute_definitions!
94
+
95
+ params = {
96
+ table_name: namespaced_table_name,
97
+ attribute_definitions: @attribute_definitions,
98
+ # update table take values only some values for the "parent" table
99
+ # no key_schema, update_table does not handle key_schema for the "parent" table
100
+ }
101
+ # only set "parent" table provisioned_throughput if user actually invoked
102
+ # it in the dsl
103
+ params[:provisioned_throughput] = @provisioned_throughput if @provisioned_throughput_set_called
104
+ params[:global_secondary_index_updates] = global_secondary_index_updates
85
105
  params
86
106
  end
87
107
 
88
108
  # Goes thorugh all the lsi_indexes that have been built up in memory.
89
109
  # Find the lsi object that creates an index and then grab the
90
110
  # attribute_definitions from it.
91
- def lsi_create_attribute_definitions
111
+ def merge_lsi_attribute_definitions!
92
112
  lsi = @lsi_indexes.first # DynamoDB only supports adding one index at a time anyway. The reason @lsi_indexes is an Array is because we're sharing the same class code for LSI and GSI
93
113
  if lsi
94
114
  lsi.evaluate # force early evaluate since we need the params to
@@ -100,7 +120,7 @@ class Dynomite::Migration
100
120
  else
101
121
  @attribute_definitions
102
122
  end
103
- all_attrs.uniq
123
+ @attribute_definitions = all_attrs.uniq
104
124
  end
105
125
 
106
126
  # maps each lsi to the hash structure expected by dynamodb update_table
@@ -111,40 +131,42 @@ class Dynomite::Migration
111
131
  # { delete: {...} }
112
132
  def lsi_secondary_index_creates
113
133
  @lsi_indexes.map do |lsi|
114
- { lsi.action => lsi.params }
134
+ lsi.params
115
135
  end
116
136
  end
117
137
 
118
- def params_update_table
119
- params = {
120
- table_name: namespaced_table_name,
121
- attribute_definitions: gsi_create_attribute_definitions,
122
- # update table take values only some values for the "parent" table
123
- # no key_schema, update_table does not handle key_schema for the "parent" table
124
- }
125
- # only set "parent" table provisioned_throughput if user actually invoked
126
- # it in the dsl
127
- params[:provisioned_throughput] = @provisioned_throughput if @provisioned_throughput_set_called
128
- params[:global_secondary_index_updates] = global_secondary_index_updates
129
- params
138
+ # maps each lsi to the hash structure expected by dynamodb update_table
139
+ # under the global_secondary_index_updates key:
140
+ #
141
+ # { create: {...} }
142
+ # { update: {...} }
143
+ # { delete: {...} }
144
+ def gsi_secondary_index_creates
145
+ @gsi_indexes.map do |gsi|
146
+ gsi.params
147
+ end
130
148
  end
131
149
 
132
150
  # Goes thorugh all the gsi_indexes that have been built up in memory.
133
151
  # Find the gsi object that creates an index and then grab the
134
152
  # attribute_definitions from it.
135
- def gsi_create_attribute_definitions
136
- gsi = @gsi_indexes.find { |gsi| gsi.action == :create }
153
+ def merge_gsi_attribute_definitions!
154
+ gsi_attrs = []
155
+
156
+ gsi = @gsi_indexes.find { |i| i.action == :create }
137
157
  if gsi
138
158
  gsi.evaluate # force early evaluate since we need the params to
139
159
  # add: gsi_attribute_definitions + gsi_attrs
140
160
  gsi_attrs = gsi.attribute_definitions
141
161
  end
142
- all_attrs = if gsi_attrs
143
- gsi_attribute_definitions + gsi_attrs
144
- else
145
- gsi_attribute_definitions
146
- end
147
- all_attrs.uniq
162
+
163
+ # Merge existing attributes for update table
164
+ all_gsi_attrs = @method_name == :update_table ?
165
+ gsi_attribute_definitions + gsi_attrs :
166
+ gsi_attrs
167
+
168
+ all_attrs = (@attribute_definitions + all_gsi_attrs).uniq
169
+ @attribute_definitions = all_attrs
148
170
  end
149
171
 
150
172
  # maps each gsi to the hash structure expected by dynamodb update_table
@@ -62,7 +62,8 @@ class Dynomite::Migration::Dsl
62
62
  }
63
63
  end
64
64
 
65
- if [:create, :update].include?(@action)
65
+ if self.is_a?(GlobalSecondaryIndex) && [:create, :update].include?(@action)
66
+ # provisioned_throughput is required for gsi index definition
66
67
  params[:provisioned_throughput] = @provisioned_throughput
67
68
  end
68
69
 
@@ -19,11 +19,19 @@ class Dynomite::Migration
19
19
  # Examples:
20
20
  # result = db.create_table(@params)
21
21
  # result = db.update_table(@params)
22
+
23
+ # Leaving this verbose output in here until this DSL is more hardened to help debug
24
+ unless ENV['DYNOMITE_ENV'] == 'test'
25
+ puts "Calling #{@method_name} with params:"
26
+ pp @params
27
+ end
28
+
29
+ return if ENV['DYNOMITE_DRY'] # dry run flag
22
30
  result = db.send(@method_name, @params)
23
31
 
24
32
  puts "DynamoDB Table: #{@table_name} Status: #{result.table_description.table_status}"
25
33
  rescue Aws::DynamoDB::Errors::ServiceError => error
26
- puts "Unable to #{@method_name.to_s.gsub('_',' ')}: #{error.message}"
34
+ puts "Unable to #{@method_name.to_s.gsub('_',' ')}: #{error.message}".colorize(:red)
27
35
  end
28
36
  end
29
37
  end
@@ -1,3 +1,3 @@
1
1
  module Dynomite
2
- VERSION = "1.0.9"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -56,8 +56,7 @@ describe LSI do
56
56
  :key_schema=>[
57
57
  {:attribute_name=>"post_id", :key_type=>"HASH"},
58
58
  {:attribute_name=>"created_at", :key_type=>"RANGE"}],
59
- :projection=>{:projection_type=>"ALL"},
60
- :provisioned_throughput=> {:read_capacity_units=>5, :write_capacity_units=>5}
59
+ :projection=>{:projection_type=>"ALL"}
61
60
  })
62
61
  end
63
62
  end
@@ -38,12 +38,12 @@ describe Dynomite::Migration::Dsl do
38
38
 
39
39
  context "update_table" do
40
40
  let(:dsl) do
41
- Dynomite::Migration::Dsl.db = double("db").as_null_object
42
41
  Dynomite::Migration::Dsl.new(:update_table, "comments")
43
42
  end
44
43
 
45
44
  it "builds up the gsi index params" do
46
45
  dsl.provisioned_throughput(18)
46
+ allow(dsl).to receive(:gsi_attribute_definitions).and_return([])
47
47
 
48
48
  dsl.gsi(:create) do |i|
49
49
  i.partition_key "post_id:string"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.9
4
+ version: 1.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-06 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -827,8 +827,9 @@ files:
827
827
  - vendor/dynomite/lib/dynomite/version.rb
828
828
  - vendor/dynomite/pkg/dynomite-1.0.8.gem
829
829
  - vendor/dynomite/pkg/dynomite-1.0.9.gem
830
+ - vendor/dynomite/pkg/dynomite-1.1.0.gem
830
831
  - vendor/dynomite/spec/fixtures/app_root/config/dynamodb.yml
831
- - vendor/dynomite/spec/fixtures/dynamodb/migrate/20190106183548-comments_migration.rb
832
+ - vendor/dynomite/spec/fixtures/dynamodb/migrate/20190108061826-comments_migration.rb
832
833
  - vendor/dynomite/spec/lib/dynomite/item_spec.rb
833
834
  - vendor/dynomite/spec/lib/dynomite/migration/dsl/global_secondary_index_spec.rb
834
835
  - vendor/dynomite/spec/lib/dynomite/migration/dsl/local_secondary_index_spec.rb