online_migrations 0.30.0 → 0.31.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 428fd65e363b915608f720370a2cd91ec14749cd17933ec4e26351bb4745084a
4
- data.tar.gz: ae292bba4cd1b557694f78240a7da761c8d890aa691cc6b485ddd9f71fd339c5
3
+ metadata.gz: b5e1f97d972736356a7aa992a5fb39d318ebdd9709952c9015f98d832b5e94c1
4
+ data.tar.gz: fd4b0fc1ae446665dd22e27519ffa93272def9ea25d107bfed037b754e9f01e0
5
5
  SHA512:
6
- metadata.gz: 59c0573c24d75488c849fa746d6346c31e439d66032725264ce724e97ab8ffbd16cebb03a57ad75071e2b29bf884be0b47696abdcadc72d974effaafd73fe8b4
7
- data.tar.gz: 73de95254d001d4d285a48ad4d3adb60726ab6bf0bb86b085dde8466b6e1e85fbb668738f09121c38718504ad253615afb3da5e24f56bc48bd01ce9d369cdd4c
6
+ metadata.gz: 170f3d973598ac2bb5b8cdf6acfa28217b58fda566e3482d1ced37f4e55b173cc32f6e1ca676863df9af0624170b520dcf1bbc50a022278c7664da55ebe317d3
7
+ data.tar.gz: 04f8aaeacea73a571b562752a7f525d607ea9f601e64dd147fb5d3f2bf75653764aa458610876b28609d12d93dd0113d4fcf3069ddbd9fee06159ee01a59cc20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.31.1 (2025-11-11)
4
+
5
+ - Do not attempt running background migrations on database with `database_tasks: false`
6
+
7
+ ## 0.31.0 (2025-10-22)
8
+
9
+ - Store backtraces for failed background data migrations jobs
10
+ - Make `add_column` idempotent
11
+ - Fix `NullLockRetrier#with_lock_retries` method signature
12
+
3
13
  ## 0.30.0 (2025-10-17)
4
14
 
5
15
  - Fix `remove_check_constraint` when using `:if_exists`
@@ -6,6 +6,8 @@ module OnlineMigrations
6
6
  class MigrationJob
7
7
  include Sidekiq::IterableJob
8
8
 
9
+ sidekiq_options backtrace: true
10
+
9
11
  sidekiq_retry_in do |count, _exception, jobhash|
10
12
  migration_id = jobhash["args"].fetch(0)
11
13
  migration = Migration.find(migration_id)
@@ -251,7 +251,7 @@ module OnlineMigrations
251
251
  def delay(_attempt, _command = nil, _arguments = [])
252
252
  end
253
253
 
254
- def with_lock_retries(_connection)
254
+ def with_lock_retries(_connection, _command = nil, *_arguments)
255
255
  yield
256
256
  end
257
257
  end
@@ -630,6 +630,19 @@ module OnlineMigrations
630
630
  remove_check_constraint(table_name, name: name)
631
631
  end
632
632
 
633
+ # Extends default method to be idempotent and automatically recreate invalid indexes.
634
+ #
635
+ # @see https://api.rubyonrails.org/v8.1/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column
636
+ #
637
+ def add_column(table_name, column_name, type, **options)
638
+ if column_exists?(table_name, column_name, type, **options)
639
+ Utils.say("Column was not added because it already exists (this may be due to an aborted migration " \
640
+ "or similar) table_name: #{table_name}, column_name: #{column_name}")
641
+ else
642
+ super
643
+ end
644
+ end
645
+
633
646
  # Adds a reference to the table with minimal locking
634
647
  #
635
648
  # Active Record adds an index non-`CONCURRENTLY` to references by default, which blocks writes.
@@ -127,7 +127,14 @@ module OnlineMigrations
127
127
  # This is the way that currently is used in ActiveRecord tests themselves.
128
128
  pool_manager = ActiveRecord::Base.connection_handler.send(:get_pool_manager, ancestor.name)
129
129
 
130
- return pool_manager.shard_names if pool_manager
130
+ if pool_manager
131
+ shards_with_database_tasks = pool_manager.shard_names.select do |shard_name|
132
+ pool_config = pool_manager.get_pool_config(:writing, shard_name)
133
+ pool_config.db_config.database_tasks? if pool_config
134
+ end
135
+
136
+ return shards_with_database_tasks
137
+ end
131
138
  end
132
139
  end
133
140
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.30.0"
4
+ VERSION = "0.31.1"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: online_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-17 00:00:00.000000000 Z
10
+ date: 2025-11-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord