lhm-shopify 4.2.2 → 4.2.3
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/gemfiles/activerecord_6.1.gemfile.lock +1 -1
- data/gemfiles/activerecord_7.0.gemfile.lock +1 -1
- data/gemfiles/activerecord_7.1.gemfile.lock +1 -1
- data/lib/lhm/chunker.rb +1 -2
- data/lib/lhm/version.rb +1 -1
- data/spec/fixtures/composite_primary_key_with_varchar_columns.ddl +10 -0
- data/spec/fixtures/composite_primary_key_with_varchar_columns_dest.ddl +10 -0
- data/spec/integration/chunker_spec.rb +40 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e88f970c0a74075057e83cd9dddaff855c4b1260279604badc45af7d4f096f0
|
4
|
+
data.tar.gz: 722aefe84a0e97d6702b4b2706df2ad9c9084dec24be0e3e790fa4f4f535ea73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f423dbc69088a1e314e0b460a051f5a3438754382a5f26008e2ed1e754da771467a532c9f269cbfd2e1e0aa347e600b3dbabc436f8cc94c32d0d99819cb0f832
|
7
|
+
data.tar.gz: 047c7221c4eb28d5bc01a16287b5e813e46dbc6b7effae12ff6778660e8e295adb53490d9825c8ca714df6e00b3abef50cff522a2f29a0ae9c6834797e9c93e5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/lhm/chunker.rb
CHANGED
@@ -23,7 +23,6 @@ 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'/
|
27
26
|
@verifier = options[:verifier]
|
28
27
|
if @throttler = options[:throttler]
|
29
28
|
@throttler.connection = @connection if @throttler.respond_to?(:connection=)
|
@@ -81,7 +80,7 @@ module Lhm
|
|
81
80
|
|
82
81
|
def raise_on_non_pk_duplicate_warning
|
83
82
|
@connection.select_all("SHOW WARNINGS", should_retry: true, log_prefix: LOG_PREFIX).each do |row|
|
84
|
-
next if row["Message"].match?(@
|
83
|
+
next if row["Message"].start_with?("Duplicate entry") && row["Message"].match?(/for key '(#{@migration.destination_name}\.)?PRIMARY'\z/)
|
85
84
|
|
86
85
|
m = "Unexpected warning found for inserted row: #{row["Message"]}"
|
87
86
|
Lhm.logger.warn(m)
|
data/lib/lhm/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
CREATE TABLE `composite_primary_key_with_varchar_columns` (
|
2
|
+
`id` bigint NOT NULL AUTO_INCREMENT,
|
3
|
+
`shop_id` bigint NOT NULL,
|
4
|
+
`owner_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
5
|
+
`owner_id` bigint NOT NULL,
|
6
|
+
`namespace` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
7
|
+
`key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
8
|
+
PRIMARY KEY (`shop_id`,`owner_type`,`owner_id`,`namespace`,`key`),
|
9
|
+
UNIQUE KEY `id` (`id`)
|
10
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC
|
@@ -0,0 +1,10 @@
|
|
1
|
+
CREATE TABLE `composite_primary_key_with_varchar_columns_dest` (
|
2
|
+
`id` bigint NOT NULL AUTO_INCREMENT,
|
3
|
+
`shop_id` bigint NOT NULL,
|
4
|
+
`owner_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
5
|
+
`owner_id` bigint NOT NULL,
|
6
|
+
`namespace` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
7
|
+
`key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
8
|
+
PRIMARY KEY (`shop_id`,`owner_type`,`owner_id`,`namespace`,`key`),
|
9
|
+
UNIQUE KEY `id` (`id`)
|
10
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC
|
@@ -61,6 +61,46 @@ describe Lhm::Chunker do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'should copy and ignore duplicate composite primary key with line breaks' do
|
65
|
+
origin = table_create(:composite_primary_key_with_varchar_columns)
|
66
|
+
destination = table_create(:composite_primary_key_with_varchar_columns_dest)
|
67
|
+
migration = Lhm::Migration.new(origin, destination)
|
68
|
+
|
69
|
+
execute("insert into composite_primary_key_with_varchar_columns set id = 1001, shop_id = 1, owner_type = 'Product', owner_id = 1, namespace = '
|
70
|
+
23
|
71
|
+
|
72
|
+
23
|
73
|
+
', `key` = '
|
74
|
+
14
|
75
|
+
|
76
|
+
1
|
77
|
+
'")
|
78
|
+
execute("insert into composite_primary_key_with_varchar_columns set id = 1002, shop_id = 1, owner_type = 'Product', owner_id = 1, namespace = '
|
79
|
+
23
|
80
|
+
|
81
|
+
22
|
82
|
+
', `key` = '
|
83
|
+
14
|
84
|
+
|
85
|
+
1
|
86
|
+
'")
|
87
|
+
execute("insert into composite_primary_key_with_varchar_columns_dest set id = 1002, shop_id = 1, owner_type = 'Product', owner_id = 1, namespace = '
|
88
|
+
23
|
89
|
+
|
90
|
+
22
|
91
|
+
', `key` = '
|
92
|
+
14
|
93
|
+
|
94
|
+
1
|
95
|
+
'")
|
96
|
+
|
97
|
+
Lhm::Chunker.new(migration, connection, {raise_on_warning: true, throttler: throttler, printer: printer} ).run
|
98
|
+
|
99
|
+
replica do
|
100
|
+
value(count_all(destination.name)).must_equal(2)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
64
104
|
it 'should copy and raise on unexpected warnings' do
|
65
105
|
origin = table_create(:custom_primary_key)
|
66
106
|
destination = table_create(:custom_primary_key_dest)
|
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.2.
|
4
|
+
version: 4.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SoundCloud
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
- Rany Keddo
|
10
10
|
- Tobias Bielohlawek
|
11
11
|
- Tobias Schmidt
|
12
|
-
autorequire:
|
12
|
+
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2024-
|
15
|
+
date: 2024-07-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: retriable
|
@@ -254,6 +254,8 @@ files:
|
|
254
254
|
- spec/fixtures/bigint_table.ddl
|
255
255
|
- spec/fixtures/composite_primary_key.ddl
|
256
256
|
- spec/fixtures/composite_primary_key_dest.ddl
|
257
|
+
- spec/fixtures/composite_primary_key_with_varchar_columns.ddl
|
258
|
+
- spec/fixtures/composite_primary_key_with_varchar_columns_dest.ddl
|
257
259
|
- spec/fixtures/custom_primary_key.ddl
|
258
260
|
- spec/fixtures/custom_primary_key_dest.ddl
|
259
261
|
- spec/fixtures/destination.ddl
|
@@ -307,7 +309,7 @@ licenses:
|
|
307
309
|
- BSD-3-Clause
|
308
310
|
metadata:
|
309
311
|
allowed_push_host: https://rubygems.org
|
310
|
-
post_install_message:
|
312
|
+
post_install_message:
|
311
313
|
rdoc_options: []
|
312
314
|
require_paths:
|
313
315
|
- lib
|
@@ -322,8 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
324
|
- !ruby/object:Gem::Version
|
323
325
|
version: '0'
|
324
326
|
requirements: []
|
325
|
-
rubygems_version: 3.5.
|
326
|
-
signing_key:
|
327
|
+
rubygems_version: 3.5.16
|
328
|
+
signing_key:
|
327
329
|
specification_version: 4
|
328
330
|
summary: online schema changer for mysql
|
329
331
|
test_files: []
|