online_migrations 0.19.0 → 0.19.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259343358d51032a296c3745f92aa0e7ab5fc8f2d5dc6cd124873876e523d525
|
4
|
+
data.tar.gz: d07240d06faac048145ae8f54da1a947d197f9ff40bb2adf276625eb76bcafb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c67adbf061095fdcbb5fcaa5305f671d81cf434dc182bfe9e43d66dae41f87d24cf5a79bb4aca160a955c74dff20de5e217b20731fe022df1dece6246e0239c0
|
7
|
+
data.tar.gz: 705397632e3afe3628776e854f74ff0ee70ada9d73d0d9e84c113289623d6240fc79b7823ca0dc05d3dab8dfd90c421c667b60ee394dbfb03c49afabd31ddc95
|
data/CHANGELOG.md
CHANGED
@@ -6,14 +6,24 @@ module OnlineMigrations
|
|
6
6
|
def add_index_in_background(table_name, column_name, **options)
|
7
7
|
migration_options = options.extract!(:max_attempts, :statement_timeout, :connection_class_name)
|
8
8
|
|
9
|
+
options[:algorithm] = :concurrently
|
10
|
+
index, algorithm, if_not_exists = add_index_options(table_name, column_name, **options)
|
11
|
+
|
12
|
+
# Need to check this first, because `index_exists?` does not check for `:where`s.
|
13
|
+
if index_name_exists?(table_name, index.name)
|
14
|
+
Utils.raise_or_say(<<~MSG)
|
15
|
+
Index creation was not enqueued because the index with name '#{index.name}' already exists.
|
16
|
+
This can be due to an aborted migration or you need to explicitly provide another name
|
17
|
+
via `:name` option.
|
18
|
+
MSG
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
9
22
|
if index_exists?(table_name, column_name, **options)
|
10
23
|
Utils.raise_or_say("Index creation was not enqueued because the index already exists.")
|
11
24
|
return
|
12
25
|
end
|
13
26
|
|
14
|
-
options[:algorithm] = :concurrently
|
15
|
-
index, algorithm, if_not_exists = add_index_options(table_name, column_name, **options)
|
16
|
-
|
17
27
|
create_index = ActiveRecord::ConnectionAdapters::CreateIndexDefinition.new(index, algorithm, if_not_exists)
|
18
28
|
schema_creation = ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaCreation.new(self)
|
19
29
|
definition = schema_creation.accept(create_index)
|
@@ -77,22 +87,21 @@ module OnlineMigrations
|
|
77
87
|
# @private
|
78
88
|
def create_background_schema_migration(migration_name, table_name, **options)
|
79
89
|
options.assert_valid_keys(:definition, :max_attempts, :statement_timeout, :connection_class_name)
|
80
|
-
migration = Migration.new(migration_name: migration_name, table_name: table_name, **options)
|
81
|
-
|
82
|
-
shards = Utils.shard_names(migration.connection_class)
|
83
|
-
if shards.size > 1
|
84
|
-
migration.children = shards.map do |shard|
|
85
|
-
child = migration.dup
|
86
|
-
child.shard = shard
|
87
|
-
child
|
88
|
-
end
|
89
90
|
|
90
|
-
|
91
|
-
|
91
|
+
Migration.find_or_create_by!(migration_name: migration_name, shard: nil) do |migration|
|
92
|
+
migration.assign_attributes(**options, table_name: table_name)
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
shards = Utils.shard_names(migration.connection_class)
|
95
|
+
if shards.size > 1
|
96
|
+
migration.children = shards.map do |shard|
|
97
|
+
child = migration.dup
|
98
|
+
child.shard = shard
|
99
|
+
child
|
100
|
+
end
|
101
|
+
|
102
|
+
migration.composite = true
|
103
|
+
end
|
104
|
+
end
|
96
105
|
end
|
97
106
|
end
|
98
107
|
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
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|