online_migrations 0.20.1 → 0.20.2
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 +4 -0
- data/lib/online_migrations/batch_iterator.rb +2 -1
- data/lib/online_migrations/change_column_type_helpers.rb +4 -4
- data/lib/online_migrations/command_checker.rb +7 -7
- data/lib/online_migrations/schema_statements.rb +3 -3
- 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: 99da2eb272335cb229fa18c23cc0fc93b79748fae109b3cde140a5e6fad633d8
|
4
|
+
data.tar.gz: 0c9aafb1960a77604aa1e6025f223176ade5a3276392fc62db64af231e265ac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09e4ccdc1f431dd3ab4fd45df8674d77f53cdc4be5d07804b988718628cc832981fa966b194da3ca95fb615a835d83a4993a9a208ae97abec1f10d3669599af9'
|
7
|
+
data.tar.gz: 895d01e0913c053fcf1bdda4fbef545049fd3810a90c2610060483727d6143366e42c4b4def0274c593294afd980bb3102473d459a22fcdce2e06638065c1464
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
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.
|
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-
|
11
|
+
date: 2024-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|