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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/generators/online_migrations/templates/initializer.rb.tt +2 -2
- data/lib/online_migrations/background_data_migrations/reset_counters.rb +1 -1
- data/lib/online_migrations/background_schema_migrations/migration.rb +1 -1
- data/lib/online_migrations/command_checker.rb +0 -5
- data/lib/online_migrations/schema_statements.rb +6 -33
- data/lib/online_migrations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f0f48b03f81c0a92af100d5d547eefc241806204f0cc0a475eb528fed026037
|
4
|
+
data.tar.gz: 74f9246907e52d527c46f832e66ab4b4b74c89e0ea9492612a303a1d65f006c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55296987b866078354a39a06f431c360a18935803b852a5768549b3ae9f18bf8d27a3b0608086b1bf9c20ecaa006ea782ed7f128bd45c57d32bce50e8cc67e3
|
7
|
+
data.tar.gz: b57ae5030819e74eb891565fd87c77a1762ed1e3aa8f74ec4fba570f286150f6da500279f7bbea95cf7e0fb360dcf3acd491ee05e1ce8e635889549211d55bf8
|
data/CHANGELOG.md
CHANGED
@@ -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 =
|
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 =
|
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/
|
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
|
@@ -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
|
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
|
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.
|
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-
|
11
|
+
date: 2025-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|