From d0b21fe1f6f9f3beac3665ff7b6d697b4c3203a5 Mon Sep 17 00:00:00 2001 From: Matheus Richard Date: Mon, 2 Feb 2026 19:47:19 -0300 Subject: [PATCH 1/3] Ruby 3.4.8 --- Gemfile.lock | 4 ++++ mise.toml | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 mise.toml diff --git a/Gemfile.lock b/Gemfile.lock index a12be4d..2e5ee54 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,6 +137,8 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) + nokogiri (1.18.10-arm64-darwin) + racc (~> 1.4) nokogiri (1.18.10-x86_64-darwin) racc (~> 1.4) nokogiri (1.18.10-x86_64-linux-gnu) @@ -237,6 +239,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) + sqlite3 (2.7.3-arm64-darwin) sqlite3 (2.7.3-x86_64-darwin) sqlite3 (2.7.3-x86_64-linux-gnu) standard-custom (1.0.2) @@ -261,6 +264,7 @@ GEM zeitwerk (2.7.3) PLATFORMS + arm64-darwin-25 x86_64-darwin-24 x86_64-linux diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..c6e14d5 --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +ruby = "3.4.8" From d75cbbd89460ca7e64d67366a38025950a0cb651 Mon Sep 17 00:00:00 2001 From: Matheus Richard Date: Mon, 2 Feb 2026 19:51:57 -0300 Subject: [PATCH 2/3] Fix transaction to wrap Migration.new Move the transaction from the instance `run` method to `self.run` so it wraps both initialization and execution. This ensures database operations in `initialize` are rolled back on failure. Co-Authored-By: Claude Opus 4.5 --- lib/data_customs/migration.rb | 20 +++++++++++--------- spec/data_customs/migration_spec.rb | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/data_customs/migration.rb b/lib/data_customs/migration.rb index 1c31ec8..8368a23 100644 --- a/lib/data_customs/migration.rb +++ b/lib/data_customs/migration.rb @@ -5,20 +5,22 @@ class Migration DEFAULT_BATCH_SIZE = 1000 DEFAULT_THROTTLE = 0.01 - def self.run(...) = new(...).run + def self.run(...) + ActiveRecord::Base.transaction do + new(...).run + end + rescue => e + warn "🛃 Data migration failed" + raise e + end def up = raise NotImplementedError def verify! = raise NotImplementedError def run - ActiveRecord::Base.transaction do - up - verify! - puts "🛃 Data migration ran successfully!" - rescue => e - warn "🛃 Data migration failed" - raise e - end + up + verify! + puts "🛃 Data migration ran successfully!" end private diff --git a/spec/data_customs/migration_spec.rb b/spec/data_customs/migration_spec.rb index 36d0ac9..40d2c5f 100644 --- a/spec/data_customs/migration_spec.rb +++ b/spec/data_customs/migration_spec.rb @@ -52,6 +52,21 @@ def verify! = raise "Should not reach this" .and raise_error("Kaboom") end + it "rolls back db operations in initialize if up fails" do + migration = Class.new(DataCustoms::Migration) do + def initialize + TestUser.create!(name: "Created in initialize") + end + + def up = raise "Kaboom" + def verify! = nil + end + + expect { migration.run } + .to raise_error("Kaboom") + .and change { TestUser.count }.by(0) + end + describe "helpers" do it "batches records" do 3.times { |i| TestUser.create!(name: "User #{i}") } From f0ba29ed249c77937f1e4dfd41fd332c190c85e6 Mon Sep 17 00:00:00 2001 From: Matheus Richard Date: Tue, 3 Feb 2026 11:06:58 -0300 Subject: [PATCH 3/3] Update Ruby version in CI matrix to 4.0 --- .github/workflows/main.yml | 2 +- Gemfile.lock | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 346d080..d161298 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: name: Ruby ${{ matrix.ruby }} strategy: matrix: - ruby: ['3.2', '3.3', '3.4', 'head'] + ruby: ['3.2', '3.3', '3.4', '4.0'] steps: - uses: actions/checkout@v4 diff --git a/Gemfile.lock b/Gemfile.lock index 2e5ee54..aa4a73d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,7 +126,8 @@ GEM net-smtp marcel (1.0.4) mini_mime (1.1.5) - minitest (5.25.5) + minitest (6.0.1) + prism (~> 1.5) net-imap (0.5.10) date net-protocol @@ -137,11 +138,11 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.10-arm64-darwin) + nokogiri (1.19.0-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-darwin) + nokogiri (1.19.0-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.19.0-x86_64-linux-gnu) racc (~> 1.4) parallel (1.27.0) parser (3.3.9.0) @@ -150,7 +151,7 @@ GEM pp (0.6.2) prettyprint prettyprint (0.2.0) - prism (1.4.0) + prism (1.9.0) psych (5.2.6) date stringio @@ -239,9 +240,9 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - sqlite3 (2.7.3-arm64-darwin) - sqlite3 (2.7.3-x86_64-darwin) - sqlite3 (2.7.3-x86_64-linux-gnu) + sqlite3 (2.9.0-arm64-darwin) + sqlite3 (2.9.0-x86_64-darwin) + sqlite3 (2.9.0-x86_64-linux-gnu) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) @@ -255,7 +256,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (3.1.5) unicode-emoji (~> 4.0, >= 4.0.4) - unicode-emoji (4.0.4) + unicode-emoji (4.2.0) useragent (0.16.11) websocket-driver (0.8.0) base64