lhm-teak 3.6.1 → 3.6.3

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: 0cb61bdc9210d61dff6a96cf2975604f7f67d5e6d053acb5b84f1a016d8bd127
4
- data.tar.gz: eb107d91175df6109f9b0640e7e0191cea7c946da2d64b49f4f95b86cc08e606
3
+ metadata.gz: 97826be10fb4623438563b99a21112df2fbbc2c996e67801282f1f89bfd3627b
4
+ data.tar.gz: e10b40b4a0d6e5b99b1b1e76c7c6e7475c6bc796f3d597c9f20c941e2b16c511
5
5
  SHA512:
6
- metadata.gz: b59f1aa113f91e6ff974a87b9fb019a6307278302110b3a99ccc58757f299acd99c6eaee3f9d6d19416cfcf6ffd9a8cdfac17a21fa29fe8b7491956eb7921f82
7
- data.tar.gz: 05f12dcc9e251b77e624c101dd7e032d5c693f293abf2a3e8f34f8679d0997df0203885273aab8bc74f017fec8e0fa24ecf769e9288703d56fbeda7d6f084e8e
6
+ metadata.gz: c3044f49b65ab2004cdcfda5ed96cdd7050157f906d58275ad5b774ca61fda52fd3c7d88837a85aa5a7782aa36d7f303a27549c40305c0cf0015a5e2d7030bca
7
+ data.tar.gz: cb8801aaf5d7777eb201accf77f4bc16fd9aae7743a862605b72d4eb547a624ee2db598f81b8cb7b2a58d41348b15f017e5ef132efde824417563aa995531175
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lhm-teak (3.6.1)
4
+ lhm-teak (3.6.3)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -6,12 +6,12 @@ module Lhm
6
6
 
7
7
  LOG_PREFIX = "ChunkInsert"
8
8
 
9
- def initialize(migration, connection, lowest, highest, retry_options = {})
9
+ def initialize(migration, connection, lowest, highest, options = {})
10
10
  @migration = migration
11
11
  @connection = connection
12
12
  @lowest = lowest
13
13
  @highest = highest
14
- @retry_options = retry_options
14
+ @options = options
15
15
  end
16
16
 
17
17
  def insert_and_return_count_of_rows_created
@@ -27,7 +27,7 @@ module Lhm
27
27
  end
28
28
 
29
29
  def expected_rows
30
- top - bottom + 1
30
+ @options.fetch(:expected_rows, top - bottom + 1)
31
31
  end
32
32
 
33
33
  private
@@ -23,9 +23,10 @@ module Lhm
23
23
  @processed_rows = 0
24
24
  while @processed_rows < ids.length
25
25
  next_idx = [@processed_rows + @throttler.stride, @ids.length].min
26
- ids_to_insert = ids[@processed_rows...next_idx]
26
+ range = @processed_rows...next_idx
27
+ ids_to_insert = ids[range]
27
28
  @processed_rows = next_idx
28
- yield IdSetChunkInsert.new(@migration, @connection, ids_to_insert)
29
+ yield ChunkInsert.new(@migration, @connection, ids_to_insert[0], ids_to_insert[-1], expected_rows: range.count)
29
30
  end
30
31
  end
31
32
 
data/lib/lhm/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Schmidt
3
3
 
4
4
  module Lhm
5
- VERSION = '3.6.1'
5
+ VERSION = '3.6.3'
6
6
  end
data/lib/lhm.rb CHANGED
@@ -11,7 +11,6 @@ require 'lhm/sql_retry'
11
11
  require 'lhm/proxysql_helper'
12
12
  require 'lhm/connection'
13
13
  require 'lhm/test_support'
14
- require 'lhm/railtie' if defined?(Rails::Railtie)
15
14
  require 'logger'
16
15
 
17
16
  # Large hadron migrator - online schema change tool
@@ -43,11 +43,11 @@ describe Lhm::IdSetChunkFinder do
43
43
 
44
44
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns((1..20).select(&:odd?))
45
45
 
46
- @connection.expects(:update).with(regexp_matches(/`id` in \(1,3\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
47
- @connection.expects(:update).with(regexp_matches(/`id` in \(5,7\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
48
- @connection.expects(:update).with(regexp_matches(/`id` in \(9,11\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
49
- @connection.expects(:update).with(regexp_matches(/`id` in \(13,15\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
50
- @connection.expects(:update).with(regexp_matches(/`id` in \(17,19\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
46
+ @connection.expects(:update).with(regexp_matches(/`id` between 1 and 3/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
47
+ @connection.expects(:update).with(regexp_matches(/`id` between 5 and 7/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
48
+ @connection.expects(:update).with(regexp_matches(/`id` between 9 and 11/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
49
+ @connection.expects(:update).with(regexp_matches(/`id` between 13 and 15/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
50
+ @connection.expects(:update).with(regexp_matches(/`id` between 17 and 19/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
51
51
 
52
52
  @chunker.run
53
53
  end
@@ -66,10 +66,10 @@ describe Lhm::IdSetChunkFinder do
66
66
 
67
67
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns((1..20).select(&:odd?))
68
68
 
69
- @connection.expects(:update).with(regexp_matches(/`id` in \(1,3\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
70
- @connection.expects(:update).with(regexp_matches(/`id` in \(5,7,9\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
71
- @connection.expects(:update).with(regexp_matches(/`id` in \(11,13,15\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
72
- @connection.expects(:update).with(regexp_matches(/`id` in \(17,19\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
69
+ @connection.expects(:update).with(regexp_matches(/`id` between 1 and 3/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
70
+ @connection.expects(:update).with(regexp_matches(/`id` between 5 and 9/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
71
+ @connection.expects(:update).with(regexp_matches(/`id` between 11 and 15/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
72
+ @connection.expects(:update).with(regexp_matches(/`id` between 17 and 19/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
73
73
 
74
74
  @connection.expects(:execute).twice.with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
75
75
 
@@ -81,7 +81,7 @@ describe Lhm::IdSetChunkFinder do
81
81
  :chunk_finder => Lhm::IdSetChunkFinder)
82
82
 
83
83
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([1])
84
- @connection.expects(:update).with(regexp_matches(/`id` in \(1\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
84
+ @connection.expects(:update).with(regexp_matches(/`id` between 1 and 1/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
85
85
 
86
86
  @chunker.run
87
87
  end
@@ -95,11 +95,11 @@ describe Lhm::IdSetChunkFinder do
95
95
 
96
96
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns((2..10).to_a)
97
97
 
98
- @connection.expects(:update).with(regexp_matches(/`id` in \(2,3\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
99
- @connection.expects(:update).with(regexp_matches(/`id` in \(4,5\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
100
- @connection.expects(:update).with(regexp_matches(/`id` in \(6,7\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
101
- @connection.expects(:update).with(regexp_matches(/`id` in \(8,9\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
102
- @connection.expects(:update).with(regexp_matches(/`id` in \(10\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
98
+ @connection.expects(:update).with(regexp_matches(/`id` between 2 and 3/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
99
+ @connection.expects(:update).with(regexp_matches(/`id` between 4 and 5/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
100
+ @connection.expects(:update).with(regexp_matches(/`id` between 6 and 7/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
101
+ @connection.expects(:update).with(regexp_matches(/`id` between 8 and 9/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(2)
102
+ @connection.expects(:update).with(regexp_matches(/`id` between 10 and 10/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
103
103
 
104
104
  @chunker.run
105
105
  end
@@ -113,7 +113,7 @@ describe Lhm::IdSetChunkFinder do
113
113
  end
114
114
 
115
115
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([1, 2])
116
- @connection.expects(:update).with(regexp_matches(/where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`.*`id` in \(1,2\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
116
+ @connection.expects(:update).with(regexp_matches(/where \(foo.created_at > '2013-07-10' or foo.baz = 'quux'\) and `foo`.*`id` between 1 and 2/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
117
117
  @connection.expects(:execute).with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
118
118
 
119
119
  def @migration.conditions
@@ -132,7 +132,7 @@ describe Lhm::IdSetChunkFinder do
132
132
  end
133
133
 
134
134
  @connection.expects(:select_values).with(regexp_matches(/order by id asc/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([1,2])
135
- @connection.expects(:update).with(regexp_matches(/inner join bar on foo.id = bar.foo_id and.*`id` in \(1,2\)/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
135
+ @connection.expects(:update).with(regexp_matches(/inner join bar on foo.id = bar.foo_id and.*`id` between 1 and 2/),EXPECTED_RETRY_FLAGS_CHUNK_INSERT).returns(1)
136
136
  @connection.expects(:execute).with(regexp_matches(/show warnings/),EXPECTED_RETRY_FLAGS_CHUNKER).returns([])
137
137
 
138
138
  def @migration.conditions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhm-teak
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SoundCloud
@@ -218,7 +218,6 @@ files:
218
218
  - lib/lhm/migrator.rb
219
219
  - lib/lhm/printer.rb
220
220
  - lib/lhm/proxysql_helper.rb
221
- - lib/lhm/railtie.rb
222
221
  - lib/lhm/sql_helper.rb
223
222
  - lib/lhm/sql_retry.rb
224
223
  - lib/lhm/table.rb
data/lib/lhm/railtie.rb DELETED
@@ -1,9 +0,0 @@
1
- module Lhm
2
- class Railtie < Rails::Railtie
3
- initializer "lhm.test_setup" do
4
- if Rails.env.test? || Rails.env.development?
5
- Lhm.execute_inline!
6
- end
7
- end
8
- end
9
- end