online_migrations 0.9.0 → 0.9.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 +8 -0
- data/lib/online_migrations/change_column_type_helpers.rb +16 -4
- 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: 579a0db844c82c2c9153a1a3f44bfcffe929011112b132afe73b1dfdf68f4583
|
4
|
+
data.tar.gz: b88f26034f0c1d044607ef191ca3feae71e3c6093cb05bd9a277790447da01af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 229a2a31c44a358425a684ea8d1771d98ecee6412c9b4480e30e2cd68e53c0c9e77039959fa8f379ad0a83fb9f592d133d29fe43e2c79ae4dbf674cd9c210598
|
7
|
+
data.tar.gz: 9255d5ad7b7d350021cc553b5d91bec852cfbecc0b9c7d6296606beffae266de72096cdf5a4d12dd88d921fb0af60a9e870d08a676a90fad552c5bd2d36096f6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 0.9.2 (2023-11-02)
|
4
|
+
|
5
|
+
- Fix checking which expression indexes to copy when changing column type
|
6
|
+
|
7
|
+
## 0.9.1 (2023-10-30)
|
8
|
+
|
9
|
+
- Fix copying expression indexes when changing column type
|
10
|
+
|
3
11
|
## 0.9.0 (2023-10-27)
|
4
12
|
|
5
13
|
- Add ability to use custom raw sql for `backfill_column_for_type_change`'s `type_cast_function`
|
@@ -405,9 +405,15 @@ module OnlineMigrations
|
|
405
405
|
to_column = to_column.to_s
|
406
406
|
|
407
407
|
__indexes_for(table_name, from_column).each do |index|
|
408
|
-
new_columns =
|
409
|
-
|
410
|
-
|
408
|
+
new_columns =
|
409
|
+
# Expression index.
|
410
|
+
if index.columns.is_a?(String)
|
411
|
+
index.columns.gsub(/\b#{from_column}\b/, to_column)
|
412
|
+
else
|
413
|
+
index.columns.map do |column|
|
414
|
+
column == from_column ? to_column : column
|
415
|
+
end
|
416
|
+
end
|
411
417
|
|
412
418
|
# This is necessary as we can't properly rename indexes such as "taggings_idx".
|
413
419
|
if !index.name.include?(from_column)
|
@@ -444,7 +450,13 @@ module OnlineMigrations
|
|
444
450
|
def __indexes_for(table_name, column_name)
|
445
451
|
column_name = column_name.to_s
|
446
452
|
|
447
|
-
indexes(table_name).select
|
453
|
+
indexes(table_name).select do |index|
|
454
|
+
if index.columns.is_a?(String)
|
455
|
+
index.columns =~ /\b#{column_name}\b/
|
456
|
+
else
|
457
|
+
index.columns.include?(column_name)
|
458
|
+
end
|
459
|
+
end
|
448
460
|
end
|
449
461
|
|
450
462
|
# While its rare for a column to have multiple foreign keys, PostgreSQL supports this.
|
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.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|