online_migrations 0.21.0 → 0.22.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 +9 -0
- data/lib/online_migrations/background_migrations/migration.rb +12 -0
- data/lib/online_migrations/background_migrations/scheduler.rb +7 -11
- data/lib/online_migrations/background_schema_migrations/migration.rb +12 -0
- 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: 493a3f1a84eb30974c533f81ca5baf8b739d69d4ec6e30810d891284791632f1
|
4
|
+
data.tar.gz: 9dae1370ea3073146888d3757314bac6c8e968c5e35a2c2be345f3617f610881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40cae89f1be37a97567d7bb05d1ded17479ce89b9783ed0c606d6bdfdec2d940d251de4de66557af774fc88e1262ae492539fe3fae5f4cb105d88526e7315d3
|
7
|
+
data.tar.gz: 26316851d405210a67576ea0ae35ba0419574832aacc43a2f0ddd00a8f22223f0d1ed73ff1635f6f9aa4168877c48aebb56d0f93f05472b531d80f3fc19881e9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 0.22.0 (2025-01-03)
|
4
|
+
|
5
|
+
- Make background data migrations scheduler run a single migration at a time
|
6
|
+
|
7
|
+
This is similar to background schema migrations scheduler's behavior.
|
8
|
+
Running multiple migrations at a time can cause unneeded database load and other bad effects.
|
9
|
+
|
10
|
+
- Add `#pausable?`, `#can_be_cancelled?` and `#can_be_paused?` helpers to background migrations
|
11
|
+
|
3
12
|
## 0.21.0 (2024-12-09)
|
4
13
|
|
5
14
|
- Fix `add_foreign_key` when referencing same table via different columns
|
@@ -110,6 +110,18 @@ module OnlineMigrations
|
|
110
110
|
end
|
111
111
|
alias cancel cancelled!
|
112
112
|
|
113
|
+
def pausable?
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
def can_be_paused?
|
118
|
+
enqueued? || running?
|
119
|
+
end
|
120
|
+
|
121
|
+
def can_be_cancelled?
|
122
|
+
!succeeded? && !cancelled?
|
123
|
+
end
|
124
|
+
|
113
125
|
def last_job
|
114
126
|
migration_jobs.order(:max_value).last
|
115
127
|
end
|
@@ -3,9 +3,10 @@
|
|
3
3
|
module OnlineMigrations
|
4
4
|
module BackgroundMigrations
|
5
5
|
# Class responsible for scheduling background migrations.
|
6
|
-
#
|
6
|
+
#
|
7
|
+
# It selects a single runnable background migration and runs it one step (one batch) at a time.
|
7
8
|
# A migration is considered runnable if it is not completed and the time interval between
|
8
|
-
#
|
9
|
+
# successive runs has passed.
|
9
10
|
#
|
10
11
|
# Scheduler should be configured to run periodically, for example, via cron.
|
11
12
|
# @example Run via whenever
|
@@ -22,18 +23,13 @@ module OnlineMigrations
|
|
22
23
|
# Runs Scheduler
|
23
24
|
def run
|
24
25
|
active_migrations = Migration.runnable.active.queue_order
|
25
|
-
|
26
|
+
runnable_migration = active_migrations.select(&:interval_elapsed?).first
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
def run_migration_job(migration)
|
34
|
-
runner = MigrationRunner.new(migration)
|
28
|
+
if runnable_migration
|
29
|
+
runner = MigrationRunner.new(runnable_migration)
|
35
30
|
runner.run_migration_job
|
36
31
|
end
|
32
|
+
end
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -94,6 +94,18 @@ module OnlineMigrations
|
|
94
94
|
end
|
95
95
|
alias cancel cancelled!
|
96
96
|
|
97
|
+
def pausable?
|
98
|
+
false
|
99
|
+
end
|
100
|
+
|
101
|
+
def can_be_paused?
|
102
|
+
false
|
103
|
+
end
|
104
|
+
|
105
|
+
def can_be_cancelled?
|
106
|
+
!succeeded? && !cancelled?
|
107
|
+
end
|
108
|
+
|
97
109
|
# Returns the progress of the background schema migration.
|
98
110
|
#
|
99
111
|
# @return [Float] value in range from 0.0 to 100.0
|
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.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|