online_migrations 0.19.2 → 0.19.3
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/schema_statements.rb +22 -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: 4d8223e51d4016b3752a738ecbc04cc200c94ee44dd3d91a1be2aefbc74060a9
|
4
|
+
data.tar.gz: bbaa8a04c4b730ac33e1503c59782658f6810f9782b4f882ab2b19bd0e0402d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 878031d1e81e5a069500e4c9c8f0d2bb9b9b60320e07ce101a7ae8680556a6a8114de4d0f6bf092340ec3651f9bbbb74fdc6e6453db39be3c22f6846b5a2ad94
|
7
|
+
data.tar.gz: 143a618f2d46a8a452c9f32ca87f44e47dffe5268bae00dcff008f54865cf272e20bb6aa4af7243cf642a195e64e9aed8269660f1658ebb3440bff12eeed37df
|
data/CHANGELOG.md
CHANGED
@@ -684,9 +684,17 @@ module OnlineMigrations
|
|
684
684
|
def add_index(table_name, column_name, **options)
|
685
685
|
__ensure_not_in_transaction! if options[:algorithm] == :concurrently
|
686
686
|
|
687
|
-
|
688
|
-
|
689
|
-
|
687
|
+
index =
|
688
|
+
if column_name.is_a?(String) && column_name.match?(/\W/)
|
689
|
+
# Use only name to check if index exists, because it does not work for complex expressions.
|
690
|
+
index_name = (options[:name] || index_name(table_name, column_name)).to_s
|
691
|
+
indexes(table_name).find { |i| i.name == index_name }
|
692
|
+
else
|
693
|
+
# Rewrite this with `IndexDefinition#defined_for?` when Active Record >= 7.1 is supported.
|
694
|
+
# See https://github.com/rails/rails/pull/45160.
|
695
|
+
indexes(table_name).find { |i| __index_defined_for?(i, column_name, **options) }
|
696
|
+
end
|
697
|
+
|
690
698
|
if index
|
691
699
|
schema = __schema_for_table(table_name)
|
692
700
|
|
@@ -729,7 +737,17 @@ module OnlineMigrations
|
|
729
737
|
|
730
738
|
__ensure_not_in_transaction! if options[:algorithm] == :concurrently
|
731
739
|
|
732
|
-
|
740
|
+
column = column_name || options[:column]
|
741
|
+
index_exists =
|
742
|
+
if column.is_a?(String) && column.match?(/\W/)
|
743
|
+
# Use only name to check if index exists, because it does not work for complex expressions.
|
744
|
+
index_name = options[:name] || index_name(table_name, column)
|
745
|
+
index_name_exists?(table_name, index_name)
|
746
|
+
else
|
747
|
+
index_exists?(table_name, column_name, **options)
|
748
|
+
end
|
749
|
+
|
750
|
+
if index_exists
|
733
751
|
if OnlineMigrations.config.statement_timeout
|
734
752
|
# "DROP INDEX CONCURRENTLY" requires a "SHARE UPDATE EXCLUSIVE" lock.
|
735
753
|
# It only conflicts with constraint validations, other creating/removing indexes,
|
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
|
+
version: 0.19.3
|
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
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|