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: 48ddbce66257c9010d8ab7361d8860cd898854207b5a1f4c6aa2b6b797aec2e1
4
- data.tar.gz: c21fbb5f535f788e13068e339eebe77f05a378c68c00244c4522a10d50a28a0d
3
+ metadata.gz: '0759df02ba803fe453e3f1f67eac92f73ad9c874a09aa5b9768c2dc82509af03'
4
+ data.tar.gz: 29772b85d1f2d414af140558790c365ec801bad2fc99fecc051704bfcc4d1ca9
5
5
  SHA512:
6
- metadata.gz: a5bbff2a8cca45e5fce79d653db3246bc41a4ab9d314f44131bbf74f2659d610fdaf3e87ac5e22baf7928d0cdb481e19eacaa1ed8945e4ee32f1afac3223273f
7
- data.tar.gz: 6e3861f420327e0bccec7ab8e7c0a508e7cf224312c366297834091467d7cdb5e4fac8a305dbb59f7c0650d199d9a17062ab0408fd180b6fbaa05946bfd27545
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
@@ -25,10 +25,7 @@ module OnlineMigrations
25
25
  end
26
26
 
27
27
  def relation
28
- model
29
- .unscoped
30
- .where(copy_to.index_with(nil))
31
- .where.not(copy_from.index_with(nil))
28
+ model.unscoped
32
29
  end
33
30
 
34
31
  def process_batch(relation)
@@ -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
- case definition
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnlineMigrations
4
- VERSION = "0.16.0"
4
+ VERSION = "0.16.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: online_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fatkodima