online_migrations 0.11.0 → 0.11.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08a823ebaea1855fcfaae87c3252cbc4a727f04ae564cd14cfcb8e2f43ebb2b
|
4
|
+
data.tar.gz: f02621f945b90de34217f588d26a243b506bc47c9433feab784b8db43ecd83de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb01d066a03e7bb85c6d6e37f6c3e67351dc1a890579d9eb4c8ef7a200785918c863a7b2f1104a1d531772da0405daa1f9724cad6b224a92da08fba3fac2479
|
7
|
+
data.tar.gz: 21acc8fbfb9a2aab13d5768f1df613d74e9145d55148bdb8b04b53e5687bca9fd0e6f88178282dec9f0642fdad2fd188e979d152b697b771554adf866aa417e3
|
data/CHANGELOG.md
CHANGED
@@ -102,9 +102,15 @@ module OnlineMigrations
|
|
102
102
|
if succeeded?
|
103
103
|
100.0
|
104
104
|
elsif composite?
|
105
|
-
|
106
|
-
if
|
107
|
-
|
105
|
+
rows_counts = children.to_a.pluck(:rows_count)
|
106
|
+
if rows_counts.none?(nil)
|
107
|
+
total_rows_count = rows_counts.sum
|
108
|
+
|
109
|
+
progresses = children.map do |child|
|
110
|
+
child.progress * child.rows_count / total_rows_count # weighted progress
|
111
|
+
end
|
112
|
+
|
113
|
+
progresses.sum.round(2)
|
108
114
|
end
|
109
115
|
elsif rows_count
|
110
116
|
jobs_rows_count = migration_jobs.succeeded.sum(:batch_size)
|
@@ -181,15 +187,17 @@ module OnlineMigrations
|
|
181
187
|
iterator = BatchIterator.new(migration_relation)
|
182
188
|
batch_range = nil
|
183
189
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
190
|
+
on_shard do
|
191
|
+
# rubocop:disable Lint/UnreachableLoop
|
192
|
+
iterator.each_batch(of: batch_size, column: batch_column_name, start: next_min_value) do |relation|
|
193
|
+
min = relation.arel_table[batch_column_name].minimum
|
194
|
+
max = relation.arel_table[batch_column_name].maximum
|
195
|
+
batch_range = relation.pick(min, max)
|
189
196
|
|
190
|
-
|
197
|
+
break
|
198
|
+
end
|
199
|
+
# rubocop:enable Lint/UnreachableLoop
|
191
200
|
end
|
192
|
-
# rubocop:enable Lint/UnreachableLoop
|
193
201
|
|
194
202
|
return if batch_range.nil?
|
195
203
|
|
@@ -286,7 +294,7 @@ module OnlineMigrations
|
|
286
294
|
attributes.each do |attribute|
|
287
295
|
updates[attribute] = read_attribute(attribute) if attribute_changed?(attribute)
|
288
296
|
end
|
289
|
-
children.update_all(updates) if updates.any?
|
297
|
+
children.active.update_all(updates) if updates.any?
|
290
298
|
end
|
291
299
|
|
292
300
|
def next_min_value
|
@@ -14,10 +14,7 @@ module OnlineMigrations
|
|
14
14
|
def run_migration_job
|
15
15
|
raise "Should not be called on a composite (with sharding) migration" if migration.composite?
|
16
16
|
|
17
|
-
if migration.enqueued?
|
18
|
-
migration.running!
|
19
|
-
migration.parent.running! if migration.parent && migration.parent.enqueued?
|
20
|
-
end
|
17
|
+
mark_as_running if migration.enqueued?
|
21
18
|
migration_payload = notifications_payload(migration)
|
22
19
|
|
23
20
|
if !migration.migration_jobs.exists?
|
@@ -57,7 +54,7 @@ module OnlineMigrations
|
|
57
54
|
raise "This method is not intended for use in production environments" if !Utils.developer_env?
|
58
55
|
return if migration.completed?
|
59
56
|
|
60
|
-
|
57
|
+
mark_as_running
|
61
58
|
|
62
59
|
if migration.composite?
|
63
60
|
migration.children.each do |child_migration|
|
@@ -96,6 +93,11 @@ module OnlineMigrations
|
|
96
93
|
end
|
97
94
|
|
98
95
|
private
|
96
|
+
def mark_as_running
|
97
|
+
migration.running!
|
98
|
+
migration.parent.running! if migration.parent && migration.parent.enqueued?
|
99
|
+
end
|
100
|
+
|
99
101
|
def should_throttle?
|
100
102
|
::OnlineMigrations.config.background_migrations.throttler.call
|
101
103
|
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.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.4
|
107
|
+
rubygems_version: 3.5.4
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Catch unsafe PostgreSQL migrations in development and run them easier in
|