online_migrations 0.20.1 → 0.20.2

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: 2fd0059b044a120c61044268bfc32c3622163ae1871f85655ae51fe3cfb99c60
4
- data.tar.gz: 1e1842002d3d229014011ee2a6af8eb122eaa7a6822912bec2d276f67e6555b4
3
+ metadata.gz: 99da2eb272335cb229fa18c23cc0fc93b79748fae109b3cde140a5e6fad633d8
4
+ data.tar.gz: 0c9aafb1960a77604aa1e6025f223176ade5a3276392fc62db64af231e265ac7
5
5
  SHA512:
6
- metadata.gz: 590aa0a0d36f94316cf02c0b3c8ec2dcf7be08e17cd687eb889d6fb9d8a4cfc892424cffb49c1988691720a7cbede5d58f1a2e712a0ddd8ab8545ce6df6395ed
7
- data.tar.gz: a981da87aae5a6e0a5872be04ec9839285fa6b53693c73a4f8ceac354d30f5623d7aef473a8d5c07992e14654083253d3603881f031877692c6718c8f5588407
6
+ metadata.gz: '09e4ccdc1f431dd3ab4fd45df8674d77f53cdc4be5d07804b988718628cc832981fa966b194da3ca95fb615a835d83a4993a9a208ae97abec1f10d3669599af9'
7
+ data.tar.gz: 895d01e0913c053fcf1bdda4fbef545049fd3810a90c2610060483727d6143366e42c4b4def0274c593294afd980bb3102473d459a22fcdce2e06638065c1464
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.20.2 (2024-11-11)
4
+
5
+ - Fix running background migrations over relations with duplicate records
6
+
3
7
  ## 0.20.1 (2024-11-05)
4
8
 
5
9
  - Fix background data migrations to work with `includes`/`eager_load` on relation
@@ -75,9 +75,10 @@ module OnlineMigrations
75
75
  # Retaining the results in the query cache would undermine the point of batching.
76
76
  batch_relation.uncached { yield batch_relation, start_id, last_id }
77
77
 
78
- break if stop_row.nil?
78
+ break if last_id == finish
79
79
 
80
80
  start_id = stop_id
81
+ stop_id = nil
81
82
  end
82
83
  end
83
84
 
@@ -126,15 +126,15 @@ module OnlineMigrations
126
126
  # To avoid this, we instead set it to `NOT NULL DEFAULT 0` and we'll
127
127
  # copy the correct values when backfilling.
128
128
  add_column(table_name, tmp_column_name, new_type,
129
- **old_col_options.merge(column_options).merge(default: old_col.default || 0, null: false))
129
+ **old_col_options, **column_options, default: old_col.default || 0, null: false)
130
130
  else
131
131
  if !old_col.default.nil?
132
132
  old_col_options = old_col_options.merge(default: old_col.default, null: old_col.null)
133
133
  end
134
- add_column(table_name, tmp_column_name, new_type, **old_col_options.merge(column_options))
134
+ add_column(table_name, tmp_column_name, new_type, **old_col_options, **column_options)
135
135
  end
136
136
  else
137
- add_column(table_name, tmp_column_name, new_type, **old_col_options.merge(column_options))
137
+ add_column(table_name, tmp_column_name, new_type, **old_col_options, **column_options)
138
138
  change_column_default(table_name, tmp_column_name, old_col.default) if !old_col.default.nil?
139
139
  end
140
140
  end
@@ -434,7 +434,7 @@ module OnlineMigrations
434
434
  options[:opclass] = opclasses
435
435
  end
436
436
 
437
- add_index(table_name, new_columns, **options.merge(algorithm: :concurrently))
437
+ add_index(table_name, new_columns, **options, algorithm: :concurrently)
438
438
  end
439
439
  end
440
440
 
@@ -553,7 +553,7 @@ module OnlineMigrations
553
553
  if !new_or_small_table?(table_name)
554
554
  if options[:algorithm] != :concurrently
555
555
  raise_error :add_index,
556
- command: command_str(:add_index, table_name, column_name, **options.merge(algorithm: :concurrently))
556
+ command: command_str(:add_index, table_name, column_name, **options, algorithm: :concurrently)
557
557
  end
558
558
 
559
559
  if options[:algorithm] == :concurrently && index_corruption?
@@ -585,7 +585,7 @@ module OnlineMigrations
585
585
 
586
586
  if options[:algorithm] != :concurrently && !new_or_small_table?(table_name)
587
587
  raise_error :remove_index,
588
- command: command_str(:remove_index, table_name, **options.merge(algorithm: :concurrently))
588
+ command: command_str(:remove_index, table_name, **options, algorithm: :concurrently)
589
589
  end
590
590
 
591
591
  index_def = connection.indexes(table_name).find do |index|
@@ -608,7 +608,7 @@ module OnlineMigrations
608
608
 
609
609
  if validate
610
610
  raise_error :add_foreign_key,
611
- add_code: command_str(:add_foreign_key, from_table, to_table, **options.merge(validate: false)),
611
+ add_code: command_str(:add_foreign_key, from_table, to_table, **options, validate: false),
612
612
  validate_code: command_str(:validate_foreign_key, from_table, to_table)
613
613
  end
614
614
  end
@@ -633,7 +633,7 @@ module OnlineMigrations
633
633
  name = options[:name] || check_constraint_name(table_name, expression)
634
634
 
635
635
  raise_error :add_check_constraint,
636
- add_code: command_str(:add_check_constraint, table_name, expression, **options.merge(validate: false)),
636
+ add_code: command_str(:add_check_constraint, table_name, expression, **options, validate: false),
637
637
  validate_code: command_str(:validate_check_constraint, table_name, name: name)
638
638
  end
639
639
  end
@@ -645,7 +645,7 @@ module OnlineMigrations
645
645
 
646
646
  raise_error :add_unique_constraint,
647
647
  add_index_code: command_str(:add_index, table_name, column_name, unique: true, name: index_name, algorithm: :concurrently),
648
- add_code: command_str(:add_unique_constraint, table_name, **options.merge(using_index: index_name)),
648
+ add_code: command_str(:add_unique_constraint, table_name, **options, using_index: index_name),
649
649
  remove_code: command_str(:remove_unique_constraint, table_name, column_name)
650
650
  end
651
651
 
@@ -661,7 +661,7 @@ module OnlineMigrations
661
661
  def add_not_null_constraint(table_name, column_name, **options)
662
662
  if !new_or_small_table?(table_name) && options[:validate] != false
663
663
  raise_error :add_not_null_constraint,
664
- add_code: command_str(:add_not_null_constraint, table_name, column_name, **options.merge(validate: false)),
664
+ add_code: command_str(:add_not_null_constraint, table_name, column_name, **options, validate: false),
665
665
  validate_code: command_str(:validate_not_null_constraint, table_name, column_name, **options.except(:validate))
666
666
  end
667
667
  end
@@ -669,7 +669,7 @@ module OnlineMigrations
669
669
  def add_text_limit_constraint(table_name, column_name, limit, **options)
670
670
  if !new_or_small_table?(table_name) && options[:validate] != false
671
671
  raise_error :add_text_limit_constraint,
672
- add_code: command_str(:add_text_limit_constraint, table_name, column_name, limit, **options.merge(validate: false)),
672
+ add_code: command_str(:add_text_limit_constraint, table_name, column_name, limit, **options, validate: false),
673
673
  validate_code: command_str(:validate_text_limit_constraint, table_name, column_name, **options.except(:validate))
674
674
  end
675
675
  end
@@ -451,7 +451,7 @@ module OnlineMigrations
451
451
  "or similar) table_name: #{table_name}, column_name: #{column_name}")
452
452
  else
453
453
  transaction do
454
- add_column(table_name, column_name, type, **options.merge(default: nil, null: true))
454
+ add_column(table_name, column_name, type, **options, default: nil, null: true)
455
455
  change_column_default(table_name, column_name, default)
456
456
  end
457
457
  end
@@ -672,7 +672,7 @@ module OnlineMigrations
672
672
  index[:name] ||= "index_#{table_name}_on_#{ref_name}"
673
673
  end
674
674
 
675
- add_index(table_name, index_columns, **index.merge(algorithm: :concurrently))
675
+ add_index(table_name, index_columns, **index, algorithm: :concurrently)
676
676
  end
677
677
 
678
678
  foreign_key = options[:foreign_key]
@@ -681,7 +681,7 @@ module OnlineMigrations
681
681
  foreign_key = {} if foreign_key == true
682
682
 
683
683
  foreign_table_name = Utils.foreign_table_name(ref_name, foreign_key)
684
- add_foreign_key(table_name, foreign_table_name, **foreign_key.merge(column: column_name, validate: false))
684
+ add_foreign_key(table_name, foreign_table_name, **foreign_key, column: column_name, validate: false)
685
685
 
686
686
  if foreign_key[:validate] != false
687
687
  validate_foreign_key(table_name, foreign_table_name, **foreign_key)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.20.1"
4
+ VERSION = "0.20.2"
5
5
  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.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-05 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord