dynamodb_framework 1.1.1 → 1.2.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: a89873127b5505c1c0f056df7e1e0ad1784ef20a
4
- data.tar.gz: d3479acd9e647dab6e5fd50c2d188dab0215aac8
3
+ metadata.gz: 43c68b4046339dcf1497fd9b227b2b28856c281e
4
+ data.tar.gz: cd4cccc048de83ac5b7d3f793cedf90be72ad18c
5
5
  SHA512:
6
- metadata.gz: 1db9bae075601b19cb993434983b89fd8899b9e4c9ac1cfadedf603e51c5070a352370a57fcb9253b8310e1ec6fe89b5cda8ffa71687f714e3817cdf8e75ad85
7
- data.tar.gz: 062d8ff334681876b692f70e95fefbec5acfb269581db4ee89f693958abf43dcb21d13fb6d124e79082a7fc10be3c32fb08d16dfbfb6d92b0a71f0813f7f5002
6
+ metadata.gz: 18566e0f81953f9f6956e813a15340cb15e8d937247773a91a0895e7106e2022587cf629d8b0d5ae13cd7b48e41bccf98aa90fde3f74972ac56666e11267ff1d
7
+ data.tar.gz: 7ee89bb2e01f23de3ff65f3c6a157db3a3f1d5faf3384c92a22613c3bd2b5a20594fc08747ab6493a305948a1c976d632a4824786114efc488340011b54f333d
@@ -1,6 +1,7 @@
1
1
  module DynamoDbFramework
2
2
  class MigrationScript
3
3
  attr_accessor :timestamp
4
+ attr_accessor :namespace
4
5
 
5
6
  def apply
6
7
  raise 'Not implemented.'
@@ -32,8 +32,8 @@ module DynamoDbFramework
32
32
 
33
33
  end
34
34
 
35
- def get_executed_scripts
36
- scripts = @dynamodb_repository.all()
35
+ def get_executed_scripts(namespace)
36
+ scripts = @dynamodb_repository.query(:namespace, namespace)
37
37
  if scripts.length > 0
38
38
  return scripts.sort { |a,b| b['timestamp'] <=> a['timestamp'] }.map { |i| i['timestamp'] }
39
39
  end
@@ -41,11 +41,11 @@ module DynamoDbFramework
41
41
  return nil
42
42
  end
43
43
 
44
- def apply
44
+ def apply(namespace)
45
45
 
46
46
  DynamoDbFramework.logger.info "[#{self.class}] - Applying migration scripts"
47
47
 
48
- executed_scripts = get_executed_scripts()
48
+ executed_scripts = get_executed_scripts(namespace)
49
49
 
50
50
  scripts = []
51
51
  DynamoDbFramework::MigrationScript.descendants.each do |ms|
@@ -57,7 +57,7 @@ module DynamoDbFramework
57
57
  if executed_scripts == nil || !executed_scripts.include?(script.timestamp)
58
58
  DynamoDbFramework.logger.info "[#{self.class}] - Applying script: #{script.timestamp}....."
59
59
  script.apply
60
- @dynamodb_repository.put({ :timestamp => script.timestamp })
60
+ @dynamodb_repository.put({ :timestamp => script.timestamp, :namespace => script.namespace })
61
61
  end
62
62
  end
63
63
 
@@ -65,11 +65,11 @@ module DynamoDbFramework
65
65
 
66
66
  end
67
67
 
68
- def rollback
68
+ def rollback(namespace)
69
69
 
70
70
  DynamoDbFramework.logger.info "[#{self.class}] - Rolling back started."
71
71
 
72
- executed_scripts = get_executed_scripts()
72
+ executed_scripts = get_executed_scripts(namespace)
73
73
 
74
74
  scripts = []
75
75
  DynamoDbFramework::MigrationScript.descendants.each do |ms|
@@ -80,7 +80,7 @@ module DynamoDbFramework
80
80
  scripts.sort { |a,b| a.timestamp <=> b.timestamp }.each do |script|
81
81
  if executed_scripts != nil && executed_scripts.length > 0 && executed_scripts.include?(script.timestamp)
82
82
  script.undo
83
- @dynamodb_repository.delete({ :timestamp => script.timestamp })
83
+ @dynamodb_repository.delete({ :timestamp => script.timestamp, :namespace => script.namespace })
84
84
  return
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module DynamoDbFramework
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage