lhm-shopify 4.1.0 → 4.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
  SHA256:
3
- metadata.gz: 850cda6d2f610db2985c780d2a90d176e8520b373e21dafbe67df47e9a07ba0f
4
- data.tar.gz: 982ab91c6319f5f7803d73d9f3734a57d28a13e76184500a665a5ab5b91d434f
3
+ metadata.gz: b1a16e83f2a989c0624948b4ef8bfe2c3b7359aa1420ee5d2c41dee1b9ec6e29
4
+ data.tar.gz: 9baa1e49780b70edd51caec39460a3ad440f2d7f10f65aa8295da541a762cd42
5
5
  SHA512:
6
- metadata.gz: 8bdb254a7cd2091f7d1d125080bc843b43fc9039a7b2a99cba62752bee84726971e8018fb77738fdd0b15867a7f959ff419802270de75c08c2a72cd44d8b004b
7
- data.tar.gz: b7d3a989384483ba9f43dd000f1e46c62805e15a0e15c4fcba0fedc964787d4fb1eafe294a2b23deae2d5b035057739551385eca08d24529d8c8e951ba44b163
6
+ metadata.gz: 0d96f3ba67d232682ecb5fa27f9f7cb33f850125546364a41ede17c6dda187e00d8b91e6ab8a5189022e9fd3117af4e9bb6272c1392d0d8510252cea6ae9ac00
7
+ data.tar.gz: 407a0497d1ce019d3f7e835ceb157441a1cd76f5723a7a7d3a61d95c2232adb42ac56b6aba9b07d5720eeeab0e6ce6a68d50d297dbd9736fd4e641835d372a86
@@ -18,6 +18,11 @@ jobs:
18
18
  ruby: ["3.0", "3.1", "3.2", "head"]
19
19
  mysql: ["5.7", "8.0"]
20
20
  adapter: ["mysql2", "trilogy"]
21
+ exclude:
22
+ - activerecord: 6.1
23
+ ruby: head
24
+ - activerecord: 7.0
25
+ ruby: head
21
26
 
22
27
  env:
23
28
  BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord_${{ matrix.activerecord }}.gemfile"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Unreleased
2
2
 
3
+ # 4.2.0 (Mar, 2024)
4
+ * Support `DROP DEFAULT` & `SET DEFAULT` in `change_column` operations.
5
+
6
+ # 4.1.1 (Nov, 2023)
7
+ * Fix check for warnings against PK in MySQL 8+
8
+
3
9
  # 4.1.0 (Oct, 2023)
4
10
  * Test against MySQL 8.0.
5
11
  * Test against Ruby Head.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lhm-shopify (4.1.0)
4
+ lhm-shopify (4.2.0)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -38,7 +38,7 @@ GEM
38
38
  ruby2_keywords
39
39
  i18n (1.14.1)
40
40
  concurrent-ruby (~> 1.0)
41
- minitest (5.20.0)
41
+ minitest (5.22.2)
42
42
  mocha (2.1.0)
43
43
  ruby2_keywords (>= 0.0.5)
44
44
  mutex_m (0.1.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.1.0)
4
+ lhm-shopify (4.2.0)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -31,7 +31,7 @@ GEM
31
31
  docile (1.4.0)
32
32
  i18n (1.14.1)
33
33
  concurrent-ruby (~> 1.0)
34
- minitest (5.20.0)
34
+ minitest (5.22.2)
35
35
  mocha (2.1.0)
36
36
  ruby2_keywords (>= 0.0.5)
37
37
  mysql2 (0.5.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.1.0)
4
+ lhm-shopify (4.2.0)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -30,7 +30,7 @@ GEM
30
30
  docile (1.4.0)
31
31
  i18n (1.14.1)
32
32
  concurrent-ruby (~> 1.0)
33
- minitest (5.20.0)
33
+ minitest (5.22.2)
34
34
  mocha (2.1.0)
35
35
  ruby2_keywords (>= 0.0.5)
36
36
  mysql2 (0.5.5)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- lhm-shopify (4.1.0)
4
+ lhm-shopify (4.2.0)
5
5
  retriable (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -38,7 +38,7 @@ GEM
38
38
  ruby2_keywords
39
39
  i18n (1.14.1)
40
40
  concurrent-ruby (~> 1.0)
41
- minitest (5.20.0)
41
+ minitest (5.22.2)
42
42
  mocha (2.1.0)
43
43
  ruby2_keywords (>= 0.0.5)
44
44
  mutex_m (0.1.2)
data/lib/lhm/chunker.rb CHANGED
@@ -23,6 +23,7 @@ module Lhm
23
23
  @chunk_finder = ChunkFinder.new(migration, connection, options)
24
24
  @options = options
25
25
  @raise_on_warnings = options.fetch(:raise_on_warnings, false)
26
+ @pk_duplicate_warning_regexp ||= /Duplicate entry .+ for key '(#{@migration.destination_name}\.)?PRIMARY'/
26
27
  @verifier = options[:verifier]
27
28
  if @throttler = options[:throttler]
28
29
  @throttler.connection = @connection if @throttler.respond_to?(:connection=)
@@ -80,11 +81,11 @@ module Lhm
80
81
 
81
82
  def raise_on_non_pk_duplicate_warning
82
83
  @connection.select_all("SHOW WARNINGS", should_retry: true, log_prefix: LOG_PREFIX).each do |row|
83
- unless row["Message"].match?(/Duplicate entry .+ for key 'PRIMARY'/)
84
- m = "Unexpected warning found for inserted row: #{row["Message"]}"
85
- Lhm.logger.warn(m)
86
- raise Error.new(m) if @raise_on_warnings
87
- end
84
+ next if row["Message"].match?(@pk_duplicate_warning_regexp)
85
+
86
+ m = "Unexpected warning found for inserted row: #{row["Message"]}"
87
+ Lhm.logger.warn(m)
88
+ raise Error.new(m) if @raise_on_warnings
88
89
  end
89
90
  end
90
91
 
data/lib/lhm/migrator.rb CHANGED
@@ -67,7 +67,11 @@ module Lhm
67
67
  # @param [String] name Name of the column to change
68
68
  # @param [String] definition Valid SQL column definition
69
69
  def change_column(name, definition)
70
- ddl('alter table `%s` modify column `%s` %s' % [@name, name, definition])
70
+ if definition.match?(/^(DROP|SET) DEFAULT/i)
71
+ ddl('alter table `%s` alter column `%s` %s' % [@name, name, definition])
72
+ else
73
+ ddl('alter table `%s` modify column `%s` %s' % [@name, name, definition])
74
+ end
71
75
  end
72
76
 
73
77
  # Rename an existing column.
data/lib/lhm/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Schmidt
3
3
 
4
4
  module Lhm
5
- VERSION = '4.1.0'
5
+ VERSION = '4.2.0'
6
6
  end
@@ -31,7 +31,6 @@ describe Lhm::Chunker do
31
31
  replica do
32
32
  value(count_all(@destination.name)).must_equal(1)
33
33
  end
34
-
35
34
  end
36
35
 
37
36
  it 'should copy and ignore duplicate primary key' do
@@ -39,7 +38,7 @@ describe Lhm::Chunker do
39
38
  execute("insert into origin set id = 1002 ")
40
39
  execute("insert into destination set id = 1002 ")
41
40
 
42
- Lhm::Chunker.new(@migration, connection, {throttler: throttler, printer: printer} ).run
41
+ Lhm::Chunker.new(@migration, connection, {raise_on_warnings: true, throttler: throttler, printer: printer} ).run
43
42
 
44
43
  replica do
45
44
  value(count_all(@destination.name)).must_equal(2)
@@ -55,7 +54,7 @@ describe Lhm::Chunker do
55
54
  execute("insert into composite_primary_key set id = 1002, shop_id = 1")
56
55
  execute("insert into composite_primary_key_dest set id = 1002, shop_id = 1")
57
56
 
58
- Lhm::Chunker.new(migration, connection, {throttler: throttler, printer: printer} ).run
57
+ Lhm::Chunker.new(migration, connection, {raise_on_warning: true, throttler: throttler, printer: printer} ).run
59
58
 
60
59
  replica do
61
60
  value(count_all(destination.name)).must_equal(2)
@@ -116,6 +116,22 @@ describe Lhm::Migrator do
116
116
  'alter table `lhmn_alt` modify column `logins` INT(11)'
117
117
  ])
118
118
  end
119
+
120
+ it "should drop a default" do
121
+ @creator.change_column('foo', 'DROP DEFAULT')
122
+
123
+ value(@creator.statements).must_equal([
124
+ 'alter table `lhmn_alt` alter column `foo` DROP DEFAULT'
125
+ ])
126
+ end
127
+
128
+ it "should set a default" do
129
+ @creator.change_column('foo', "SET DEFAULT 'bar'")
130
+
131
+ value(@creator.statements).must_equal([
132
+ "alter table `lhmn_alt` alter column `foo` SET DEFAULT 'bar'"
133
+ ])
134
+ end
119
135
  end
120
136
 
121
137
  describe 'direct changes' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhm-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SoundCloud
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-10-12 00:00:00.000000000 Z
15
+ date: 2024-03-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: retriable
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
320
320
  - !ruby/object:Gem::Version
321
321
  version: '0'
322
322
  requirements: []
323
- rubygems_version: 3.4.20
323
+ rubygems_version: 3.5.6
324
324
  signing_key:
325
325
  specification_version: 4
326
326
  summary: online schema changer for mysql