data-migration 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37438001715cc268d2f647d68ee27c6a49d3a4c879187d61a2779523b1d34fb9
4
- data.tar.gz: 55d7277c0848aa1395ab004ec986a3d268e18feebbe5fdbe7766b5658ef2a561
3
+ metadata.gz: 9a8f110139404aa9a93001f7d7d62df44dfa39ed17c6467c3042b71071f0f5a9
4
+ data.tar.gz: 17ea84c1d597d6ba5907f0841bee35cf231225f9ac6febfa0dfa4b6c697105d3
5
5
  SHA512:
6
- metadata.gz: 1d655d2e86118b04fdb4f778e3afa611caab5dc95bd048e71f24baf6235b4c7c8fad1cdc2a70d8a15fb6f5491f942d7f272f91bb2b618f9e1541dfae4a443310
7
- data.tar.gz: 72542f7c60d054c70b62b39468edb645c1a3cf777ea07fd30ca710f90bdc9aa8ca66d89979ace38ed2eb48f97740757c836cda7a31169e83031a7b84609c542c
6
+ metadata.gz: 2cb6a04608ff5fa007f3bc3e5e6fd819413d73b9041ee8ec542de029719d6c089706528e3ec72e9d0442d75596709cb2646f004c00bce6a9100a063be2e91eab
7
+ data.tar.gz: 53b024625cc45959ac7cc94c5ccb5bf22f1ff463a04cfea4f847a43292b688092aaf9f3e757193fd15c17c47f2a9539b208be3153e043cca313f3b78682ff36c
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
- # 1.1.0
1
+ # CHANGELOG
2
+
3
+ ## 1.2.0
4
+
5
+ - Wrap Task.status enum with ActiveRecord version check
6
+
7
+ ## 1.1.0
2
8
 
3
9
  - Fix gem main file name to be `data-migration.rb` instead of `data_migration.rb`
4
10
 
5
- # 1.0.0
11
+ ## 1.0.0
6
12
 
7
13
  - Initial version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data-migration (1.1.0)
4
+ data-migration (1.2.0)
5
5
  activejob (> 5)
6
6
  activerecord (> 5)
7
7
  activesupport (> 5)
@@ -3,7 +3,7 @@ require "data_migration/job"
3
3
  require "data_migration/task"
4
4
 
5
5
  module DataMigration
6
- VERSION = "1.1.0".freeze
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 block_given?
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 block_given?
53
+ if block.present?
54
54
  @monitoring_context = block
55
55
  else
56
56
  @monitoring_context ||= ->(migration) do
@@ -18,7 +18,7 @@ module DataMigration
18
18
  return
19
19
  end
20
20
 
21
- task.job_check_in!(job_id, job_args:, job_kwargs:)
21
+ task.job_check_in!(job_id, job_args: job_args, job_kwargs: job_kwargs)
22
22
 
23
23
  require migration_path
24
24
  klass_name = migration_name.gsub(/^[0-9_]+/, "").camelize
@@ -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
- enum :status, {
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: { greater_than_or_equal_to: 0, only_integer: true }, if: -> { pause_minutes.present? }
30
- validates :jobs_limit, numericality: { greater_than_or_equal_to: 0, only_integer: true }, if: -> { jobs_limit.present? }
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:, pause_minutes:, jobs_limit:)
77
+ create!(name: name, pause_minutes: pause_minutes, jobs_limit: jobs_limit)
72
78
  end
73
79
 
74
80
  def self.root_path
@@ -4,6 +4,6 @@ class CreateBatchUsers
4
4
 
5
5
  User.find_or_create_by(email: "test_#{index}@example.com")
6
6
 
7
- enqueue(index: index + 1, background:)
7
+ enqueue(index: index + 1, background: background)
8
8
  end
9
9
  end
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.1.0
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-09 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails