online_migrations 0.24.0 → 0.26.0
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 +34 -0
- data/README.md +18 -73
- data/docs/background_schema_migrations.md +2 -1
- data/docs/configuring.md +8 -0
- data/lib/generators/online_migrations/templates/add_sharding_to_online_migrations.rb.tt +1 -1
- data/lib/generators/online_migrations/templates/add_timestamps_to_background_migrations.rb.tt +31 -0
- data/lib/generators/online_migrations/templates/background_schema_migrations_change_unique_index.rb.tt +1 -1
- data/lib/generators/online_migrations/templates/initializer.rb.tt +3 -0
- data/lib/generators/online_migrations/templates/install_migration.rb.tt +2 -0
- data/lib/generators/online_migrations/templates/migration.rb.tt +2 -2
- data/lib/generators/online_migrations/upgrade_generator.rb +4 -0
- data/lib/online_migrations/background_migrations/migration.rb +16 -22
- data/lib/online_migrations/background_migrations/migration_job.rb +8 -7
- data/lib/online_migrations/background_migrations/migration_job_runner.rb +3 -1
- data/lib/online_migrations/background_migrations/migration_job_status_validator.rb +2 -1
- data/lib/online_migrations/background_migrations/migration_runner.rb +13 -6
- data/lib/online_migrations/background_schema_migrations/migration.rb +30 -25
- data/lib/online_migrations/background_schema_migrations/migration_helpers.rb +1 -1
- data/lib/online_migrations/background_schema_migrations/migration_runner.rb +6 -2
- data/lib/online_migrations/background_schema_migrations/migration_status_validator.rb +6 -2
- data/lib/online_migrations/batch_iterator.rb +7 -4
- data/lib/online_migrations/change_column_type_helpers.rb +72 -12
- data/lib/online_migrations/command_checker.rb +32 -20
- data/lib/online_migrations/config.rb +8 -0
- data/lib/online_migrations/error_messages.rb +16 -0
- data/lib/online_migrations/index_definition.rb +1 -1
- data/lib/online_migrations/lock_retrier.rb +6 -9
- data/lib/online_migrations/migration.rb +8 -1
- data/lib/online_migrations/schema_cache.rb +0 -78
- data/lib/online_migrations/schema_statements.rb +20 -81
- data/lib/online_migrations/utils.rb +1 -20
- data/lib/online_migrations/verbose_sql_logs.rb +1 -7
- data/lib/online_migrations/version.rb +1 -1
- data/lib/online_migrations.rb +1 -8
- metadata +6 -5
@@ -69,23 +69,6 @@ module OnlineMigrations
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# Implementation is from ActiveRecord.
|
73
|
-
# This is not needed for ActiveRecord >= 7.1 (https://github.com/rails/rails/pull/47753).
|
74
|
-
def index_name(table_name, column_name)
|
75
|
-
max_index_name_size = 62
|
76
|
-
name = "index_#{table_name}_on_#{Array(column_name) * '_and_'}"
|
77
|
-
return name if name.bytesize <= max_index_name_size
|
78
|
-
|
79
|
-
# Fallback to short version, add hash to ensure uniqueness
|
80
|
-
hashed_identifier = "_#{OpenSSL::Digest::SHA256.hexdigest(name).first(10)}"
|
81
|
-
name = "idx_on_#{Array(column_name) * '_'}"
|
82
|
-
|
83
|
-
short_limit = max_index_name_size - hashed_identifier.bytesize
|
84
|
-
short_name = name[0, short_limit]
|
85
|
-
|
86
|
-
"#{short_name}#{hashed_identifier}"
|
87
|
-
end
|
88
|
-
|
89
72
|
# Returns estimated rows count for a table.
|
90
73
|
# https://www.citusdata.com/blog/2016/10/12/count-performance/
|
91
74
|
def estimated_count(connection, table_name)
|
@@ -144,9 +127,7 @@ module OnlineMigrations
|
|
144
127
|
# This is the way that currently is used in ActiveRecord tests themselves.
|
145
128
|
pool_manager = ActiveRecord::Base.connection_handler.send(:get_pool_manager, ancestor.name)
|
146
129
|
|
147
|
-
|
148
|
-
# See https://github.com/rails/rails/pull/49284.
|
149
|
-
return pool_manager.shard_names.uniq if pool_manager
|
130
|
+
return pool_manager.shard_names if pool_manager
|
150
131
|
end
|
151
132
|
end
|
152
133
|
|
@@ -14,13 +14,7 @@ module OnlineMigrations
|
|
14
14
|
stdout_logger.level = @activerecord_logger_was.level
|
15
15
|
stdout_logger = ActiveSupport::TaggedLogging.new(stdout_logger)
|
16
16
|
|
17
|
-
combined_logger =
|
18
|
-
# Broadcasting logs API was changed in https://github.com/rails/rails/pull/48615.
|
19
|
-
if Utils.ar_version >= 7.1
|
20
|
-
ActiveSupport::BroadcastLogger.new(stdout_logger, @activerecord_logger_was)
|
21
|
-
else
|
22
|
-
stdout_logger.extend(ActiveSupport::Logger.broadcast(@activerecord_logger_was))
|
23
|
-
end
|
17
|
+
combined_logger = ActiveSupport::BroadcastLogger.new(stdout_logger, @activerecord_logger_was)
|
24
18
|
|
25
19
|
ActiveRecord::Base.logger = combined_logger
|
26
20
|
ActiveRecord.verbose_query_logs = false
|
data/lib/online_migrations.rb
CHANGED
@@ -102,12 +102,7 @@ module OnlineMigrations
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def deprecator
|
105
|
-
@deprecator ||=
|
106
|
-
if Utils.ar_version >= 7.1
|
107
|
-
ActiveSupport::Deprecation.new(nil, "online_migrations")
|
108
|
-
else
|
109
|
-
ActiveSupport::Deprecation
|
110
|
-
end
|
105
|
+
@deprecator ||= ActiveSupport::Deprecation.new(nil, "online_migrations")
|
111
106
|
end
|
112
107
|
|
113
108
|
# @private
|
@@ -124,8 +119,6 @@ module OnlineMigrations
|
|
124
119
|
|
125
120
|
if OnlineMigrations::Utils.ar_version >= 7.2
|
126
121
|
ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache72)
|
127
|
-
elsif OnlineMigrations::Utils.ar_version >= 7.1
|
128
|
-
ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache71)
|
129
122
|
else
|
130
123
|
ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache)
|
131
124
|
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.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7.
|
19
|
+
version: '7.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '7.
|
26
|
+
version: '7.1'
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- fatkodima123@gmail.com
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/generators/online_migrations/background_migration_generator.rb
|
41
41
|
- lib/generators/online_migrations/install_generator.rb
|
42
42
|
- lib/generators/online_migrations/templates/add_sharding_to_online_migrations.rb.tt
|
43
|
+
- lib/generators/online_migrations/templates/add_timestamps_to_background_migrations.rb.tt
|
43
44
|
- lib/generators/online_migrations/templates/background_data_migration.rb.tt
|
44
45
|
- lib/generators/online_migrations/templates/background_schema_migrations_change_unique_index.rb.tt
|
45
46
|
- lib/generators/online_migrations/templates/create_background_schema_migrations.rb.tt
|
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
requirements:
|
107
108
|
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
110
|
+
version: '3.1'
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
requirements:
|
112
113
|
- - ">="
|