data-migration 1.0.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c310b238ffce7232c8d7e043b3bb05c22c7fc9feb1a202653172152e0eafe54f
4
- data.tar.gz: c177a8be4fb4805a0cdac0683ea2b1711f8e78df14176f271d834869c9d7eb0f
3
+ metadata.gz: 9a8f110139404aa9a93001f7d7d62df44dfa39ed17c6467c3042b71071f0f5a9
4
+ data.tar.gz: 17ea84c1d597d6ba5907f0841bee35cf231225f9ac6febfa0dfa4b6c697105d3
5
5
  SHA512:
6
- metadata.gz: 5c3653642986c3de1ac483875541c433f44fc604fe648dcf3b22a9065b16d0370b83c6a55ad20c7a41ed78dee646c14f69eacd9cf2f3f3fa49f7e9b8e944fb44
7
- data.tar.gz: f604aa6ac2c1993c04b7f993eabf4f56f81c0db9b1c0a892e46f390a75fe4c11a0f8d237b2e80de190b497a07b68d0f7e3d08b162682245234120e1e40a6e58f
6
+ metadata.gz: 2cb6a04608ff5fa007f3bc3e5e6fd819413d73b9041ee8ec542de029719d6c089706528e3ec72e9d0442d75596709cb2646f004c00bce6a9100a063be2e91eab
7
+ data.tar.gz: 53b024625cc45959ac7cc94c5ccb5bf22f1ff463a04cfea4f847a43292b688092aaf9f3e757193fd15c17c47f2a9539b208be3153e043cca313f3b78682ff36c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
- # 1.0.0
1
+ # CHANGELOG
2
+
3
+ ## 1.2.0
4
+
5
+ - Wrap Task.status enum with ActiveRecord version check
6
+
7
+ ## 1.1.0
8
+
9
+ - Fix gem main file name to be `data-migration.rb` instead of `data_migration.rb`
10
+
11
+ ## 1.0.0
2
12
 
3
13
  - Initial version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data-migration (1.0.0)
4
+ data-migration (1.2.0)
5
5
  activejob (> 5)
6
6
  activerecord (> 5)
7
7
  activesupport (> 5)
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/data_migration.rb | grep -Eo "[0-9.]{5,}")
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
@@ -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/data_migration.rb", __FILE__)).match(/VERSION\s*=\s*"(.*?)"/)[1]
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.0.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
data/spec/rails_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "active_record"
2
2
 
3
- require "data_migration"
3
+ require "data-migration"
4
4
 
5
5
  require "support/rails_helpers"
6
6
 
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,7 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
9
9
 
10
10
  require "active_record"
11
11
 
12
- require "data_migration"
12
+ require "data-migration"
13
13
 
14
14
  Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require_relative f }
15
15
 
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/data_migration.rb | grep -Eo "[0-9.]{5,}")
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.0.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-08 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
@@ -176,7 +176,7 @@ files:
176
176
  - LICENSE.md
177
177
  - README.md
178
178
  - data-migration.gemspec
179
- - lib/data_migration.rb
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