ridgepole 3.2.8 → 3.2.9

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: 710e0a6b4939d489088aa89eade29e41879a3d8c2605ad46579d9a68cb78edb6
4
- data.tar.gz: 2e209f3ee2382ca1271f1130415224a687069a620a91e2e9db24450ebe2ce944
3
+ metadata.gz: a15f52cb436c76a2527b18fdee99f2aebce6393e1c9acd43e8a5a0c72650c3ba
4
+ data.tar.gz: a8aca6ca24e4e67bbca188783e0d23caddaf47f6afccf44c9808bc588dee3739
5
5
  SHA512:
6
- metadata.gz: 96b25fd1acb23f673c729b7ad31065e6245c8f91d2f885efbdb821cf7ae17b504d666362a067d5cd7ae8366486505876a259d6c43200c5aee281c8883867d5c5
7
- data.tar.gz: d45c0b3e529b2459309458f604e90c8a3cf97f2b402aa08badd14ec2b88c6b55fef78012f382824747acde4345fe82aa6ca71950f835c00c0fffb1916bed5d98
6
+ metadata.gz: 2ceac9ff3f6ba52b9564b0215b70a25ebedd1df27a845fa25fac08f8ba9e4114443208e372314685ad044caf2153a8d0ed9aea42f7ee3a520b81582ec4857205
7
+ data.tar.gz: a273c31f5b3e6e8eeb021a55add40bba1f3a9ef467c0f35e29b6c70b93ce19f817060317f3f2d3dcc5c18c9025331373d80e8c8dff5c9f285c0b2037a340a152
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 3.2
4
4
 
5
+ ### 3.2.9 (2026/12/02)
6
+
7
+ - On PostgreSQL, emit `change_column_null` instead of `change_column` for null-only column changes. [pull#768](https://github.com/ridgepole/ridgepole/pull/768)
8
+
5
9
  ### 3.2.8 (2026/11/04)
6
10
 
7
11
  - On PostgreSQL, add `validate: false` check constraints after `create_table` so that they stay NOT VALID on new tables. [pull#758](https://github.com/ridgepole/ridgepole/pull/758)
data/README.md CHANGED
@@ -14,6 +14,7 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
14
14
  > Also developing similar declarative schema tools — single Go binary, plain SQL as the schema definition. Give it a try.
15
15
  >
16
16
  > * [pistachio](https://github.com/winebarrel/pistachio): for PostgreSQL
17
+ > * [hazel](https://github.com/winebarrel/hazel): for SQLite
17
18
 
18
19
  > [!warning]
19
20
  > The order of columns when exporting has changed in Rails 8.1. https://github.com/rails/rails/pull/53281
@@ -448,6 +448,10 @@ change_column_comment(#{table_name.inspect}, #{column_name.inspect}, #{comment.i
448
448
  append_change_column(table_name, column_name, attrs, buf)
449
449
  end
450
450
 
451
+ (delta[:change_null] || {}).each do |column_name, null|
452
+ append_change_column_null(table_name, column_name, null, buf)
453
+ end
454
+
451
455
  (delta[:delete] || {}).each do |column_name, attrs|
452
456
  append_remove_column(table_name, column_name, attrs, buf)
453
457
  end
@@ -508,6 +512,18 @@ change_column(#{table_name.inspect}, #{column_name.inspect}, #{type.inspect}, #{
508
512
  end
509
513
  end
510
514
 
515
+ def append_change_column_null(table_name, column_name, null, buf)
516
+ if @options[:bulk_change]
517
+ buf.puts(<<-RUBY)
518
+ t.change_null(#{column_name.inspect}, #{null.inspect})
519
+ RUBY
520
+ else
521
+ buf.puts(<<-RUBY)
522
+ change_column_null(#{table_name.inspect}, #{column_name.inspect}, #{null.inspect})
523
+ RUBY
524
+ end
525
+ end
526
+
511
527
  def append_remove_column(table_name, column_name, _attrs, buf)
512
528
  if @options[:bulk_change]
513
529
  buf.puts(<<-RUBY)
@@ -263,6 +263,9 @@ module Ridgepole
263
263
  if changed_attrs
264
264
  if comment_only_change?(from_attrs, to_attrs)
265
265
  column_comments[column_name] = to_attrs[:options][:comment]
266
+ elsif null_only_change?(from_attrs, to_attrs)
267
+ definition_delta[:change_null] ||= {}
268
+ definition_delta[:change_null][column_name] = to_attrs[:options][:null]
266
269
  else
267
270
  definition_delta[:change] ||= {}
268
271
  definition_delta[:change][column_name] = changed_attrs
@@ -746,6 +749,21 @@ module Ridgepole
746
749
  attrs1 == attrs2 && comment1 != comment2
747
750
  end
748
751
 
752
+ # On PostgreSQL, `change_column` always emits `ALTER COLUMN ... TYPE`, even when the type is unchanged.
753
+ # That makes PostgreSQL rebuild the constraints that depend on the column (and verify CHECK constraints
754
+ # against the whole table), so emit `change_column_null` (`SET NOT NULL` / `DROP NOT NULL`) instead.
755
+ def null_only_change?(attrs1, attrs2)
756
+ return false unless Ridgepole::ConnectionAdapters.postgresql?
757
+
758
+ attrs1 = attrs1.merge(options: attrs1.fetch(:options, {}).dup)
759
+ attrs2 = attrs2.merge(options: attrs2.fetch(:options, {}).dup)
760
+
761
+ null1 = attrs1.fetch(:options).delete(:null)
762
+ null2 = attrs2.fetch(:options).delete(:null)
763
+
764
+ null1 != null2 && compare_column_attrs(attrs1, attrs2)
765
+ end
766
+
749
767
  def normalize_default_proc_options!(opts1, opts2)
750
768
  if opts1[:default].is_a?(Proc) && opts2[:default].is_a?(Proc)
751
769
  opts1[:default] = opts1[:default].call
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '3.2.8'
4
+ VERSION = '3.2.9'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridgepole
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.8
4
+ version: 3.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-12-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activerecord
@@ -245,14 +245,14 @@ dependencies:
245
245
  requirements:
246
246
  - - '='
247
247
  - !ruby/object:Gem::Version
248
- version: 1.92.2
248
+ version: 1.93.0
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.92.2
255
+ version: 1.93.0
256
256
  - !ruby/object:Gem::Dependency
257
257
  name: rubocop-rake
258
258
  requirement: !ruby/object:Gem::Requirement
@@ -406,7 +406,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
406
  - !ruby/object:Gem::Version
407
407
  version: '0'
408
408
  requirements: []
409
- rubygems_version: 4.0.3
409
+ rubygems_version: 3.6.1
410
410
  specification_version: 4
411
411
  summary: Ridgepole is a tool to manage DB schema.
412
412
  test_files: []