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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f7396712072756a2c7de52a7057f0c46da8ce26bf59270f0f2dea42bf43d0b3
4
- data.tar.gz: a3a26397aa2a279e996e8af2e7c698ebabc73ee38bad89b84e98cbddb609feb4
3
+ metadata.gz: 579a0db844c82c2c9153a1a3f44bfcffe929011112b132afe73b1dfdf68f4583
4
+ data.tar.gz: b88f26034f0c1d044607ef191ca3feae71e3c6093cb05bd9a277790447da01af
5
5
  SHA512:
6
- metadata.gz: d897c787f1b4e23436ecc362dd49a97eba529e7f0613fe71d38b4fde1cd740a40e0fa6ba2ef59d32f0ab6c1050ebc98728a1830d22679f98671305e1d82d6eb3
7
- data.tar.gz: 10c2d6cc695042052c994111f71df5e19d17cf2b81a72b4ca2bce835ecced1a91dad0bfe5d2091079661c1d97dbbf066e641b80ceca196be7dd5c0e859f8ea09
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 = index.columns.map do |column|
409
- column == from_column ? to_column : column
410
- end
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 { |index| index.columns.include?(column_name) }
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.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.9.0
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-10-26 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord