ridgepole 1.0.4 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/lib/ridgepole/delta.rb +4 -1
- data/lib/ridgepole/diff.rb +3 -1
- data/lib/ridgepole/dsl_parser/context.rb +4 -1
- data/lib/ridgepole/dsl_parser.rb +3 -1
- data/lib/ridgepole/ext/abstract_mysql_adapter/partitioning.rb +2 -1
- data/lib/ridgepole/ext/postgresql_adapter/partitioning.rb +26 -14
- 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: 7886d7c158b4776c9db77e73c72ab5d882241950ed6a9f2c945a99220b7bcc4a
|
4
|
+
data.tar.gz: 6429c8b8ed0c17dd1361c0e01592180c521002fa64fead1e625e9ec7ab2436a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a06ba181dbdad2e0dd6f054366d745a3dbd119715bdb83b9a5e440c8a2258014859b2f9a8916b75fd5fb0ed9c27c4a32efe7d51761d7dd62a5e313cbad6fae
|
7
|
+
data.tar.gz: '0277821bd5e0fc9c47ec038bf938a1b1a8c18c8395af8fd5ccfdf14ed9a8b80b03c5b6550f7b11d4da7220023be6e14782261a0a85f5b70ad7d136561bce4724'
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
## 1.0
|
4
4
|
|
5
|
+
### 1.0.7 (2022/06/09)
|
6
|
+
|
7
|
+
* Normalize list partition values for PostgreSQL [pull#389](https://github.com/ridgepole/ridgepole/pull/389)
|
8
|
+
|
9
|
+
### 1.0.6 (2022/06/06)
|
10
|
+
|
11
|
+
* Support Hash partition for PostgreSQL [pull#387](https://github.com/ridgepole/ridgepole/pull/387)
|
12
|
+
|
13
|
+
### 1.0.5 (2022/06/05)
|
14
|
+
|
15
|
+
* Support DEFAULT partition for PostgreSQL [pull#386](https://github.com/ridgepole/ridgepole/pull/386)
|
16
|
+
|
5
17
|
### 1.0.4 (2022/03/28)
|
6
18
|
|
7
19
|
* Add warning for generated column [pull#382](https://github.com/ridgepole/ridgepole/pull/382)
|
data/lib/ridgepole/delta.rb
CHANGED
@@ -349,7 +349,10 @@ execute "ALTER TABLE #{ActiveRecord::Base.connection.quote_table_name(table_name
|
|
349
349
|
|
350
350
|
append_change_foreign_keys(table_name, foreign_keys, pre_buf_for_fk, post_buf_for_fk, @options) unless foreign_keys.empty?
|
351
351
|
|
352
|
-
|
352
|
+
if table_options || table_charset || table_collation
|
353
|
+
append_change_table_raw_options(table_name, table_options, table_charset, table_collation,
|
354
|
+
buf)
|
355
|
+
end
|
353
356
|
|
354
357
|
append_change_table_comment(table_name, table_comment, buf) if table_comment
|
355
358
|
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -640,7 +640,9 @@ MSG
|
|
640
640
|
return
|
641
641
|
end
|
642
642
|
|
643
|
-
|
643
|
+
if from[:partition_definitions].present? && (to[:partition_definitions] & from[:partition_definitions]).empty?
|
644
|
+
raise "All partition is different. please check partition settings.to: #{to}, from: #{from}"
|
645
|
+
end
|
644
646
|
|
645
647
|
scan_partition_definition_chanage(from, to, table_delta)
|
646
648
|
end
|
@@ -96,7 +96,10 @@ module Ridgepole
|
|
96
96
|
values = partition_definition.fetch(:values)
|
97
97
|
raise ArgumentError unless values.is_a?(Hash)
|
98
98
|
|
99
|
-
|
99
|
+
if values.key?(:in)
|
100
|
+
values[:in] = Array.wrap(values[:in])
|
101
|
+
values[:in] = values[:in].map(&:to_s) if Ridgepole::ConnectionAdapters.postgresql?
|
102
|
+
end
|
100
103
|
values[:to] = Array.wrap(values[:to]) if values.key?(:to)
|
101
104
|
values[:from] = Array.wrap(values[:from]) if values.key?(:from)
|
102
105
|
end
|
data/lib/ridgepole/dsl_parser.rb
CHANGED
@@ -40,7 +40,9 @@ module Ridgepole
|
|
40
40
|
# NOTE: For composite primary keys, the first column of the primary key is used as the foreign key index
|
41
41
|
next if Array(attrs[:options][:primary_key]).first == fk_index
|
42
42
|
|
43
|
-
raise
|
43
|
+
raise("The column `#{fk_index}` of the table `#{table_name}` has a foreign key but no index." \
|
44
|
+
' Although InnoDB creates an index automatically,' \
|
45
|
+
' please add one explicitly in order for ridgepole to manage it.')
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -46,7 +46,8 @@ module Ridgepole
|
|
46
46
|
|
47
47
|
# SchemaStatements
|
48
48
|
def create_partition(table_name, type:, columns:, partition_definitions:)
|
49
|
-
execute schema_creation.accept(ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, type, columns,
|
49
|
+
execute schema_creation.accept(ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, type, columns,
|
50
|
+
partition_definitions: partition_definitions))
|
50
51
|
end
|
51
52
|
|
52
53
|
def add_partition(table_name, name:, values:)
|
@@ -51,23 +51,31 @@ module Ridgepole
|
|
51
51
|
ORDER BY p.relname
|
52
52
|
SQL
|
53
53
|
|
54
|
-
partition_definitions = partition_info.map do |
|
55
|
-
values =
|
56
|
-
|
57
|
-
values = row[1].match(/FOR VALUES IN \((?<csv>.+)\)$/)[:csv].split(',').map(&:strip).map { |value| cast_value(value) }
|
58
|
-
{ in: Array.wrap(values) }
|
59
|
-
when :range
|
60
|
-
match = row[1].match(/FOR VALUES FROM \((?<from>.+)\) TO \((?<to>.+)\)/)
|
61
|
-
from = match[:from].split(',').map(&:strip).map { |value| cast_value(value) }
|
62
|
-
to = match[:to].split(',').map(&:strip).map { |value| cast_value(value) }
|
63
|
-
{ from: from, to: to }
|
54
|
+
partition_definitions = partition_info.map do |name, val_str|
|
55
|
+
values = if val_str == 'DEFAULT'
|
56
|
+
{ default: true }
|
64
57
|
else
|
65
|
-
|
58
|
+
case options[:type]
|
59
|
+
when :list
|
60
|
+
values = val_str.match(/FOR VALUES IN \((?<csv>.+)\)$/)[:csv].split(',').map(&:strip).map { |value| cast_value(value) }
|
61
|
+
{ in: Array.wrap(values) }
|
62
|
+
when :range
|
63
|
+
match = val_str.match(/FOR VALUES FROM \((?<from>.+)\) TO \((?<to>.+)\)/)
|
64
|
+
from = match[:from].split(',').map(&:strip).map { |value| cast_value(value) }
|
65
|
+
to = match[:to].split(',').map(&:strip).map { |value| cast_value(value) }
|
66
|
+
{ from: from, to: to }
|
67
|
+
when :hash
|
68
|
+
match = val_str.match(/FOR VALUES WITH \(modulus (?<modulus>\d+), remainder (?<remainder>\d+)\)/)
|
69
|
+
{ modulus: match[:modulus].to_i, remainder: match[:remainder].to_i }
|
70
|
+
else
|
71
|
+
raise NotImplementedError
|
72
|
+
end
|
66
73
|
end
|
67
|
-
{ name:
|
74
|
+
{ name: name, values: values }
|
68
75
|
end
|
69
76
|
|
70
|
-
ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, options[:type], options[:columns],
|
77
|
+
ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, options[:type], options[:columns],
|
78
|
+
partition_definitions: partition_definitions)
|
71
79
|
end
|
72
80
|
|
73
81
|
def cast_value(value)
|
@@ -97,12 +105,16 @@ module Ridgepole
|
|
97
105
|
|
98
106
|
# SchemaStatements
|
99
107
|
def add_partition(table_name, name:, values:)
|
100
|
-
condition = if values.key?(:
|
108
|
+
condition = if values.key?(:default)
|
109
|
+
'DEFAULT'
|
110
|
+
elsif values.key?(:in)
|
101
111
|
"FOR VALUES IN (#{values[:in].map { |v| quote_value(v) }.join(',')})"
|
102
112
|
elsif values.key?(:to)
|
103
113
|
from = values[:from].map { |v| quote_value(v) }.join(',')
|
104
114
|
to = values[:to].map { |v| quote_value(v) }.join(',')
|
105
115
|
"FOR VALUES FROM (#{from}) TO (#{to})"
|
116
|
+
elsif values.key?(:modulus)
|
117
|
+
"FOR VALUES WITH (modulus #{values[:modulus]}, remainder #{values[:remainder]})"
|
106
118
|
else
|
107
119
|
raise NotImplementedError
|
108
120
|
end
|
data/lib/ridgepole/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridgepole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
342
|
- !ruby/object:Gem::Version
|
343
343
|
version: '0'
|
344
344
|
requirements: []
|
345
|
-
rubygems_version: 3.
|
345
|
+
rubygems_version: 3.3.7
|
346
346
|
signing_key:
|
347
347
|
specification_version: 4
|
348
348
|
summary: Ridgepole is a tool to manage DB schema.
|