online_migrations 0.19.4 → 0.19.5

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: 6392ff9889da502701252f97a71e4fa8c3b403dc61aa010957a5b79221a9366b
4
- data.tar.gz: 1c880f23e20b142c335679701bdac977f089ac5ef076352a438e6dfa469b54cb
3
+ metadata.gz: 9cb60167b94f5ce8556b3f9835949c86f9be4c523eb2c35494de578dea31a2bf
4
+ data.tar.gz: 20d9d6fcf509bbc25987a2e3bce165c927cacd03502aa908c02aba37dd284774
5
5
  SHA512:
6
- metadata.gz: 30f7c9ed855f97180ba1b4f9c90f717f58ad9198fbd90f1b80b914b35994a2b863499239263878115d220413927ca3f5a05519e917b66335a346607b19a8f2ab
7
- data.tar.gz: 271a237cb9df14677ed5c364c6c90657a6726347ae94b6992ad37c468b0bf59a76e51c0a1b79f187264d2369637e6c6de83d454d6f8c1c368648640c5ee23068
6
+ metadata.gz: 03f82fe701b6d2145963f1f2220ac9ed127dc826885455134afc3bb547197d21a1c0307156b6d8b5402c0a521332328eebf45d96a3bb2183804055d866cd3af2
7
+ data.tar.gz: 94f0bfd73299897757a8b836a9cbd995bb9313c971a6e0076079b783955c26da239098b84df391096128fc0e060ba66ca69e61e16a84013c12d613c7fe4064ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 0.19.5 (2024-09-20)
4
+
5
+ - Fix `add_reference_concurrently` when adding polymorphic references
6
+
3
7
  ## 0.19.4 (2024-09-02)
4
8
 
5
9
  - Fix an edge case for background schema migrations
@@ -647,21 +647,29 @@ module OnlineMigrations
647
647
  __ensure_not_in_transaction!
648
648
 
649
649
  column_name = "#{ref_name}_id"
650
+ type_column_name = "#{ref_name}_type"
651
+
650
652
  if !column_exists?(table_name, column_name)
651
653
  type = options[:type] || :bigint
652
654
  allow_null = options.fetch(:null, true)
653
655
  add_column(table_name, column_name, type, null: allow_null)
654
656
  end
655
657
 
658
+ if !column_exists?(table_name, type_column_name)
659
+ allow_null = options[:polymorphic].is_a?(Hash) ? options[:polymorphic][:null] : true
660
+ add_column(table_name, type_column_name, :string, null: allow_null)
661
+ end
662
+
656
663
  # Always added by default in 5.0+
657
664
  index = options.fetch(:index, true)
658
665
 
659
666
  if index
660
667
  index = {} if index == true
661
668
  index_columns = [column_name]
669
+
662
670
  if options[:polymorphic]
671
+ index_columns.unshift(type_column_name)
663
672
  index[:name] ||= "index_#{table_name}_on_#{ref_name}"
664
- index_columns.unshift("#{ref_name}_type")
665
673
  end
666
674
 
667
675
  add_index(table_name, index_columns, **index.merge(algorithm: :concurrently))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.19.4"
4
+ VERSION = "0.19.5"
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.19.4
4
+ version: 0.19.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord