ridgepole 2.1.1 → 3.0.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: d5a8448bb1e765b5413fdae6ad54336b6a79ab31de43e5c9767c8cdd6c53c681
4
- data.tar.gz: 0c8b227c585e225133d947cbe5facbfaf3d4218f2b9ad37ec41141c2a7a7a191
3
+ metadata.gz: cccf60348e4baf7ac0988edb6e68bc14b0cbb945a167e4a2e6d9ef71d5e35c8a
4
+ data.tar.gz: 9ff98ff1c8a823fe988129816db0bcc4dac1c9f1a5c565faa47ef8aa3852507b
5
5
  SHA512:
6
- metadata.gz: 6f6efcdcba804e9699cbeb2c9c17d467c4a3bcf21013a5856d275bd2a56904c3202bfa123735002d23d7ea1eca8d95b894510d050d52b1213ac04a8d67ff23f3
7
- data.tar.gz: 1769dc1a656bcaef84e491806078a95e722dc873c81e1e25c8e28bb6a426aced6c3a096eb6e4c133038fd5b370d426feeb381fb9c003a10f57343698b27c77b3
6
+ metadata.gz: f0dc88f6715d8500bb4edfa106140ea7ca6cd1c207edd51cf65d12a76453ed2eb3d575ee8b73d7d96a0e386c4dec3e34ff985bf81bcc7a8026529946c3b40f74
7
+ data.tar.gz: 750a855f189b49cafbc35db15d227b2b2cbf8f2a545075b46a390697f768b3b9c606d9c6403c74c3491fdc76a408944aba2a3a2f7781dd475d096b82ec6f330a
data/.rubocop.yml CHANGED
@@ -58,3 +58,5 @@ Style/OptionalBooleanParameter:
58
58
  Enabled: false
59
59
  Gemspec/DevelopmentDependencies:
60
60
  Enabled: false
61
+ Lint/LiteralInInterpolation:
62
+ Enabled: false
data/Appraisals CHANGED
@@ -15,3 +15,7 @@ end
15
15
  appraise 'activerecord-7.2' do
16
16
  gem 'activerecord', '~> 7.2.0'
17
17
  end
18
+
19
+ appraise 'activerecord-8.0' do
20
+ gem 'activerecord', '~> 8.0.0'
21
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0
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
+
10
+ ### 3.0.0 (2024/11/10)
11
+
12
+ - Support Rails 8.0 [pull#504](https://github.com/ridgepole/ridgepole/pull/504)
13
+
3
14
  ## 2.1
4
15
 
5
16
  ### 2.1.1 (2024/09/12)
data/README.md CHANGED
@@ -6,10 +6,12 @@ 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
- [![Build Status](https://github.com/ridgepole/ridgepole/workflows/test/badge.svg?branch=1.2)](https://github.com/ridgepole/ridgepole/actions)
10
- [![Coverage Status](https://coveralls.io/repos/github/ridgepole/ridgepole/badge.svg?branch=1.2)](https://coveralls.io/github/ridgepole/ridgepole?branch=1.2)
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
+ > * ridgepole v3.0.0
14
+ > * Support Rails 8.0 (cf. https://github.com/ridgepole/ridgepole/pull/504)
13
15
  > * ridgepole v2.0.0
14
16
  > * Support Trilogy (cf. https://github.com/ridgepole/ridgepole/pull/447)
15
17
  > * Support Rails 7.1 (cf. https://github.com/ridgepole/ridgepole/pull/441)
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 8.0.0"
6
+
7
+ gemspec path: "../"
@@ -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
- options[:primary_key] = options[:primary_key].to_s if options[:primary_key]
81
- options[:column] = options[:column].to_s if options[:column]
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]]
@@ -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? { |_k, v| v[:column_name].first == fk_index }
40
- # NOTE: For composite primary keys, the first column of the primary key is used as the foreign key index
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '2.1.1'
4
+ VERSION = '3.0.1'
5
5
  end
data/ridgepole.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = Gem::Requirement.new('>= 2.7')
26
26
 
27
- spec.add_dependency 'activerecord', '>= 6.1', '< 8.0'
27
+ spec.add_dependency 'activerecord', '>= 6.1', '< 8.1'
28
28
  spec.add_dependency 'diffy'
29
29
  spec.add_dependency 'logger'
30
30
 
@@ -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.66.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: 2.1.1
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: 2024-09-12 00:00:00.000000000 Z
10
+ date: 2025-01-12 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: '6.1'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '8.0'
21
+ version: '8.1'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: '6.1'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '8.0'
31
+ version: '8.1'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: diffy
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -232,14 +231,14 @@ dependencies:
232
231
  requirements:
233
232
  - - '='
234
233
  - !ruby/object:Gem::Version
235
- version: 1.66.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.66.1
241
+ version: 1.69.2
243
242
  - !ruby/object:Gem::Dependency
244
243
  name: rubocop-rake
245
244
  requirement: !ruby/object:Gem::Requirement
@@ -334,6 +333,7 @@ files:
334
333
  - gemfiles/activerecord_7.0.gemfile
335
334
  - gemfiles/activerecord_7.1.gemfile
336
335
  - gemfiles/activerecord_7.2.gemfile
336
+ - gemfiles/activerecord_8.0.gemfile
337
337
  - lib/ridgepole.rb
338
338
  - lib/ridgepole/cli/config.rb
339
339
  - lib/ridgepole/client.rb
@@ -362,7 +362,6 @@ licenses:
362
362
  - MIT
363
363
  metadata:
364
364
  rubygems_mfa_required: 'true'
365
- post_install_message:
366
365
  rdoc_options: []
367
366
  require_paths:
368
367
  - lib
@@ -377,8 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
377
376
  - !ruby/object:Gem::Version
378
377
  version: '0'
379
378
  requirements: []
380
- rubygems_version: 3.5.1
381
- signing_key:
379
+ rubygems_version: 3.6.2
382
380
  specification_version: 4
383
381
  summary: Ridgepole is a tool to manage DB schema.
384
382
  test_files: []