online_migrations 0.29.1 → 0.29.2

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: cdc577e6585babba94ffe21df14f59b4a41681a0f80046e677452741123534d1
4
- data.tar.gz: 25f2d76cece9c0c1ae1a61d099e69599391a67f2ac3690abc537852873862df6
3
+ metadata.gz: 8f0f48b03f81c0a92af100d5d547eefc241806204f0cc0a475eb528fed026037
4
+ data.tar.gz: 74f9246907e52d527c46f832e66ab4b4b74c89e0ea9492612a303a1d65f006c7
5
5
  SHA512:
6
- metadata.gz: 14049ce85c5832741d1b0d5928b8e1d69924601f69c56a07d534c0aa558be60928c71d37eb3715cd892e9af68a44e7dd3d69d048c9bb52f5464a2ac7ad97f512
7
- data.tar.gz: 7b96a5bea220ea7283bd7a2bacc82b646de611d1b9704abafc412948ea77279cd2fbbf26908a43f1877a99e36d54ad52323a038297e4340600c4ce52d1cbada7
6
+ metadata.gz: d55296987b866078354a39a06f431c360a18935803b852a5768549b3ae9f18bf8d27a3b0608086b1bf9c20ecaa006ea782ed7f128bd45c57d32bce50e8cc67e3
7
+ data.tar.gz: b57ae5030819e74eb891565fd87c77a1762ed1e3aa8f74ec4fba570f286150f6da500279f7bbea95cf7e0fb360dcf3acd491ee05e1ce8e635889549211d55bf8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.29.2 (2025-07-21)
4
+
5
+ - Fix analyzing tables when indexes are added
6
+
3
7
  ## 0.29.1 (2025-07-17)
4
8
 
5
9
  - Fix idempotency for adding/removing indexes in background
@@ -33,7 +33,7 @@ OnlineMigrations.configure do |config|
33
33
 
34
34
  # Analyze tables after indexes are added.
35
35
  # Outdated statistics can sometimes hurt performance.
36
- config.auto_analyze = false
36
+ config.auto_analyze = true
37
37
 
38
38
  # Alphabetize table columns when dumping the schema.
39
39
  config.alphabetize_schema = false
@@ -130,7 +130,7 @@ OnlineMigrations.configure do |config|
130
130
  config.background_schema_migrations.max_attempts = 5
131
131
 
132
132
  # Statement timeout value used when running background schema migration.
133
- config.background_schema_migrations.statement_timeout = 1.hour
133
+ config.background_schema_migrations.statement_timeout = config.statement_timeout
134
134
 
135
135
  # The callback to perform when an error occurs during the background schema migration.
136
136
  # config.background_schema_migrations.error_handler = ->(error, errored_migration) do
@@ -55,7 +55,7 @@ module OnlineMigrations
55
55
  end
56
56
 
57
57
  private
58
- def has_many_association(counter_association) # rubocop:disable Naming/PredicateName
58
+ def has_many_association(counter_association) # rubocop:disable Naming/PredicatePrefix
59
59
  has_many_association = model.reflect_on_association(counter_association)
60
60
 
61
61
  if !has_many_association
@@ -138,7 +138,7 @@ module OnlineMigrations
138
138
  if index.valid?
139
139
  return
140
140
  else
141
- connection.remove_index(table_name, name: name, algorithm: :concurrently)
141
+ connection.remove_index(table_name, name: index.name, algorithm: :concurrently)
142
142
  end
143
143
  end
144
144
  end
@@ -558,11 +558,6 @@ module OnlineMigrations
558
558
  end
559
559
  end
560
560
  end
561
-
562
- # Outdated statistics + a new index can hurt performance of existing queries.
563
- if OnlineMigrations.config.auto_analyze && direction == :up
564
- connection.execute("ANALYZE #{table_name}")
565
- end
566
561
  end
567
562
  end
568
563
 
@@ -434,7 +434,7 @@ module OnlineMigrations
434
434
  # batch_size: 10_000, pause_ms: 100)
435
435
  #
436
436
  # @note This method should not be run within a transaction
437
- # @note For PostgreSQL 11+ you can use `add_column` instead
437
+ # @note If default value is not volatile, for PostgreSQL 11+ you can use `add_column` instead.
438
438
  #
439
439
  def add_column_with_default(table_name, column_name, type, **options)
440
440
  default = options.fetch(:default)
@@ -727,6 +727,11 @@ module OnlineMigrations
727
727
  # It only conflicts with constraint validations, creating/removing indexes,
728
728
  # and some other "ALTER TABLE"s.
729
729
  super
730
+
731
+ # Outdated statistics + a new index can hurt performance of existing queries.
732
+ if OnlineMigrations.config.auto_analyze
733
+ execute("ANALYZE #{table_name}")
734
+ end
730
735
  end
731
736
 
732
737
  # Extends default method to be idempotent.
@@ -777,22 +782,6 @@ module OnlineMigrations
777
782
  end
778
783
  end
779
784
 
780
- # Extends default method with disabled statement timeout while validation is run
781
- #
782
- # @see https://edgeapi.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/SchemaStatements.html#method-i-validate_foreign_key
783
- #
784
- def validate_foreign_key(from_table, to_table = nil, **options)
785
- foreign_key = foreign_key_for!(from_table, to_table: to_table, **options)
786
-
787
- # Skip costly operation if already validated.
788
- return if foreign_key.validated?
789
-
790
- # "VALIDATE CONSTRAINT" requires a "SHARE UPDATE EXCLUSIVE" lock.
791
- # It only conflicts with other validations, creating/removing indexes,
792
- # and some other "ALTER TABLE"s.
793
- super
794
- end
795
-
796
785
  # Extends default method to be idempotent.
797
786
  #
798
787
  # @see https://edgeapi.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_foreign_key
@@ -823,22 +812,6 @@ module OnlineMigrations
823
812
  end
824
813
  end
825
814
 
826
- # Extends default method with disabled statement timeout while validation is run
827
- #
828
- # @see https://edgeapi.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/SchemaStatements.html#method-i-validate_check_constraint
829
- #
830
- def validate_check_constraint(table_name, **options)
831
- check_constraint = check_constraint_for!(table_name, **options)
832
-
833
- # Skip costly operation if already validated.
834
- return if check_constraint.validated?
835
-
836
- # "VALIDATE CONSTRAINT" requires a "SHARE UPDATE EXCLUSIVE" lock.
837
- # It only conflicts with other validations, creating/removing indexes,
838
- # and some other "ALTER TABLE"s.
839
- super
840
- end
841
-
842
815
  # Extends default method to be idempotent
843
816
  #
844
817
  # @see https://edgeapi.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_check_constraint
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.29.1"
4
+ VERSION = "0.29.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: online_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.1
4
+ version: 0.29.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-17 00:00:00.000000000 Z
11
+ date: 2025-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord