wukong-migrate 0.0.3 → 0.0.4
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 +8 -8
- data/lib/wukong-migrate/elasticsearch_migration.rb +10 -12
- data/lib/wukong-migrate/elasticsearch_operations.rb +7 -6
- data/lib/wukong-migrate/version.rb +1 -1
- data/spec/wukong-migrate/elasticsearch_migration_spec.rb +2 -3
- data/spec/wukong-migrate/elasticsearch_operations_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2RlYzkzMTE2NDhhY2Q2MDdlMzNlNzMyMGZjYjAwNDVkOGQyMDJmYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTczYjgyM2ExYzRhYmZkMmY0MTQ4YWVjMjQ4OTZlZjE2YWE4OGFhZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDI3MjQ0MGQxYTJkMmViZjgyMDA1MDg5MTEwNjI5YTQyMWE0MTUwNmFiOWE0
|
10
|
+
ZGNlMDYyNmRmZDRkZDdlNjdhNjAzMDc5NDBhNmYxMzlkMTNlZWRmODQxMjhi
|
11
|
+
ZWNlN2YwOGIyYWJlM2MzODliMGJjYTY3OWM4YjU2OWI4ZDdmYTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWM1MWMyOWI4YjQwOTU4OTgzOWY4ODQ3MGI2ZDA3MDUzMDIyZDljZTU1NGI1
|
14
|
+
Yjk0MGNjYmRiZDdlY2JjOTkzNjliNWY3YjIzZWY1NDcwMzY4MjRmZTIwOGVm
|
15
|
+
MWM5NWI5NTg1MTA2OTEzYzM1MDc5MTA3NWY0ZTg2MTBlMGVhNDA=
|
@@ -65,11 +65,11 @@ end
|
|
65
65
|
|
66
66
|
class IndexDsl < EsMigrationDsl
|
67
67
|
# Dsl methods
|
68
|
-
collection :creations,
|
69
|
-
collection :updates,
|
70
|
-
collection :deletions,
|
71
|
-
|
72
|
-
|
68
|
+
collection :creations, ObjectDsl, singular_name: 'create_mapping'
|
69
|
+
collection :updates, ObjectDsl, singular_name: 'update_mapping'
|
70
|
+
collection :deletions, ObjectDsl, singular_name: 'delete_mapping'
|
71
|
+
collection :add_aliases, Whatever, singular_name: 'alias_to'
|
72
|
+
collection :remove_aliases, Whatever, singular_name: 'remove_alias'
|
73
73
|
|
74
74
|
# Additional index-level settings
|
75
75
|
magic :number_of_replicas, Integer
|
@@ -92,14 +92,12 @@ class IndexDsl < EsMigrationDsl
|
|
92
92
|
obj
|
93
93
|
end
|
94
94
|
|
95
|
-
def receive_alias_to
|
96
|
-
|
97
|
-
super(params)
|
95
|
+
def receive_alias_to(attrs, &block)
|
96
|
+
operation_list << alias_index_op(:add, self.name, attrs[:name], attrs[:filter])
|
98
97
|
end
|
99
|
-
|
100
|
-
def receive_remove_alias
|
101
|
-
|
102
|
-
super(params)
|
98
|
+
|
99
|
+
def receive_remove_alias(attrs, &block)
|
100
|
+
operation_list << alias_index_op(:remove, self.name, attrs[:name], attrs[:filter])
|
103
101
|
end
|
104
102
|
|
105
103
|
def index_settings
|
@@ -59,11 +59,12 @@ class EsHttpOperation
|
|
59
59
|
class AliasIndex < EsHttpOperation
|
60
60
|
field :alias_name, String
|
61
61
|
field :action, Symbol
|
62
|
+
field :filter, Hash
|
62
63
|
|
63
|
-
def path() '/_aliases?'
|
64
|
-
def body() { actions: [{ action => { index: index, alias: alias_name } }]} ; end
|
65
|
-
def verb() :post
|
66
|
-
def info() "#{action.capitalize} alias :#{alias_name} for index #{index}"
|
64
|
+
def path() '/_aliases?' ; end
|
65
|
+
def body() { actions: [{ action => { index: index, alias: alias_name, filter: filter }.compact_blank }]} ; end
|
66
|
+
def verb() :post ; end
|
67
|
+
def info() "#{action.capitalize} alias :#{alias_name} for index #{index}" ; end
|
67
68
|
end
|
68
69
|
|
69
70
|
class UpdateIndexMapping < EsHttpOperation
|
@@ -93,8 +94,8 @@ class EsHttpOperation
|
|
93
94
|
UpdateIndexMapping.receive(index: index, obj_type: obj_type, mapping: mapping)
|
94
95
|
end
|
95
96
|
|
96
|
-
def alias_index_op (action, index, als)
|
97
|
-
AliasIndex.receive(action: action, index: index, alias_name: als)
|
97
|
+
def alias_index_op (action, index, als, filter)
|
98
|
+
AliasIndex.receive({ action: action, index: index, alias_name: als, filter: filter }.compact_blank)
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
@@ -36,13 +36,12 @@ describe EsMigration do
|
|
36
36
|
it 'handles alias operations last' do
|
37
37
|
m = subject.new do
|
38
38
|
create_index(:foo) do
|
39
|
-
alias_to
|
39
|
+
alias_to :superfoo, filter: {}
|
40
40
|
end
|
41
41
|
delete_index(:bar)
|
42
42
|
end.combined_operations.should eq([delete_index_op('bar'),
|
43
43
|
create_index_op('foo', {}),
|
44
|
-
alias_index_op('add', 'foo', 'superfoo')
|
45
|
-
alias_index_op('add', 'foo', 'superbar')])
|
44
|
+
alias_index_op('add', 'foo', 'superfoo', {})])
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'handles mapping operations' do
|
@@ -52,14 +52,14 @@ describe 'EsHttpOperation' do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
context EsHttpOperation::AliasIndex do
|
55
|
-
subject{ described_class.receive(index: 'foo', alias_name: 'bar', action: 'add') }
|
55
|
+
subject{ described_class.receive(index: 'foo', alias_name: 'bar', action: 'add', filter: { term: { foo: 'bar' }}) }
|
56
56
|
|
57
57
|
its(:path) { should eq('/_aliases?') }
|
58
|
-
its(:body) { should eq({ actions: [{ add: { index: 'foo', alias: 'bar' } }]}) }
|
58
|
+
its(:body) { should eq({ actions: [{ add: { index: 'foo', alias: 'bar', filter: { term: { foo: 'bar' } } } }]}) }
|
59
59
|
its(:verb) { should eq(:post) }
|
60
60
|
its(:info) { should eq('Add alias :bar for index foo') }
|
61
61
|
its(:raw_curl_string) do
|
62
|
-
should eq("curl -X POST 'http://localhost:9200/_aliases?' -d '{\"actions\":[{\"add\":{\"index\":\"foo\",\"alias\":\"bar\"}}]}'")
|
62
|
+
should eq("curl -X POST 'http://localhost:9200/_aliases?' -d '{\"actions\":[{\"add\":{\"index\":\"foo\",\"alias\":\"bar\",\"filter\":{\"term\":{\"foo\":\"bar\"}}}}]}'")
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wukong-migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Dempsey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wukong-deploy
|