ridgepole 1.0.4 → 1.0.5

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: 93755589225b2104033ca2e660fdb5e4d3efa0da2784dbbd7fe4d0f1ff2a455d
4
- data.tar.gz: 297bc45e7568a26ebec4a410cb2ce8bece3fd0c960fda4ad3955f09f58981004
3
+ metadata.gz: 8fd50f2c89f1cffa71ee02cf208bfe4d9b41ffefba5c9a93b164975a08a71687
4
+ data.tar.gz: f9ff68ec24ad420cbe070d769671721ac71fd3acf13322b3b340db07d4141f57
5
5
  SHA512:
6
- metadata.gz: 32fca405de8475e0a09fcac001fbc92ed955a13ae2b2a6175b161c8cec135b5f2c99fb18d214f0e34aa0015503b2885c0c9420ae1d2912ac70b7ce98bbfbfe12
7
- data.tar.gz: 20cebc14f9eb4976b644569af06c93c78a4573c8368dbe98447153aaabf601113a6cc8db8a2e8f3bd6def07ebb7971c5358dfcced15513e9fcc0d69903a0d233
6
+ metadata.gz: 286bff861331444fdef459dd5063d7dfbb4007dd1b15a96efd38af1f95e65bf30f520ed5e2d9c0e87295516ee586f2742df78923304345db245fdd595f9599a7
7
+ data.tar.gz: 6e42ba5e0a2de5cfc2ce8f72179ac4ec41ddbacc27000d8906010d199556accd1348fa0b9d75fd0e322d9cbc5e3c12f07fdc28c8ee12b0db3355127ee837c299
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 1.0
4
4
 
5
+ ### 1.0.5 (2022/06/05)
6
+
7
+ * Support DEFAULT partition for PostgreSQL [pull#386](https://github.com/ridgepole/ridgepole/pull/386)
8
+
5
9
  ### 1.0.4 (2022/03/28)
6
10
 
7
11
  * Add warning for generated column [pull#382](https://github.com/ridgepole/ridgepole/pull/382)
@@ -51,20 +51,24 @@ module Ridgepole
51
51
  ORDER BY p.relname
52
52
  SQL
53
53
 
54
- partition_definitions = partition_info.map do |row|
55
- values = case options[:type]
56
- when :list
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
- raise NotImplementedError
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
+ else
68
+ raise NotImplementedError
69
+ end
66
70
  end
67
- { name: row[0], values: values }
71
+ { name: name, values: values }
68
72
  end
69
73
 
70
74
  ActiveRecord::ConnectionAdapters::PartitionOptions.new(table_name, options[:type], options[:columns], partition_definitions: partition_definitions)
@@ -97,7 +101,9 @@ module Ridgepole
97
101
 
98
102
  # SchemaStatements
99
103
  def add_partition(table_name, name:, values:)
100
- condition = if values.key?(:in)
104
+ condition = if values.key?(:default)
105
+ 'DEFAULT'
106
+ elsif values.key?(:in)
101
107
  "FOR VALUES IN (#{values[:in].map { |v| quote_value(v) }.join(',')})"
102
108
  elsif values.key?(:to)
103
109
  from = values[:from].map { |v| quote_value(v) }.join(',')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
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
4
+ version: 1.0.5
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-03-29 00:00:00.000000000 Z
11
+ date: 2022-06-05 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.2.32
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.