ridgepole 3.1.5 → 3.2.0

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: b6de4765b254e55e4087b4fe7d99a9c23493e0c54b0a7c7e957b88488fa234d2
4
- data.tar.gz: 6d05534c60e9f9f0967179520d8ecd83bee84b96cbe1e80cd4336327f7cb8c37
3
+ metadata.gz: 58a248172bd53075285dcb1fa69f4c8e3bcfa8ab382445e78823d1a284695c3d
4
+ data.tar.gz: f7568382f78041f9279ff389e1b4f17f389f6ebfef37bde0c9b557ea2f0efeed
5
5
  SHA512:
6
- metadata.gz: 1bb9273027a3b3d74c7c18faf25ba4b47033a44b98b12b1de80e04cd521aeb994f45168e97603b56c87dac6839990322eb8b2131e438320772983b9636a8695e
7
- data.tar.gz: 49099509a1f3d8e5ae98fb7fe442e942ba7c7def24cf8a065e7c0d8838826e8ba4ec6394e4f9a5fa12cb906f2e850cb1a89e10496bbd07801ba746bf429f6389
6
+ metadata.gz: 331e86965d4537a88a18d56fc593bf7359a8cee7d4ea69e1e401d53cf2c704b86dae70db004b29738025b2851b528d4a03cc8cea0270b56ffe96cbb41df4d3a9
7
+ data.tar.gz: 1704cb3599ee8de9695efa8a4af09134f876192ff902ec111a705bdb0ab6f56a8af7bf2e59148fee9037866dab605e622b99c11137330f66decf4df316728e00
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
- ## 3.0
3
+ ## 3.2
4
+
5
+ ### 3.2.0 (2026/03/28)
6
+
7
+ - Fix spurious diff for `timestamp`/`datetime` with `precision: 6` on MySQL. [pull#665](https://github.com/ridgepole/ridgepole/pull/665)
8
+ - Use `udiff` instead of `diffy`. [pull#657](https://github.com/ridgepole/ridgepole/pull/657)
9
+
10
+ ## 3.1
4
11
 
5
12
  ### 3.1.5 (2026/03/21)
6
13
 
@@ -29,6 +36,8 @@
29
36
  - Support Rails 8.1 [pull#589](https://github.com/ridgepole/ridgepole/pull/589)
30
37
  - Support for migrating PostgreSQL table comments [pull#587](https://github.com/ridgepole/ridgepole/pull/587)
31
38
 
39
+ ## 3.0
40
+
32
41
  ### 3.0.4 (2025/08/31)
33
42
 
34
43
  - Fix checking foreign key without index [pull#571](https://github.com/ridgepole/ridgepole/pull/571)
data/README.md CHANGED
@@ -15,6 +15,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
15
15
  > If you do not want to sort the columns, use `--disable-sort-columns` option.
16
16
 
17
17
  > [!note]
18
+ > * ridgepole v3.2.0
19
+ > * Use `udiff` instead of `diffy` (cf. https://github.com/ridgepole/ridgepole/pull/657)
18
20
  > * ridgepole v3.1.0
19
21
  > * Support Rails 8.1 (cf. https://github.com/ridgepole/ridgepole/pull/589)
20
22
  > * ridgepole v3.0.0
@@ -301,6 +303,46 @@ execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFE
301
303
  end
302
304
  ```
303
305
 
306
+ ### Manage View using `execute`
307
+
308
+ #### MySQL
309
+
310
+ ```ruby
311
+ # NOTE: view_select must match the normalized form stored in information_schema.views.VIEW_DEFINITION
312
+ view_select = <<-EOS.strip
313
+ select `mydb`.`users`.`id` AS `id`,`mydb`.`users`.`name` AS `name`,`mydb`.`users`.`active` AS `active` from `mydb`.`users` where (`mydb`.`users`.`active` = 1)
314
+ EOS
315
+
316
+ execute("CREATE OR REPLACE VIEW `active_users` AS #{view_select}") do |c|
317
+ definition = c.raw_connection.query(<<-SQL).first&.first
318
+ SELECT SHA(VIEW_DEFINITION) FROM information_schema.views
319
+ WHERE TABLE_SCHEMA = 'mydb'
320
+ AND TABLE_NAME = 'active_users';
321
+ SQL
322
+ definition != view_select
323
+ end
324
+ ```
325
+
326
+ #### PostgreSQL
327
+
328
+ ```ruby
329
+ # NOTE: view_select must match the normalized form stored in pg_views.definition
330
+ view_select = <<~EOS.strip
331
+ SELECT users.name
332
+ FROM users
333
+ WHERE (users.active = false);
334
+ EOS
335
+
336
+ execute("CREATE OR REPLACE VIEW active_users AS #{view_select}") do |c|
337
+ definition = c.raw_connection.query(<<-SQL).first&.dig("definition")
338
+ SELECT definition FROM pg_views
339
+ WHERE schemaname = 'public'
340
+ AND viewname = 'active_users';
341
+ SQL
342
+ definition&.strip != view_select
343
+ end
344
+ ```
345
+
304
346
  ## Diff
305
347
  ```sh
306
348
  $ ridgepole --diff file1.schema file2.schema
@@ -445,6 +445,15 @@ module Ridgepole
445
445
  end
446
446
  end
447
447
 
448
+ # Since ActiveRecord >= 7.0.5, datetime/timestamp columns default to precision: 6 on MySQL.
449
+ # Strip precision: 6 when it matches the default to avoid spurious diffs.
450
+ # cf. https://github.com/ridgepole/ridgepole/issues/515
451
+ if %i[datetime timestamp].include?(attrs[:type]) &&
452
+ opts[:precision] == 6 &&
453
+ ActiveRecord.gem_version >= Gem::Version.new('7.0.5')
454
+ opts.delete(:precision)
455
+ end
456
+
448
457
  if opts[:size] && %i[text blob binary].include?(attrs[:type])
449
458
  case opts.delete(:size)
450
459
  when :tiny
@@ -697,13 +706,12 @@ module Ridgepole
697
706
  obj1 = Ridgepole::Ext::PpSortHash.extend_if_hash(obj1)
698
707
  obj2 = Ridgepole::Ext::PpSortHash.extend_if_hash(obj2)
699
708
 
700
- diffy = Diffy::Diff.new(
709
+ diff = Udiff::Diff.new(
701
710
  obj1.pretty_inspect,
702
- obj2.pretty_inspect,
703
- diff: '-u'
711
+ obj2.pretty_inspect
704
712
  )
705
713
 
706
- diffy.to_s(@options[:color] ? :color : :text).gsub(/\s+\z/m, '')
714
+ diff.to_s(@options[:color] ? :color : :text).gsub(/\s+\z/m, '')
707
715
  end
708
716
 
709
717
  def collect_relation_info!(table_name, table_attr, relation_info)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '3.1.5'
4
+ VERSION = '3.2.0'
5
5
  end
data/lib/ridgepole.rb CHANGED
@@ -11,7 +11,7 @@ require 'active_record'
11
11
  require 'active_support'
12
12
  require 'active_support/core_ext'
13
13
 
14
- require 'diffy'
14
+ require 'udiff'
15
15
 
16
16
  module Ridgepole; end
17
17
 
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.1.5
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -30,7 +30,7 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: '8.3'
32
32
  - !ruby/object:Gem::Dependency
33
- name: diffy
33
+ name: logger
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - ">="
@@ -44,19 +44,19 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: logger
47
+ name: udiff
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '0'
52
+ version: 0.2.0
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: 0.2.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: appraisal
62
62
  requirement: !ruby/object:Gem::Requirement