ridgepole 3.2.0.beta → 3.2.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 +4 -4
- data/CHANGELOG.md +11 -2
- data/README.md +45 -0
- data/lib/ridgepole/diff.rb +23 -3
- data/lib/ridgepole/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44c06587d61c4599e0f7f0b10cdcc16829bd43122c9545a9e7441e22e5d1a5be
|
|
4
|
+
data.tar.gz: 350526f0a2303c72901e214c9c01996062a3758581815605152ef702ffefcc16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0634c00dfc3a1c34f44e22d76cef892d17b5115a344ed600f5152ebba12e776668e8aa987650ee680cf8263a1cf779f39963a1b5cf2c7cbd20393d8a31c29b40
|
|
7
|
+
data.tar.gz: e5303a3b7c53068957d7b27613cb2b608043d1cd6a7adf9ee278378d7e6227794909f32d01289f484e00c5b480613c6dd6ce18066b6cf634b6849d69e9a304b0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 3.
|
|
3
|
+
## 3.2
|
|
4
|
+
|
|
5
|
+
### 3.2.1 (2026/05/04)
|
|
6
|
+
|
|
7
|
+
- Warn when an anonymous index ambiguously matches multiple DB indexes. [pull#692](https://github.com/ridgepole/ridgepole/pull/692)
|
|
4
8
|
|
|
5
|
-
### 3.2.0
|
|
9
|
+
### 3.2.0 (2026/03/28)
|
|
6
10
|
|
|
11
|
+
- Fix spurious diff for `timestamp`/`datetime` with `precision: 6` on MySQL. [pull#665](https://github.com/ridgepole/ridgepole/pull/665)
|
|
7
12
|
- Use `udiff` instead of `diffy`. [pull#657](https://github.com/ridgepole/ridgepole/pull/657)
|
|
8
13
|
|
|
14
|
+
## 3.1
|
|
15
|
+
|
|
9
16
|
### 3.1.5 (2026/03/21)
|
|
10
17
|
|
|
11
18
|
- Fix for renaming references column. [pull#652](https://github.com/ridgepole/ridgepole/pull/652)
|
|
@@ -33,6 +40,8 @@
|
|
|
33
40
|
- Support Rails 8.1 [pull#589](https://github.com/ridgepole/ridgepole/pull/589)
|
|
34
41
|
- Support for migrating PostgreSQL table comments [pull#587](https://github.com/ridgepole/ridgepole/pull/587)
|
|
35
42
|
|
|
43
|
+
## 3.0
|
|
44
|
+
|
|
36
45
|
### 3.0.4 (2025/08/31)
|
|
37
46
|
|
|
38
47
|
- Fix checking foreign key without index [pull#571](https://github.com/ridgepole/ridgepole/pull/571)
|
data/README.md
CHANGED
|
@@ -9,6 +9,11 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
|
9
9
|
[](https://github.com/ridgepole/ridgepole/actions/workflows/test.yml)
|
|
10
10
|
[](https://codecov.io/gh/ridgepole/ridgepole)
|
|
11
11
|
|
|
12
|
+
> [!TIP]
|
|
13
|
+
> Currently developing a similar tool for PostgreSQL.
|
|
14
|
+
>
|
|
15
|
+
> see https://github.com/winebarrel/pistachio
|
|
16
|
+
|
|
12
17
|
> [!warning]
|
|
13
18
|
> The order of columns when exporting has changed in Rails 8.1. https://github.com/rails/rails/pull/53281
|
|
14
19
|
>
|
|
@@ -303,6 +308,46 @@ execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFE
|
|
|
303
308
|
end
|
|
304
309
|
```
|
|
305
310
|
|
|
311
|
+
### Manage View using `execute`
|
|
312
|
+
|
|
313
|
+
#### MySQL
|
|
314
|
+
|
|
315
|
+
```ruby
|
|
316
|
+
# NOTE: view_select must match the normalized form stored in information_schema.views.VIEW_DEFINITION
|
|
317
|
+
view_select = <<-EOS.strip
|
|
318
|
+
select `mydb`.`users`.`id` AS `id`,`mydb`.`users`.`name` AS `name`,`mydb`.`users`.`active` AS `active` from `mydb`.`users` where (`mydb`.`users`.`active` = 1)
|
|
319
|
+
EOS
|
|
320
|
+
|
|
321
|
+
execute("CREATE OR REPLACE VIEW `active_users` AS #{view_select}") do |c|
|
|
322
|
+
definition = c.raw_connection.query(<<-SQL).first&.first
|
|
323
|
+
SELECT VIEW_DEFINITION FROM information_schema.views
|
|
324
|
+
WHERE TABLE_SCHEMA = 'mydb'
|
|
325
|
+
AND TABLE_NAME = 'active_users';
|
|
326
|
+
SQL
|
|
327
|
+
definition&.strip != view_select
|
|
328
|
+
end
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
#### PostgreSQL
|
|
332
|
+
|
|
333
|
+
```ruby
|
|
334
|
+
# NOTE: view_select must match the normalized form stored in pg_views.definition
|
|
335
|
+
view_select = <<~EOS.strip
|
|
336
|
+
SELECT users.name
|
|
337
|
+
FROM users
|
|
338
|
+
WHERE (users.active = false);
|
|
339
|
+
EOS
|
|
340
|
+
|
|
341
|
+
execute("CREATE OR REPLACE VIEW active_users AS #{view_select}") do |c|
|
|
342
|
+
definition = c.raw_connection.query(<<-SQL).first&.dig("definition")
|
|
343
|
+
SELECT definition FROM pg_views
|
|
344
|
+
WHERE schemaname = 'public'
|
|
345
|
+
AND viewname = 'active_users';
|
|
346
|
+
SQL
|
|
347
|
+
definition&.strip != view_select
|
|
348
|
+
end
|
|
349
|
+
```
|
|
350
|
+
|
|
306
351
|
## Diff
|
|
307
352
|
```sh
|
|
308
353
|
$ ridgepole --diff file1.schema file2.schema
|
data/lib/ridgepole/diff.rb
CHANGED
|
@@ -104,7 +104,7 @@ module Ridgepole
|
|
|
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
106
|
apply_column_renames_to_indices(from[:indices], table_delta.dig(:definition, :rename))
|
|
107
|
-
scan_indices_change(from[:indices], to[:indices], to[:definition], table_delta, from[:options], to[:options])
|
|
107
|
+
scan_indices_change(table_name, from[:indices], to[:indices], to[:definition], table_delta, from[:options], to[:options])
|
|
108
108
|
scan_foreign_keys_change(from[:foreign_keys], to[:foreign_keys], table_delta, @options)
|
|
109
109
|
scan_check_constraints_change(from[:check_constraints], to[:check_constraints], table_delta)
|
|
110
110
|
scan_exclusion_constraints_change(from[:exclusion_constraints], to[:exclusion_constraints], table_delta)
|
|
@@ -356,7 +356,7 @@ module Ridgepole
|
|
|
356
356
|
end
|
|
357
357
|
end
|
|
358
358
|
|
|
359
|
-
def scan_indices_change(from, to, to_columns, table_delta, _from_table_options, to_table_options)
|
|
359
|
+
def scan_indices_change(table_name, from, to, to_columns, table_delta, _from_table_options, to_table_options)
|
|
360
360
|
from = (from || {}).dup
|
|
361
361
|
to = (to || {}).dup
|
|
362
362
|
indices_delta = {}
|
|
@@ -365,7 +365,18 @@ module Ridgepole
|
|
|
365
365
|
ignore_index = to_attrs.fetch(:options, {}).delete(:ignore)
|
|
366
366
|
|
|
367
367
|
if index_name.is_a?(Array)
|
|
368
|
-
|
|
368
|
+
matching = from.select { |_name, attrs| attrs[:column_name] == index_name }
|
|
369
|
+
|
|
370
|
+
if matching.size > 1 && !ignore_index
|
|
371
|
+
@logger.warn(
|
|
372
|
+
"[WARNING] Multiple existing indexes on `#{table_name}` match column #{index_name.inspect}: " \
|
|
373
|
+
"#{matching.keys.map(&:inspect).join(', ')}. " \
|
|
374
|
+
'The choice of which index to keep depends on iteration order; ' \
|
|
375
|
+
'specify `name:` explicitly to disambiguate.'
|
|
376
|
+
)
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
from_index_name, from_attrs = matching.first
|
|
369
380
|
|
|
370
381
|
if from_attrs
|
|
371
382
|
from.delete(from_index_name)
|
|
@@ -445,6 +456,15 @@ module Ridgepole
|
|
|
445
456
|
end
|
|
446
457
|
end
|
|
447
458
|
|
|
459
|
+
# Since ActiveRecord >= 7.0.5, datetime/timestamp columns default to precision: 6 on MySQL.
|
|
460
|
+
# Strip precision: 6 when it matches the default to avoid spurious diffs.
|
|
461
|
+
# cf. https://github.com/ridgepole/ridgepole/issues/515
|
|
462
|
+
if %i[datetime timestamp].include?(attrs[:type]) &&
|
|
463
|
+
opts[:precision] == 6 &&
|
|
464
|
+
ActiveRecord.gem_version >= Gem::Version.new('7.0.5')
|
|
465
|
+
opts.delete(:precision)
|
|
466
|
+
end
|
|
467
|
+
|
|
448
468
|
if opts[:size] && %i[text blob binary].include?(attrs[:type])
|
|
449
469
|
case opts.delete(:size)
|
|
450
470
|
when :tiny
|
data/lib/ridgepole/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ridgepole
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Genki Sugawara
|
|
@@ -245,14 +245,14 @@ dependencies:
|
|
|
245
245
|
requirements:
|
|
246
246
|
- - '='
|
|
247
247
|
- !ruby/object:Gem::Version
|
|
248
|
-
version: 1.
|
|
248
|
+
version: 1.86.1
|
|
249
249
|
type: :development
|
|
250
250
|
prerelease: false
|
|
251
251
|
version_requirements: !ruby/object:Gem::Requirement
|
|
252
252
|
requirements:
|
|
253
253
|
- - '='
|
|
254
254
|
- !ruby/object:Gem::Version
|
|
255
|
-
version: 1.
|
|
255
|
+
version: 1.86.1
|
|
256
256
|
- !ruby/object:Gem::Dependency
|
|
257
257
|
name: rubocop-rake
|
|
258
258
|
requirement: !ruby/object:Gem::Requirement
|