Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

# 4.5.1 (Jul, 2025)
* Create update before insert trigger

# 4.5.0 (Feb, 2025)
* Update test matrix to include Rails 8
* Add option to force tables to use default engine
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lhm-shopify (4.5.0)
lhm-shopify (4.5.1)
retriable (>= 3.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_7.2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
lhm-shopify (4.5.0)
lhm-shopify (4.5.1)
retriable (>= 3.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_8.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
lhm-shopify (4.5.0)
lhm-shopify (4.5.1)
retriable (>= 3.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_head.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GIT
PATH
remote: ..
specs:
lhm-shopify (4.5.0)
lhm-shopify (4.5.1)
retriable (>= 3.0.0)

GEM
Expand Down
2 changes: 1 addition & 1 deletion lib/lhm/entangler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def initialize(migration, connection = nil)
def entangle
[
create_delete_trigger,
create_update_trigger,
create_insert_trigger,
create_update_trigger
]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/lhm/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Schmidt

module Lhm
VERSION = '4.5.0'
VERSION = '4.5.1'
end
28 changes: 14 additions & 14 deletions spec/unit/entangler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,37 @@
@destination.columns['tags'] = { :type => 'varchar(255)' }
end

it 'should create insert trigger to destination table' do
it 'should create the delete trigger to the destination table first' do
ddl = %Q{
create trigger `lhmt_ins_origin`
after insert on `origin` for each row
replace into `destination` (`info`, `tags`) /* large hadron migration */
values (`NEW`.`info`, `NEW`.`tags`)
create trigger `lhmt_del_origin`
after delete on `origin` for each row
delete ignore from `destination` /* large hadron migration */
where `destination`.`id` = OLD.`id`
}

value(@entangler.entangle).must_include strip(ddl)
assert_equal strip(ddl), @entangler.entangle[0]
end

it 'should create an update trigger to the destination table' do
it 'should create the update trigger to the destination table second' do
ddl = %Q{
create trigger `lhmt_upd_origin`
after update on `origin` for each row
replace into `destination` (`info`, `tags`) /* large hadron migration */
values (`NEW`.`info`, `NEW`.`tags`)
}

value(@entangler.entangle).must_include strip(ddl)
assert_equal strip(ddl), @entangler.entangle[1]
end

it 'should create a delete trigger to the destination table' do
it 'should create the insert trigger to destination table last' do
ddl = %Q{
create trigger `lhmt_del_origin`
after delete on `origin` for each row
delete ignore from `destination` /* large hadron migration */
where `destination`.`id` = OLD.`id`
create trigger `lhmt_ins_origin`
after insert on `origin` for each row
replace into `destination` (`info`, `tags`) /* large hadron migration */
values (`NEW`.`info`, `NEW`.`tags`)
}

value(@entangler.entangle).must_include strip(ddl)
assert_equal strip(ddl), @entangler.entangle[2]
end

it 'should retry trigger creation when it hits a lock wait timeout' do
Expand Down