ridgepole 1.0.5 → 1.0.6

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: 8fd50f2c89f1cffa71ee02cf208bfe4d9b41ffefba5c9a93b164975a08a71687
4
- data.tar.gz: f9ff68ec24ad420cbe070d769671721ac71fd3acf13322b3b340db07d4141f57
3
+ metadata.gz: 7e42446dbd4e240dcb801dbd26b995e91d9afea59c52131d97e44d4242dd5cb7
4
+ data.tar.gz: a986057d2aefe29e1ac34f9e8e224eaea86efbf3d900ab095e9b55c1281fc34c
5
5
  SHA512:
6
- metadata.gz: 286bff861331444fdef459dd5063d7dfbb4007dd1b15a96efd38af1f95e65bf30f520ed5e2d9c0e87295516ee586f2742df78923304345db245fdd595f9599a7
7
- data.tar.gz: 6e42ba5e0a2de5cfc2ce8f72179ac4ec41ddbacc27000d8906010d199556accd1348fa0b9d75fd0e322d9cbc5e3c12f07fdc28c8ee12b0db3355127ee837c299
6
+ metadata.gz: 899809c201c1fe7bed640dac621bb3e98edd4c2606f7107ce3faf4420de2e5ca5087f6499be4b1d66d55e58becd55d6746057033a7dc6b4ea58c3112deadf9c6
7
+ data.tar.gz: edf7a56bad1187f2e749205afb4c35bbf84b79476b6f00641d452714099374ca69c504425db29dc45b470e769b3cb8381aaa510cc8ca7d0b9cf233e39da7c3a6
data/.rubocop.yml CHANGED
@@ -21,7 +21,7 @@ Metrics/ClassLength:
21
21
  Metrics/CyclomaticComplexity:
22
22
  Enabled: false
23
23
  Layout/LineLength:
24
- Enabled: false
24
+ Max: 200
25
25
  Metrics/MethodLength:
26
26
  Enabled: false
27
27
  Metrics/ModuleLength:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 1.0
4
4
 
5
+ ### 1.0.6 (2022/06/06)
6
+
7
+ * Support Hash partition for PostgreSQL [pull#387](https://github.com/ridgepole/ridgepole/pull/387)
8
+
5
9
  ### 1.0.5 (2022/06/05)
6
10
 
7
11
  * Support DEFAULT partition for PostgreSQL [pull#386](https://github.com/ridgepole/ridgepole/pull/386)
@@ -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
- append_change_table_raw_options(table_name, table_options, table_charset, table_collation, buf) if table_options || table_charset || table_collation
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
 
@@ -640,7 +640,9 @@ MSG
640
640
  return
641
641
  end
642
642
 
643
- raise "All partition is different. please check partition settings.to: #{to}, from: #{from}" if from[:partition_definitions].present? && (to[:partition_definitions] & from[:partition_definitions]).empty?
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
@@ -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 "The column `#{fk_index}` of the table `#{table_name}` has a foreign key but no index. Although InnoDB creates an index automatically, please add one explicitly in order for ridgepole to manage it."
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, partition_definitions: partition_definitions))
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:)
@@ -64,6 +64,9 @@ module Ridgepole
64
64
  from = match[:from].split(',').map(&:strip).map { |value| cast_value(value) }
65
65
  to = match[:to].split(',').map(&:strip).map { |value| cast_value(value) }
66
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 }
67
70
  else
68
71
  raise NotImplementedError
69
72
  end
@@ -71,7 +74,8 @@ module Ridgepole
71
74
  { name: name, values: values }
72
75
  end
73
76
 
74
- ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, options[:type], options[:columns], partition_definitions: partition_definitions)
77
+ ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, options[:type], options[:columns],
78
+ partition_definitions: partition_definitions)
75
79
  end
76
80
 
77
81
  def cast_value(value)
@@ -109,6 +113,8 @@ module Ridgepole
109
113
  from = values[:from].map { |v| quote_value(v) }.join(',')
110
114
  to = values[:to].map { |v| quote_value(v) }.join(',')
111
115
  "FOR VALUES FROM (#{from}) TO (#{to})"
116
+ elsif values.key?(:modulus)
117
+ "FOR VALUES WITH (modulus #{values[:modulus]}, remainder #{values[:remainder]})"
112
118
  else
113
119
  raise NotImplementedError
114
120
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
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: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara