ridgepole 3.1.4 → 3.1.5
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 +5 -0
- data/lib/ridgepole/delta.rb +38 -6
- data/lib/ridgepole/diff.rb +14 -0
- data/lib/ridgepole/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6de4765b254e55e4087b4fe7d99a9c23493e0c54b0a7c7e957b88488fa234d2
|
|
4
|
+
data.tar.gz: 6d05534c60e9f9f0967179520d8ecd83bee84b96cbe1e80cd4336327f7cb8c37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bb9273027a3b3d74c7c18faf25ba4b47033a44b98b12b1de80e04cd521aeb994f45168e97603b56c87dac6839990322eb8b2131e438320772983b9636a8695e
|
|
7
|
+
data.tar.gz: 49099509a1f3d8e5ae98fb7fe442e942ba7c7def24cf8a065e7c0d8838826e8ba4ec6394e4f9a5fa12cb906f2e850cb1a89e10496bbd07801ba746bf429f6389
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## 3.0
|
|
4
4
|
|
|
5
|
+
### 3.1.5 (2026/03/21)
|
|
6
|
+
|
|
7
|
+
- Fix for renaming references column. [pull#652](https://github.com/ridgepole/ridgepole/pull/652)
|
|
8
|
+
- Fix for creating table with non-PK auto_increment column. [pull#650](https://github.com/ridgepole/ridgepole/pull/650)
|
|
9
|
+
|
|
5
10
|
### 3.1.4 (2026/03/20)
|
|
6
11
|
|
|
7
12
|
- Fix for errors when changing generated columns. [pull#642](https://github.com/ridgepole/ridgepole/pull/642) [pull#646](https://github.com/ridgepole/ridgepole/pull/646)
|
data/lib/ridgepole/delta.rb
CHANGED
|
@@ -243,10 +243,18 @@ create_table(#{table_name.inspect}, #{inspect_options_include_default_proc(optio
|
|
|
243
243
|
RUBY
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
# Partition indices: indices referencing auto_increment columns must be
|
|
247
|
+
# inside CREATE TABLE on MySQL to avoid "must be defined as a key" error.
|
|
248
|
+
# cf. https://github.com/ridgepole/ridgepole/issues/494
|
|
249
|
+
if @options[:create_table_with_index]
|
|
250
|
+
indices_in_create = indices
|
|
251
|
+
indices_after_create = {}
|
|
252
|
+
else
|
|
253
|
+
indices_in_create, indices_after_create = partition_indices_for_create(definition, indices)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
indices_in_create.each do |index_name, index_attrs|
|
|
257
|
+
append_add_index(table_name, index_name, index_attrs, buf, true)
|
|
250
258
|
end
|
|
251
259
|
|
|
252
260
|
unless (check_constraints = attrs[:check_constraints] || {}).empty?
|
|
@@ -271,9 +279,9 @@ create_table(#{table_name.inspect}, #{inspect_options_include_default_proc(optio
|
|
|
271
279
|
end
|
|
272
280
|
RUBY
|
|
273
281
|
|
|
274
|
-
|
|
282
|
+
unless indices_after_create.empty?
|
|
275
283
|
append_change_table(table_name, buf) do
|
|
276
|
-
|
|
284
|
+
indices_after_create.each do |index_name, index_attrs|
|
|
277
285
|
append_add_index(table_name, index_name, index_attrs, buf)
|
|
278
286
|
end
|
|
279
287
|
end
|
|
@@ -289,6 +297,30 @@ end
|
|
|
289
297
|
post_buf_for_fk.puts
|
|
290
298
|
end
|
|
291
299
|
|
|
300
|
+
def partition_indices_for_create(definition, indices)
|
|
301
|
+
return [{}, indices] unless Ridgepole::ConnectionAdapters.mysql?
|
|
302
|
+
|
|
303
|
+
auto_increment_columns = definition.select do |_col_name, col_attrs|
|
|
304
|
+
col_attrs.dig(:options, :auto_increment)
|
|
305
|
+
end.keys
|
|
306
|
+
|
|
307
|
+
return [{}, indices] if auto_increment_columns.empty?
|
|
308
|
+
|
|
309
|
+
in_create = {}
|
|
310
|
+
after_create = {}
|
|
311
|
+
|
|
312
|
+
indices.each do |idx_name, idx_attrs|
|
|
313
|
+
columns = Array(idx_attrs[:column_name])
|
|
314
|
+
if (columns & auto_increment_columns).any?
|
|
315
|
+
in_create[idx_name] = idx_attrs
|
|
316
|
+
else
|
|
317
|
+
after_create[idx_name] = idx_attrs
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
[in_create, after_create]
|
|
322
|
+
end
|
|
323
|
+
|
|
292
324
|
def append_rename_table(to_table_name, from_table_name, buf)
|
|
293
325
|
buf.puts(<<-RUBY)
|
|
294
326
|
rename_table(#{from_table_name.inspect}, #{to_table_name.inspect})
|
data/lib/ridgepole/diff.rb
CHANGED
|
@@ -103,6 +103,7 @@ module Ridgepole
|
|
|
103
103
|
|
|
104
104
|
scan_options_change(table_name, from[:options], to[:options], table_delta)
|
|
105
105
|
scan_definition_change(from[:definition], to[:definition], from[:indices], table_name, from[:options], table_delta)
|
|
106
|
+
apply_column_renames_to_indices(from[:indices], table_delta.dig(:definition, :rename))
|
|
106
107
|
scan_indices_change(from[:indices], to[:indices], to[:definition], table_delta, from[:options], to[:options])
|
|
107
108
|
scan_foreign_keys_change(from[:foreign_keys], to[:foreign_keys], table_delta, @options)
|
|
108
109
|
scan_check_constraints_change(from[:check_constraints], to[:check_constraints], table_delta)
|
|
@@ -342,6 +343,19 @@ module Ridgepole
|
|
|
342
343
|
end
|
|
343
344
|
end
|
|
344
345
|
|
|
346
|
+
def apply_column_renames_to_indices(indices, renames)
|
|
347
|
+
return unless indices && renames
|
|
348
|
+
|
|
349
|
+
# renames: { new_column_name => old_column_name }
|
|
350
|
+
rename_map = renames.invert # { old_column_name => new_column_name }
|
|
351
|
+
|
|
352
|
+
indices.each_value do |attrs|
|
|
353
|
+
next unless attrs[:column_name].is_a?(Array)
|
|
354
|
+
|
|
355
|
+
attrs[:column_name] = attrs[:column_name].map { |col| rename_map[col] || col }
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
345
359
|
def scan_indices_change(from, to, to_columns, table_delta, _from_table_options, to_table_options)
|
|
346
360
|
from = (from || {}).dup
|
|
347
361
|
to = (to || {}).dup
|
data/lib/ridgepole/version.rb
CHANGED