ridgepole 3.0.4 → 3.1.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: 931a6b90df6d277ffd72a272342058290e4fcc8b793ffc0b94f2719a9fc6de4e
4
- data.tar.gz: '01879ec62757730657f0197c052f2601fe74561286cef3fc4d7c9e82bc329764'
3
+ metadata.gz: d387024f72e2f0cadf0c913d9d6d1863753401ed8cdd35759effd47e5405d3fd
4
+ data.tar.gz: ed16c2c4ce6e91797eba24c94384dc2e03db5e39ca18e9119daa4e19a67bd97e
5
5
  SHA512:
6
- metadata.gz: ada25e648306fce2dbb1755c5746e2bcaf6a7e4413fada585ce278f4750f7b28493b2e156139b17cacdb5b95d70073771dc174c11ce32986033bfa80a8cc3bf9
7
- data.tar.gz: 61e689542f00d014065941fab911c0c11a6cbd1f41ef0f293cce18ffb4f71de37f9499985f9a6c4241699fe796c7a7bc2721979834a3882ad52bb2fcbfac0011
6
+ metadata.gz: ea58375d9d0f3aa45084f08dabdea2719bbdd973229214dd60388fdd375d05dc3814b9131afb48a0c3b445b505a23f7c25b99a27f255549db81abf948a88a04e
7
+ data.tar.gz: 692d7e680804f86feab03fdebf1aa8f0f88af8f752e04cafec57a5406be64240114d6327a1651a74dae483d31336d0ab09b0f566524f8bd7f133a3e0e9862bb7
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## 3.0
4
4
 
5
+ ### 3.1.0 (2025/10/30)
6
+
7
+ - Support Rails 8.1 [pull#589](https://github.com/ridgepole/ridgepole/pull/589)
8
+ - Support for migrating PostgreSQL table comments [pull#587](https://github.com/ridgepole/ridgepole/pull/587)
9
+
5
10
  ### 3.0.4 (2025/08/31)
6
11
 
7
12
  - Fix checking foreign key without index [pull#571](https://github.com/ridgepole/ridgepole/pull/571)
data/README.md CHANGED
@@ -181,6 +181,13 @@ create_table "user_comments", force: :cascade, renamed_from: "comments" do |t|
181
181
  end
182
182
  ```
183
183
 
184
+ > [!note]
185
+ > When using `renamed_from` on a table, Ridgepole will only perform the rename operation. All other changes to that table (columns, indexes, foreign keys, etc.) will not be detected during the same migration.
186
+ >
187
+ > If you need to rename AND modify a table, do it in two separate steps:
188
+ > 1. First migration: Add `renamed_from` to rename the table
189
+ > 2. Second migration: Remove `renamed_from` and apply your desired changes
190
+
184
191
  ## Foreign Key
185
192
  ```ruby
186
193
  create_table "parent", force: :cascade do |t|
data/bin/ridgepole CHANGED
@@ -139,6 +139,7 @@ ARGV.options do |opt|
139
139
  opt.on('', '--drop-table-only') { options[:drop_table_only] = true }
140
140
  opt.on('', '--mysql-change-table-options') { options[:mysql_change_table_options] = true }
141
141
  opt.on('', '--mysql-change-table-comment') { options[:mysql_change_table_comment] = true }
142
+ opt.on('', '--pg-change-table-comment') { options[:postgresql_change_table_comment] = true }
142
143
  opt.on('', '--check-relation-type DEF_PK') { |v| options[:check_relation_type] = v }
143
144
  opt.on('', '--ignore-table-comment') { options[:ignore_table_comment] = true }
144
145
  opt.on('', '--skip-column-comment-change') { options[:skip_column_comment_change] = true }
@@ -3,14 +3,15 @@
3
3
  module Ridgepole
4
4
  class DefaultsLimit
5
5
  DEFAULT_LIMIT_FOR_MYSQL = {
6
- boolean: 1,
7
6
  integer: 4,
8
7
  bigint: 8,
9
8
  float: 24,
10
9
  string: 255,
11
10
  text: 65_535,
12
11
  binary: 65_535,
13
- }.freeze
12
+ }.tap do |limits|
13
+ limits[:boolean] = 1 if ActiveRecord.gem_version < Gem::Version.new('8.1.0.beta1')
14
+ end.freeze
14
15
 
15
16
  DEFAULTS_LIMITS = {
16
17
  mysql2: DEFAULT_LIMIT_FOR_MYSQL,
@@ -328,8 +328,14 @@ execute "ALTER TABLE #{ActiveRecord::Base.connection.quote_table_name(table_name
328
328
  end
329
329
 
330
330
  def append_change_table_comment(table_name, table_comment, buf)
331
- comment_literal = "COMMENT=#{ActiveRecord::Base.connection.quote(table_comment)}"
332
- append_change_table_options(table_name, comment_literal, buf)
331
+ if Ridgepole::ConnectionAdapters.postgresql?
332
+ buf.puts(<<-RUBY)
333
+ change_table_comment(#{table_name.inspect}, #{table_comment.inspect})
334
+ RUBY
335
+ else
336
+ comment_literal = "COMMENT=#{ActiveRecord::Base.connection.quote(table_comment)}"
337
+ append_change_table_options(table_name, comment_literal, buf)
338
+ end
333
339
  end
334
340
 
335
341
  def append_change(table_name, attrs, buf, pre_buf_for_fk, post_buf_for_fk)
@@ -438,7 +444,7 @@ rename_column(#{table_name.inspect}, #{from_column_name.inspect}, #{to_column_na
438
444
  options = attrs[:options] || {}
439
445
 
440
446
  # Fix for https://github.com/rails/rails/commit/7f0567b43b73b1bd1a16bfac9cd32fcbf1321b51
441
- if Ridgepole::ConnectionAdapters.mysql? && ActiveRecord::VERSION::STRING !~ /\A5\.0\./
447
+ if Ridgepole::ConnectionAdapters.mysql?
442
448
  options[:comment] = nil unless options.key?(:comment)
443
449
  end
444
450
 
@@ -157,6 +157,14 @@ module Ridgepole
157
157
  end
158
158
  end
159
159
 
160
+ if Ridgepole::ConnectionAdapters.postgresql?
161
+ if @options[:postgresql_change_table_comment] && (from[:comment] != to[:comment])
162
+ from.delete(:comment)
163
+ to_comment = to.delete(:comment)
164
+ table_delta[:table_comment] = to_comment
165
+ end
166
+ end
167
+
160
168
  if @options[:dump_without_table_options]
161
169
  from.delete(:options)
162
170
  from.delete(:charset)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '3.0.4'
4
+ VERSION = '3.1.0'
5
5
  end
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.0.4
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -18,7 +18,7 @@ dependencies:
18
18
  version: '6.1'
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: '8.1'
21
+ version: '8.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  version: '6.1'
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
- version: '8.1'
31
+ version: '8.2'
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: diffy
34
34
  requirement: !ruby/object:Gem::Requirement
@@ -217,28 +217,28 @@ dependencies:
217
217
  requirements:
218
218
  - - ">="
219
219
  - !ruby/object:Gem::Version
220
- version: 0.1.3
220
+ version: 0.2.0
221
221
  type: :development
222
222
  prerelease: false
223
223
  version_requirements: !ruby/object:Gem::Requirement
224
224
  requirements:
225
225
  - - ">="
226
226
  - !ruby/object:Gem::Version
227
- version: 0.1.3
227
+ version: 0.2.0
228
228
  - !ruby/object:Gem::Dependency
229
229
  name: rubocop
230
230
  requirement: !ruby/object:Gem::Requirement
231
231
  requirements:
232
232
  - - '='
233
233
  - !ruby/object:Gem::Version
234
- version: 1.80.0
234
+ version: 1.81.6
235
235
  type: :development
236
236
  prerelease: false
237
237
  version_requirements: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - '='
240
240
  - !ruby/object:Gem::Version
241
- version: 1.80.0
241
+ version: 1.81.6
242
242
  - !ruby/object:Gem::Dependency
243
243
  name: rubocop-rake
244
244
  requirement: !ruby/object:Gem::Requirement
@@ -363,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
363
363
  - !ruby/object:Gem::Version
364
364
  version: '0'
365
365
  requirements: []
366
- rubygems_version: 3.6.7
366
+ rubygems_version: 3.7.2
367
367
  specification_version: 4
368
368
  summary: Ridgepole is a tool to manage DB schema.
369
369
  test_files: []