ridgepole 3.1.3 → 3.1.4
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/lib/ridgepole/client.rb +1 -1
- data/lib/ridgepole/delta.rb +8 -1
- data/lib/ridgepole/diff.rb +5 -3
- data/lib/ridgepole/execute_expander.rb +34 -8
- data/lib/ridgepole/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3784ad1d842d1d94b1990eada126a7e089be6b7be6f1d764baf8d0f9e78f9dc1
|
|
4
|
+
data.tar.gz: f69dc5c28eac0444853c39bf46e0a64f3e6acfd7ced84d46485993594f56a3b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c61e60599c78c740e21f36e087e8d9931e01ed801c05a64e78b11dcca30f872acbe34df427fe27da44734e07a1bbb2f408fb6e2bec6e037224a33cdb6455cd5
|
|
7
|
+
data.tar.gz: fd7fabfea47e6d71217e0b38463d3049c58864d02f5f7e094b98c533802b54dfb55fd2932af603a219c846830e73c3e6d6d408917f703f84a65377f486f5ec44
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## 3.0
|
|
4
4
|
|
|
5
|
+
### 3.1.4 (2026/03/20)
|
|
6
|
+
|
|
7
|
+
- Fix for errors when changing generated columns. [pull#642](https://github.com/ridgepole/ridgepole/pull/642) [pull#646](https://github.com/ridgepole/ridgepole/pull/646)
|
|
8
|
+
- Fix for changes to `create_table` in ActiveRecord 8.2. [pull#645](https://github.com/ridgepole/ridgepole/pull/645)
|
|
9
|
+
|
|
5
10
|
### 3.1.3 (2026/01/29)
|
|
6
11
|
|
|
7
12
|
- Show `COMMENT` SQL in dry-run. [pull#632](https://github.com/ridgepole/ridgepole/pull/632)
|
data/README.md
CHANGED
|
@@ -412,9 +412,9 @@ see https://github.com/ridgepole/ridgepole/issues/568
|
|
|
412
412
|
docker compose up -d
|
|
413
413
|
bundle install
|
|
414
414
|
bundle exec appraisal install
|
|
415
|
-
bundle exec appraisal activerecord-8.
|
|
416
|
-
# POSTGRESQL=1 bundle exec appraisal activerecord-8.
|
|
417
|
-
# MYSQL80=1 bundle exec appraisal activerecord-8.
|
|
415
|
+
bundle exec appraisal activerecord-8.1 rake
|
|
416
|
+
# POSTGRESQL=1 bundle exec appraisal activerecord-8.1 rake
|
|
417
|
+
# MYSQL80=1 bundle exec appraisal activerecord-8.1 rake
|
|
418
418
|
```
|
|
419
419
|
|
|
420
420
|
> [!note]
|
data/lib/ridgepole/client.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Ridgepole
|
|
|
10
10
|
# XXX: If the required processing in class method?
|
|
11
11
|
@options[:index_removed_drop_column] = true if !@options.key?(:index_removed_drop_column) && (Ridgepole::DefaultsLimit.adapter == :postgresql)
|
|
12
12
|
|
|
13
|
-
Ridgepole::ExecuteExpander.expand_execute(ActiveRecord::Base.connection)
|
|
13
|
+
Ridgepole::ExecuteExpander.expand_execute(ActiveRecord::Base.connection, @options)
|
|
14
14
|
@dumper = Ridgepole::Dumper.new(@options)
|
|
15
15
|
@parser = Ridgepole::DSLParser.new(@options)
|
|
16
16
|
@diff = Ridgepole::Diff.new(@options)
|
data/lib/ridgepole/delta.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Ridgepole
|
|
|
74
74
|
ActiveRecord::Migration.disable_logging = true
|
|
75
75
|
buf = StringIO.new
|
|
76
76
|
|
|
77
|
-
callback = proc do |sql
|
|
77
|
+
callback = proc do |sql|
|
|
78
78
|
buf.puts sql if sql =~ /\A(CREATE|ALTER|DROP|RENAME|COMMENT)\b/i
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -446,6 +446,13 @@ rename_column(#{table_name.inspect}, #{from_column_name.inspect}, #{to_column_na
|
|
|
446
446
|
# Fix for https://github.com/rails/rails/commit/7f0567b43b73b1bd1a16bfac9cd32fcbf1321b51
|
|
447
447
|
if Ridgepole::ConnectionAdapters.mysql?
|
|
448
448
|
options[:comment] = nil unless options.key?(:comment)
|
|
449
|
+
|
|
450
|
+
# Generated/virtual columns cannot have DEFAULT values in MySQL.
|
|
451
|
+
# cf. https://github.com/ridgepole/ridgepole/issues/482
|
|
452
|
+
if type == :virtual
|
|
453
|
+
options.delete(:default)
|
|
454
|
+
options.delete(:unsigned)
|
|
455
|
+
end
|
|
449
456
|
end
|
|
450
457
|
|
|
451
458
|
if @options[:bulk_change]
|
data/lib/ridgepole/diff.rb
CHANGED
|
@@ -410,15 +410,17 @@ module Ridgepole
|
|
|
410
410
|
|
|
411
411
|
def normalize_column_options!(attrs, primary_key = false)
|
|
412
412
|
opts = attrs[:options]
|
|
413
|
-
opts[:null] = true if !opts.key?(:null) && !primary_key
|
|
413
|
+
opts[:null] = true if !opts.key?(:null) && !primary_key && attrs[:type] != :virtual
|
|
414
414
|
default_limit = Ridgepole::DefaultsLimit.default_limit(attrs[:type], @options)
|
|
415
415
|
opts.delete(:limit) if opts[:limit] == default_limit
|
|
416
416
|
|
|
417
417
|
# XXX: MySQL only?
|
|
418
|
-
|
|
418
|
+
# Generated/virtual columns cannot have DEFAULT values in MySQL.
|
|
419
|
+
# cf. https://github.com/ridgepole/ridgepole/issues/482
|
|
420
|
+
opts[:default] = nil if !opts.key?(:default) && !primary_key && attrs[:type] != :virtual
|
|
419
421
|
|
|
420
422
|
if Ridgepole::ConnectionAdapters.mysql?
|
|
421
|
-
opts[:unsigned] = false
|
|
423
|
+
opts[:unsigned] = false if !opts.key?(:unsigned) && attrs[:type] != :virtual
|
|
422
424
|
|
|
423
425
|
if attrs[:type] == :integer && opts[:limit]
|
|
424
426
|
min = Ridgepole::DefaultsLimit.default_limit(:integer, @options)
|
|
@@ -13,19 +13,24 @@ module Ridgepole
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
module ConnectionAdapterExt
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
def execute_expander_internal_execute(sql, &block)
|
|
17
|
+
# Generated/virtual columns cannot have DEFAULT values in MySQL.
|
|
18
|
+
# Rails' change_column always adds DEFAULT from the existing column,
|
|
19
|
+
# so we strip it from the SQL for virtual columns.
|
|
20
|
+
# cf. https://github.com/ridgepole/ridgepole/issues/482
|
|
21
|
+
if Ridgepole::ConnectionAdapters.mysql? && !Ridgepole::ExecuteExpander.options[:bulk_change]
|
|
22
|
+
# NOTE: bulk_change does not support changing MySQL generated columns with `DEFAULT NULL`.
|
|
23
|
+
sql = sql.sub(/\bDEFAULT\s+NULL\z/i, '') if /\AALTER\s+TABLE\b/i.match?(sql) && /\bAS\s*\(/i.match?(sql) && /\bDEFAULT\s+NULL\z/i.match?(sql)
|
|
24
|
+
end
|
|
20
25
|
if Ridgepole::ExecuteExpander.noop
|
|
21
26
|
if (callback = Ridgepole::ExecuteExpander.callback)
|
|
22
27
|
sql = append_alter_extra(sql)
|
|
23
|
-
callback.call(sql
|
|
28
|
+
callback.call(sql)
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
if /\A(SELECT|SHOW)\b/i.match?(sql)
|
|
27
32
|
begin
|
|
28
|
-
|
|
33
|
+
block.call(sql)
|
|
29
34
|
rescue StandardError
|
|
30
35
|
Stub.new
|
|
31
36
|
end
|
|
@@ -34,7 +39,7 @@ module Ridgepole
|
|
|
34
39
|
end
|
|
35
40
|
elsif Ridgepole::ExecuteExpander.use_script
|
|
36
41
|
if /\A(SELECT|SHOW)\b/i.match?(sql)
|
|
37
|
-
|
|
42
|
+
block.call(sql)
|
|
38
43
|
else
|
|
39
44
|
sql = append_alter_extra(sql)
|
|
40
45
|
Ridgepole::ExecuteExpander.sql_executer.execute(sql)
|
|
@@ -42,10 +47,28 @@ module Ridgepole
|
|
|
42
47
|
end
|
|
43
48
|
else
|
|
44
49
|
sql = append_alter_extra(sql)
|
|
50
|
+
block.call(sql)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def execute(*args)
|
|
55
|
+
name = args[1]
|
|
56
|
+
execute_expander_internal_execute(args.fetch(0)) do |sql|
|
|
45
57
|
super(sql, name)
|
|
46
58
|
end
|
|
47
59
|
end
|
|
48
60
|
|
|
61
|
+
def execute_batch(statements, name = nil, **kwargs)
|
|
62
|
+
new_statements = []
|
|
63
|
+
statements.each do |statement|
|
|
64
|
+
execute_expander_internal_execute(statement) do |sql|
|
|
65
|
+
new_statements << sql
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
super(new_statements, name, **kwargs) unless new_statements.empty?
|
|
69
|
+
statements
|
|
70
|
+
end
|
|
71
|
+
|
|
49
72
|
private
|
|
50
73
|
|
|
51
74
|
def append_alter_extra(sql)
|
|
@@ -69,6 +92,7 @@ module Ridgepole
|
|
|
69
92
|
cattr_accessor :use_script, instance_writer: false, instance_reader: false
|
|
70
93
|
cattr_accessor :sql_executer, instance_writer: false, instance_reader: false
|
|
71
94
|
cattr_accessor :alter_extra, instance_writer: false, instance_reader: false
|
|
95
|
+
cattr_accessor :options, instance_writer: false, instance_reader: false
|
|
72
96
|
|
|
73
97
|
class << self
|
|
74
98
|
def without_operation(callback = nil)
|
|
@@ -96,9 +120,11 @@ module Ridgepole
|
|
|
96
120
|
self.alter_extra = nil
|
|
97
121
|
end
|
|
98
122
|
|
|
99
|
-
def expand_execute(connection)
|
|
123
|
+
def expand_execute(connection, options)
|
|
100
124
|
return if connection.is_a?(ConnectionAdapterExt)
|
|
101
125
|
|
|
126
|
+
self.options = options
|
|
127
|
+
|
|
102
128
|
connection.class_eval do
|
|
103
129
|
prepend ConnectionAdapterExt
|
|
104
130
|
end
|
data/lib/ridgepole/version.rb
CHANGED
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.
|
|
4
|
+
version: 3.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Genki Sugawara
|
|
@@ -245,14 +245,14 @@ dependencies:
|
|
|
245
245
|
requirements:
|
|
246
246
|
- - '='
|
|
247
247
|
- !ruby/object:Gem::Version
|
|
248
|
-
version: 1.
|
|
248
|
+
version: 1.85.1
|
|
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.
|
|
255
|
+
version: 1.85.1
|
|
256
256
|
- !ruby/object:Gem::Dependency
|
|
257
257
|
name: rubocop-rake
|
|
258
258
|
requirement: !ruby/object:Gem::Requirement
|