online_migrations 0.16.0 → 0.16.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: '0759df02ba803fe453e3f1f67eac92f73ad9c874a09aa5b9768c2dc82509af03'
|
4
|
+
data.tar.gz: 29772b85d1f2d414af140558790c365ec801bad2fc99fecc051704bfcc4d1ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e733e9e90c7e7f4f52a5811cce39856e5fce10c717a15dff2c9fe6fd5531cc19a00442cc44fd690ed3037e474a28abaf4e6a7c24cac380a4243365a3e4d8c5
|
7
|
+
data.tar.gz: f89156275fb3886d9405e00f4a8f8aa2c4b28808fa0ba3f2e4991d319fed8bc4cdd3bd54fc249577e3e13ea30dca5ed1cbb5d1dd56843e366674a752fe61e028
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 0.16.1 (2024-03-29)
|
4
|
+
|
5
|
+
- Improve error message when background schema migration name is already taken
|
6
|
+
- Fix copying column background migration to work with primary keys added via `initialize_column_type_change`
|
7
|
+
|
3
8
|
## 0.16.0 (2024-03-28)
|
4
9
|
|
5
10
|
- Add support for asynchronous creation/removal of indexes
|
@@ -57,9 +57,18 @@ module OnlineMigrations
|
|
57
57
|
belongs_to :parent, class_name: name, optional: true
|
58
58
|
has_many :children, class_name: name, foreign_key: :parent_id
|
59
59
|
|
60
|
-
validates :migration_name, presence: true, uniqueness: { scope: :shard }
|
61
60
|
validates :table_name, presence: true, length: { maximum: MAX_IDENTIFIER_LENGTH }
|
62
61
|
validates :definition, presence: true
|
62
|
+
validates :migration_name, presence: true, uniqueness: {
|
63
|
+
scope: :shard,
|
64
|
+
message: ->(object, data) do
|
65
|
+
message = "(#{data[:value]}) has already been taken."
|
66
|
+
if object.index_addition?
|
67
|
+
message += " Consider enqueuing index creation with a different index name via a `:name` option."
|
68
|
+
end
|
69
|
+
message
|
70
|
+
end,
|
71
|
+
}
|
63
72
|
|
64
73
|
validate :validate_children_statuses, if: -> { composite? && status_changed? }
|
65
74
|
validate :validate_connection_class, if: :connection_class_name?
|
@@ -107,6 +116,10 @@ module OnlineMigrations
|
|
107
116
|
end
|
108
117
|
end
|
109
118
|
|
119
|
+
def index_addition?
|
120
|
+
definition.match?(/create (unique )?index/i)
|
121
|
+
end
|
122
|
+
|
110
123
|
# @private
|
111
124
|
def connection_class
|
112
125
|
if connection_class_name && (klass = connection_class_name.safe_constantize)
|
@@ -130,8 +143,7 @@ module OnlineMigrations
|
|
130
143
|
statement_timeout = self.statement_timeout || OnlineMigrations.config.statement_timeout
|
131
144
|
|
132
145
|
with_statement_timeout(connection, statement_timeout) do
|
133
|
-
|
134
|
-
when /create (unique )?index/i
|
146
|
+
if index_addition?
|
135
147
|
index = connection.indexes(table_name).find { |i| i.name == name }
|
136
148
|
if index
|
137
149
|
# Use index validity from https://github.com/rails/rails/pull/45160
|