ridgepole 1.0.2 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f2be3783ec61f227ecfe28f6886bd190b3c0d842b70a525c0e875a94b6203da
4
- data.tar.gz: 813db605ad690e1e1fc67c35d43c8b8d5ea3f176be5e8231ebf729a4d0e59b39
3
+ metadata.gz: 8fd50f2c89f1cffa71ee02cf208bfe4d9b41ffefba5c9a93b164975a08a71687
4
+ data.tar.gz: f9ff68ec24ad420cbe070d769671721ac71fd3acf13322b3b340db07d4141f57
5
5
  SHA512:
6
- metadata.gz: 5298fb7f40541eaa1165119bda5bfad7c97ef0ab32989271abdf58209fb6e8302a0ed48100cd7d8e7b3d9baf38e94b654af7fa8437e6d3d84a0e82023a0edf0f
7
- data.tar.gz: 6cd5e1415f034bcc34b803c509c1c3a6603117b008202b97525567a60824c35290871b33e8133fa2bf61e8eb37323c79e2926666d195d35a8b4c35884d1a7193
6
+ metadata.gz: 286bff861331444fdef459dd5063d7dfbb4007dd1b15a96efd38af1f95e65bf30f520ed5e2d9c0e87295516ee586f2742df78923304345db245fdd595f9599a7
7
+ data.tar.gz: 6e42ba5e0a2de5cfc2ce8f72179ac4ec41ddbacc27000d8906010d199556accd1348fa0b9d75fd0e322d9cbc5e3c12f07fdc28c8ee12b0db3355127ee837c299
data/CHANGELOG.md CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  ## 1.0
4
4
 
5
- ### 1.0.2 (Unreleased)
5
+ ### 1.0.5 (2022/06/05)
6
+
7
+ * Support DEFAULT partition for PostgreSQL [pull#386](https://github.com/ridgepole/ridgepole/pull/386)
8
+
9
+ ### 1.0.4 (2022/03/28)
10
+
11
+ * Add warning for generated column [pull#382](https://github.com/ridgepole/ridgepole/pull/382)
12
+
13
+ ### 1.0.3 (2022/02/12)
14
+
15
+ * Support Rails 7.0.2 [pull#380](https://github.com/ridgepole/ridgepole/pull/380)
16
+
17
+ ### 1.0.2 (2022/02/06)
6
18
 
7
19
  * Add support for partitioning ([pull#374](https://github.com/ridgepole/ridgepole/pull/374))
8
20
  * Suppress warning of table option differences ([pull#378](https://github.com/ridgepole/ridgepole/pull/378))
data/README.md CHANGED
@@ -11,6 +11,10 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
11
11
 
12
12
  **Notice**
13
13
 
14
+ * ActiveRecord 7.x has some incompatible changes. If you get unintended differences in `datetime`, add `precision`.
15
+ * cf. https://github.com/ridgepole/ridgepole/issues/381
16
+ * For ActiveRecord 7.x series, please use AcriveRecord 7.0.2 or higher / Ridgepole 1.0.3 or higher.
17
+ * cf. https://github.com/ridgepole/ridgepole/pull/380
14
18
  * ActiveRecord 6.1 is supported in ridgepole v0.9, but the ActiveRecord dump has been changed, so there is a difference between ActiveRecord 5.x/6.0 format.
15
19
  * **If you use ActiveRecord 6.1, please modify Schemafile format**.
16
20
  * cf. https://github.com/ridgepole/ridgepole/pull/323
@@ -210,6 +214,19 @@ activerecord 5.0.0 and activerecord-mysql-awesome dumps a collation rather than
210
214
 
211
215
  See `mysql> show character set;` to find charset / collation pair for your system.
212
216
 
217
+ ## Generated Column (MySQL)
218
+
219
+ There should be NO extra white spaces in the expression (such as after comma).
220
+ Quotes in expression may cause the operations failure with MySQL 8.0.
221
+
222
+ ```ruby
223
+ create_table "users", force: :cascade do |t|
224
+ t.string "last_name"
225
+ t.string "first_name"
226
+ t.virtual "full_name", type: :string, as: "concat(`last_name`,' ',`first_name`)", stored: true
227
+ end
228
+ ```
229
+
213
230
  ## Execute
214
231
  ```ruby
215
232
  create_table "authors", force: :cascade do |t|
@@ -422,9 +422,6 @@ module Ridgepole
422
422
  opts[:limit] = 4_294_967_295
423
423
  end
424
424
  end
425
-
426
- # Workaround for Active Record 7.0
427
- opts.delete(:precision) if attrs[:type] == :datetime && opts[:precision].nil?
428
425
  end
429
426
  end
430
427
 
@@ -509,6 +506,14 @@ module Ridgepole
509
506
  attrs2.fetch(:options).delete(:comment)
510
507
  end
511
508
 
509
+ if attrs1[:options][:as] != attrs2[:options][:as] && attrs1[:options].fetch(:as, '').delete(' ') == attrs2[:options].fetch(:as, '').delete(' ')
510
+ @logger.warn(<<-MSG)
511
+ [WARNING] Same expressions but only differed by white spaces were detected. This operation may fail.
512
+ Before: '#{attrs1[:options][:as]}'
513
+ After : '#{attrs2[:options][:as]}'
514
+ MSG
515
+ end
516
+
512
517
  attrs1 == attrs2
513
518
  end
514
519
 
@@ -652,7 +657,7 @@ MSG
652
657
 
653
658
  (from_partitions.keys - to_partitions.keys).each do |name|
654
659
  partition_definitions_delta[:delete] ||= {}
655
- partition_definitions_delta[:delete][name] = attrs.merge(valuve: from_partitions[name][:values])
660
+ partition_definitions_delta[:delete][name] = attrs.merge(values: from_partitions[name][:values])
656
661
  end
657
662
 
658
663
  (to_partitions.keys - from_partitions.keys).each do |name|
@@ -39,7 +39,7 @@ module Ridgepole
39
39
 
40
40
  dsl = stream.string.lines.select do |line|
41
41
  line !~ /\A#/ &&
42
- line !~ /\AActiveRecord::Schema\.define/ &&
42
+ line !~ /\AActiveRecord::Schema(\[\d\.\d\])?\.define/ &&
43
43
  line !~ /\Aend/
44
44
  end
45
45
 
@@ -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.2'
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.2
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-02-06 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.