data-migration 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/data-migration.gemspec +1 -1
- data/lib/{data_migration.rb → data-migration.rb} +2 -2
- data/lib/data_migration/config.rb +2 -2
- data/lib/data_migration/job.rb +1 -1
- data/lib/data_migration/task.rb +12 -6
- data/spec/fixtures/data_migrations/20241206200114_create_batch_users.rb +1 -1
- data/spec/rails_helper.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/usr/bin/release.sh +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8f110139404aa9a93001f7d7d62df44dfa39ed17c6467c3042b71071f0f5a9
|
4
|
+
data.tar.gz: 17ea84c1d597d6ba5907f0841bee35cf231225f9ac6febfa0dfa4b6c697105d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb6a04608ff5fa007f3bc3e5e6fd819413d73b9041ee8ec542de029719d6c089706528e3ec72e9d0442d75596709cb2646f004c00bce6a9100a063be2e91eab
|
7
|
+
data.tar.gz: 53b024625cc45959ac7cc94c5ccb5bf22f1ff463a04cfea4f847a43292b688092aaf9f3e757193fd15c17c47f2a9539b208be3153e043cca313f3b78682ff36c
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -129,7 +129,7 @@ Contribution policy:
|
|
129
129
|
Prefer using script `usr/bin/release.sh`, it will ensure that repository is synced and after publishing gem will create a tag.
|
130
130
|
|
131
131
|
```sh
|
132
|
-
GEM_VERSION=$(grep -Eo "VERSION\s*=\s*\".+\"" lib/
|
132
|
+
GEM_VERSION=$(grep -Eo "VERSION\s*=\s*\".+\"" lib/data-migration.rb | grep -Eo "[0-9.]{5,}")
|
133
133
|
rm data-migration-*.gem
|
134
134
|
gem build data-migration.gemspec
|
135
135
|
gem push data-migration-$GEM_VERSION.gem
|
data/data-migration.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "data-migration"
|
3
|
-
gem.version = File.read(File.expand_path("../lib/
|
3
|
+
gem.version = File.read(File.expand_path("../lib/data-migration.rb", __FILE__)).match(/VERSION\s*=\s*"(.*?)"/)[1]
|
4
4
|
|
5
5
|
repository_url = "https://github.com/amkisko/data-migration.rb"
|
6
6
|
root_files = %w[CHANGELOG.md LICENSE.md README.md]
|
@@ -3,7 +3,7 @@ require "data_migration/job"
|
|
3
3
|
require "data_migration/task"
|
4
4
|
|
5
5
|
module DataMigration
|
6
|
-
VERSION = "1.
|
6
|
+
VERSION = "1.2.0".freeze
|
7
7
|
|
8
8
|
module_function
|
9
9
|
|
@@ -17,7 +17,7 @@ module DataMigration
|
|
17
17
|
|
18
18
|
def notify(message, context: {})
|
19
19
|
if Object.const_defined?(:ActionReporter)
|
20
|
-
ActionReporter.notify(message, context:)
|
20
|
+
ActionReporter.notify(message, context: context.presence || {})
|
21
21
|
elsif Object.const_defined?(:Rails)
|
22
22
|
Rails.logger.info("#{message} #{context.inspect}")
|
23
23
|
end
|
@@ -35,7 +35,7 @@ module DataMigration
|
|
35
35
|
|
36
36
|
attr_writer :operator_resolver
|
37
37
|
def operator_resolver(&block)
|
38
|
-
if
|
38
|
+
if block.present?
|
39
39
|
@operator_resolver = block
|
40
40
|
else
|
41
41
|
@operator_resolver ||= -> do
|
@@ -50,7 +50,7 @@ module DataMigration
|
|
50
50
|
|
51
51
|
attr_writer :monitoring_context
|
52
52
|
def monitoring_context(&block)
|
53
|
-
if
|
53
|
+
if block.present?
|
54
54
|
@monitoring_context = block
|
55
55
|
else
|
56
56
|
@monitoring_context ||= ->(migration) do
|
data/lib/data_migration/job.rb
CHANGED
data/lib/data_migration/task.rb
CHANGED
@@ -2,6 +2,7 @@ require "active_record"
|
|
2
2
|
|
3
3
|
module DataMigration
|
4
4
|
class JobConcurrencyLimitError < StandardError; end
|
5
|
+
|
5
6
|
class JobConflictError < StandardError; end
|
6
7
|
|
7
8
|
def self.tasks_table_name
|
@@ -18,16 +19,21 @@ module DataMigration
|
|
18
19
|
self.jobs_limit ||= DataMigration.config.default_jobs_limit
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
+
STATUS_OPTIONS = {
|
22
23
|
started: "started",
|
23
24
|
performing: "performing",
|
24
25
|
paused: "paused",
|
25
26
|
completed: "completed"
|
26
27
|
}
|
28
|
+
if ActiveRecord::VERSION::MAJOR >= 7
|
29
|
+
enum :status, STATUS_OPTIONS
|
30
|
+
else
|
31
|
+
enum status: STATUS_OPTIONS
|
32
|
+
end
|
27
33
|
|
28
34
|
validates :name, presence: true
|
29
|
-
validates :pause_minutes, numericality: {
|
30
|
-
validates :jobs_limit, numericality: {
|
35
|
+
validates :pause_minutes, numericality: {greater_than_or_equal_to: 0, only_integer: true}, if: -> { pause_minutes.present? }
|
36
|
+
validates :jobs_limit, numericality: {greater_than_or_equal_to: 0, only_integer: true}, if: -> { jobs_limit.present? }
|
31
37
|
validate :file_should_exist
|
32
38
|
|
33
39
|
after_save do
|
@@ -50,7 +56,7 @@ module DataMigration
|
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.perform_now(name, **kwargs)
|
53
|
-
create!(name:).perform_now(**kwargs)
|
59
|
+
create!(name: name).perform_now(**kwargs)
|
54
60
|
end
|
55
61
|
|
56
62
|
def perform_now(**perform_args)
|
@@ -59,7 +65,7 @@ module DataMigration
|
|
59
65
|
end
|
60
66
|
|
61
67
|
def self.perform_later(name, **kwargs)
|
62
|
-
create!(name:).perform_later(**kwargs)
|
68
|
+
create!(name: name).perform_later(**kwargs)
|
63
69
|
end
|
64
70
|
|
65
71
|
def perform_later(**perform_args)
|
@@ -68,7 +74,7 @@ module DataMigration
|
|
68
74
|
end
|
69
75
|
|
70
76
|
def self.prepare(name, pause_minutes: nil, jobs_limit: nil)
|
71
|
-
create!(name
|
77
|
+
create!(name: name, pause_minutes: pause_minutes, jobs_limit: jobs_limit)
|
72
78
|
end
|
73
79
|
|
74
80
|
def self.root_path
|
data/spec/rails_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/usr/bin/release.sh
CHANGED
@@ -18,7 +18,7 @@ if [[ $(git diff --shortstat 2>/dev/null | tail -n1) != "" ]]; then
|
|
18
18
|
fi
|
19
19
|
|
20
20
|
GEM_NAME="data-migration"
|
21
|
-
VERSION=$(grep -Eo "VERSION\s*=\s*\".+\"" lib/
|
21
|
+
VERSION=$(grep -Eo "VERSION\s*=\s*\".+\"" lib/data-migration.rb | grep -Eo "[0-9.]{5,}")
|
22
22
|
GEM_FILE="$GEM_NAME-$VERSION.gem"
|
23
23
|
|
24
24
|
e "gem build $GEM_NAME.gemspec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data-migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Makarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -176,7 +176,7 @@ files:
|
|
176
176
|
- LICENSE.md
|
177
177
|
- README.md
|
178
178
|
- data-migration.gemspec
|
179
|
-
- lib/
|
179
|
+
- lib/data-migration.rb
|
180
180
|
- lib/data_migration/config.rb
|
181
181
|
- lib/data_migration/job.rb
|
182
182
|
- lib/data_migration/task.rb
|