ridgepole 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/ridgepole/diff.rb +8 -1
- data/lib/ridgepole/dsl_parser/context.rb +10 -2
- data/lib/ridgepole/dsl_parser.rb +11 -3
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +1 -1
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cccf60348e4baf7ac0988edb6e68bc14b0cbb945a167e4a2e6d9ef71d5e35c8a
|
4
|
+
data.tar.gz: 9ff98ff1c8a823fe988129816db0bcc4dac1c9f1a5c565faa47ef8aa3852507b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0dc88f6715d8500bb4edfa106140ea7ca6cd1c207edd51cf65d12a76453ed2eb3d575ee8b73d7d96a0e386c4dec3e34ff985bf81bcc7a8026529946c3b40f74
|
7
|
+
data.tar.gz: 750a855f189b49cafbc35db15d227b2b2cbf8f2a545075b46a390697f768b3b9c606d9c6403c74c3491fdc76a408944aba2a3a2f7781dd475d096b82ec6f330a
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## 3.0
|
4
4
|
|
5
|
+
### 3.0.1 (2025/01/12)
|
6
|
+
|
7
|
+
- Normalize `check_constraint` [pull#512](https://github.com/ridgepole/ridgepole/pull/512)
|
8
|
+
- Support composite foreign key for non-primary key [pull#518](https://github.com/ridgepole/ridgepole/pull/518)
|
9
|
+
|
5
10
|
### 3.0.0 (2024/11/10)
|
6
11
|
|
7
12
|
- Support Rails 8.0 [pull#504](https://github.com/ridgepole/ridgepole/pull/504)
|
data/README.md
CHANGED
@@ -6,8 +6,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
6
6
|
(like Chef/Puppet)
|
7
7
|
|
8
8
|
[![Gem Version](https://badge.fury.io/rb/ridgepole.svg)](https://badge.fury.io/rb/ridgepole)
|
9
|
-
[![
|
10
|
-
[![Coverage Status](https://coveralls.io/repos/github/ridgepole/ridgepole/badge.svg?branch=
|
9
|
+
[![test](https://github.com/ridgepole/ridgepole/actions/workflows/test.yml/badge.svg)](https://github.com/ridgepole/ridgepole/actions/workflows/test.yml)
|
10
|
+
[![Coverage Status](https://coveralls.io/repos/github/ridgepole/ridgepole/badge.svg?branch=3.0)](https://coveralls.io/github/ridgepole/ridgepole?branch=3.0)
|
11
11
|
|
12
12
|
> [!note]
|
13
13
|
> * ridgepole v3.0.0
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
module Ridgepole
|
4
4
|
class Diff
|
5
5
|
PRIMARY_KEY_OPTIONS = %i[id limit default null precision scale collation unsigned].freeze
|
6
|
+
REGEX_COLUMN_IDENTIFIER_QUOTATION_CHARS = '"`'
|
6
7
|
|
7
8
|
def initialize(options = {})
|
8
9
|
@options = options
|
@@ -486,7 +487,7 @@ module Ridgepole
|
|
486
487
|
from_attrs = from.delete(name)
|
487
488
|
|
488
489
|
if from_attrs
|
489
|
-
if from_attrs != to_attrs
|
490
|
+
if normalize_check_constraint(from_attrs) != normalize_check_constraint(to_attrs)
|
490
491
|
check_constraints_delta[:add] ||= {}
|
491
492
|
check_constraints_delta[:add][name] = to_attrs
|
492
493
|
|
@@ -509,6 +510,12 @@ module Ridgepole
|
|
509
510
|
table_delta[:check_constraints] = check_constraints_delta unless check_constraints_delta.empty?
|
510
511
|
end
|
511
512
|
|
513
|
+
def normalize_check_constraint(attr)
|
514
|
+
attr = attr.dup
|
515
|
+
attr[:expression] = attr[:expression].delete(REGEX_COLUMN_IDENTIFIER_QUOTATION_CHARS)
|
516
|
+
attr
|
517
|
+
end
|
518
|
+
|
512
519
|
def scan_exclusion_constraints_change(from, to, table_delta)
|
513
520
|
from = (from || {}).dup
|
514
521
|
to = (to || {}).dup
|
@@ -77,8 +77,16 @@ module Ridgepole
|
|
77
77
|
from_table = from_table.to_s
|
78
78
|
to_table = to_table.to_s
|
79
79
|
options[:name] = options[:name].to_s if options[:name]
|
80
|
-
|
81
|
-
|
80
|
+
if options[:primary_key].is_a?(Array)
|
81
|
+
options[:primary_key] = options[:primary_key].map(&:to_s)
|
82
|
+
elsif options[:primary_key]
|
83
|
+
options[:primary_key] = options[:primary_key].to_s
|
84
|
+
end
|
85
|
+
if options[:column].is_a?(Array)
|
86
|
+
options[:column] = options[:column].map(&:to_s)
|
87
|
+
elsif options[:column]
|
88
|
+
options[:column] = options[:column].to_s
|
89
|
+
end
|
82
90
|
@__definition[from_table] ||= {}
|
83
91
|
@__definition[from_table][:foreign_keys] ||= {}
|
84
92
|
idx = options[:name] || [from_table, to_table, options[:column]]
|
data/lib/ridgepole/dsl_parser.rb
CHANGED
@@ -36,14 +36,22 @@ module Ridgepole
|
|
36
36
|
|
37
37
|
attrs[:foreign_keys].each_value do |foreign_key_attrs|
|
38
38
|
fk_index = foreign_key_attrs[:options][:column] || "#{foreign_key_attrs[:to_table].singularize}_id"
|
39
|
-
next if attrs[:indices]&.any? { |
|
40
|
-
|
41
|
-
next if Array(attrs[:options][:primary_key]).first == fk_index
|
39
|
+
next if attrs[:indices]&.any? { |_, v| match_column_name?(v[:column_name], fk_index) }
|
40
|
+
next if match_column_name?(attrs[:options][:primary_key], fk_index)
|
42
41
|
|
43
42
|
raise("The column `#{fk_index}` of the table `#{table_name}` has a foreign key but no index. " \
|
44
43
|
'Although InnoDB creates an index automatically, ' \
|
45
44
|
'please add one explicitly in order for ridgepole to manage it.')
|
46
45
|
end
|
47
46
|
end
|
47
|
+
|
48
|
+
def match_column_name?(index_column_name, fk_index)
|
49
|
+
if fk_index.is_a?(Array)
|
50
|
+
index_column_name == fk_index
|
51
|
+
else
|
52
|
+
# NOTE: For composite primary keys, the first column of the primary key is used as the foreign key index
|
53
|
+
Array(index_column_name).first == fk_index
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
data/lib/ridgepole/version.rb
CHANGED
data/ridgepole.gemspec
CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency 'rspec', '>= 3.0.0'
|
41
41
|
spec.add_development_dependency 'rspec-match_fuzzy', '>= 0.2.0'
|
42
42
|
spec.add_development_dependency 'rspec-match_ruby', '>= 0.1.3'
|
43
|
-
spec.add_development_dependency 'rubocop', '1.
|
43
|
+
spec.add_development_dependency 'rubocop', '1.69.2'
|
44
44
|
spec.add_development_dependency 'rubocop-rake', '>= 0.5.1'
|
45
45
|
spec.add_development_dependency 'rubocop-rspec', '>= 2.1.0'
|
46
46
|
spec.add_development_dependency 'simplecov'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridgepole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-12 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -232,14 +231,14 @@ dependencies:
|
|
232
231
|
requirements:
|
233
232
|
- - '='
|
234
233
|
- !ruby/object:Gem::Version
|
235
|
-
version: 1.
|
234
|
+
version: 1.69.2
|
236
235
|
type: :development
|
237
236
|
prerelease: false
|
238
237
|
version_requirements: !ruby/object:Gem::Requirement
|
239
238
|
requirements:
|
240
239
|
- - '='
|
241
240
|
- !ruby/object:Gem::Version
|
242
|
-
version: 1.
|
241
|
+
version: 1.69.2
|
243
242
|
- !ruby/object:Gem::Dependency
|
244
243
|
name: rubocop-rake
|
245
244
|
requirement: !ruby/object:Gem::Requirement
|
@@ -363,7 +362,6 @@ licenses:
|
|
363
362
|
- MIT
|
364
363
|
metadata:
|
365
364
|
rubygems_mfa_required: 'true'
|
366
|
-
post_install_message:
|
367
365
|
rdoc_options: []
|
368
366
|
require_paths:
|
369
367
|
- lib
|
@@ -378,8 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
378
376
|
- !ruby/object:Gem::Version
|
379
377
|
version: '0'
|
380
378
|
requirements: []
|
381
|
-
rubygems_version: 3.
|
382
|
-
signing_key:
|
379
|
+
rubygems_version: 3.6.2
|
383
380
|
specification_version: 4
|
384
381
|
summary: Ridgepole is a tool to manage DB schema.
|
385
382
|
test_files: []
|