dynamo-record 0.1.3 → 0.2.0
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: d7fbbd08b9fb9bbcd706585dce0bf61514301ca9
|
4
|
+
data.tar.gz: 7c5dfdafd9205e5d14d6d63abd5383fc5a6343d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97f011ec20b9522efa7aa16b665dc2feec5e98432ee49af336de64334fcf4a2f2771e664a849c6f8b0ac4aee82634b1074e53f3a77b517b52a2d2be913badc5e
|
7
|
+
data.tar.gz: 6e9796415449e386eaccefabbfda6f69b9bdb92160a27b205bc9271a9791ffe0b5585cafaea5cc321ae37ed4397ea45fc151b14074fb1bcfb1af2f14da5aec4e
|
data/.gitignore
CHANGED
File without changes
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module DynamoRecord
|
2
2
|
class TableMigration
|
3
|
+
def self.table_config_check
|
4
|
+
if migrate_table?
|
5
|
+
table_config.migrate!
|
6
|
+
return :migrated
|
7
|
+
end
|
8
|
+
:exists
|
9
|
+
end
|
10
|
+
|
3
11
|
def self.migrate(model)
|
4
12
|
migration = Aws::Record::TableMigration.new(model)
|
5
13
|
begin
|
@@ -32,5 +40,19 @@ module DynamoRecord
|
|
32
40
|
return e.message if e.message == 'Table already has an enabled stream'
|
33
41
|
raise e
|
34
42
|
end
|
43
|
+
|
44
|
+
def self.migrate_table?(update_provisioned_throughput = false)
|
45
|
+
unless update_provisioned_throughput
|
46
|
+
client = table_config.client
|
47
|
+
table_name = table_config.instance_values['model_class'].table_name
|
48
|
+
described_table = client.describe_table table_name: table_name
|
49
|
+
provisioned_throughput = described_table.table.provisioned_throughput
|
50
|
+
table_config.read_capacity_units provisioned_throughput.read_capacity_units
|
51
|
+
table_config.write_capacity_units provisioned_throughput.write_capacity_units
|
52
|
+
end
|
53
|
+
!table_config.exact_match?
|
54
|
+
rescue Aws::DynamoDB::Errors::ResourceNotFoundException
|
55
|
+
true
|
56
|
+
end
|
35
57
|
end
|
36
58
|
end
|
@@ -13,6 +13,9 @@ module DynamoRecord
|
|
13
13
|
yield "Migrating: #{migration}"
|
14
14
|
|
15
15
|
begin
|
16
|
+
status = table_config_check(migration)
|
17
|
+
yield status if status
|
18
|
+
|
16
19
|
status = up(migration)
|
17
20
|
yield status if status
|
18
21
|
|
@@ -35,9 +38,8 @@ module DynamoRecord
|
|
35
38
|
migration
|
36
39
|
end
|
37
40
|
|
38
|
-
def self.
|
39
|
-
|
40
|
-
case migration.up
|
41
|
+
def self.status_message(status)
|
42
|
+
case status
|
41
43
|
when :exists
|
42
44
|
'Table already exists'
|
43
45
|
when :migrated
|
@@ -47,6 +49,16 @@ module DynamoRecord
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
52
|
+
def self.up(migration)
|
53
|
+
return unless migration.respond_to? :up
|
54
|
+
status_message migration.up
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.table_config_check(migration)
|
58
|
+
return unless migration.respond_to? :table_config
|
59
|
+
status_message migration.table_config_check
|
60
|
+
end
|
61
|
+
|
50
62
|
def self.update(migration)
|
51
63
|
return unless migration.respond_to? :update
|
52
64
|
status = migration.update
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamo-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davis McClellan
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: exe
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-
|
17
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: aws-record
|
@@ -179,7 +179,7 @@ files:
|
|
179
179
|
- README.md
|
180
180
|
- build.sh
|
181
181
|
- doc/testing.md
|
182
|
-
- docker-compose.override.yml
|
182
|
+
- docker-compose.dev.override.yml
|
183
183
|
- docker-compose.yml
|
184
184
|
- dynamo-record.gemspec
|
185
185
|
- lib/dynamo-record.rb
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|
219
219
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.6.
|
220
|
+
rubygems_version: 2.6.11
|
221
221
|
signing_key:
|
222
222
|
specification_version: 4
|
223
223
|
summary: Extensions for working with dynamo via aws-record
|