ridgepole 0.8.8 → 0.8.9
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/.rubocop.yml +2 -2
- data/README.md +3 -0
- data/lib/ridgepole/diff.rb +12 -0
- data/lib/ridgepole/dsl_parser.rb +2 -1
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/fk/migrate_create_fk_spec.rb +25 -5
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4a820687bccfcbcfaa3290b28536a0ea3599d32a35a16e897f37a20a4e1ef75
|
4
|
+
data.tar.gz: c25c8a48b003aa297f7b1a979f609898b776c3393628d42c2dc2a0897d87be0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58fae0cd35607eb2980be9600b0d31b04605c559445932d7f73ab7cec066267bb45da5ef783c0ab577fec2272f664214afd190d088c1976f299fcfb30a6c54a
|
7
|
+
data.tar.gz: 498c6a55c4d7480a7ac019e58ddc63a8212961bda3d587f9d30d860be1d04d8a8f33e5bcbac72044d759919a3abba46f36750cc4cf2bcd44b87d4af352f7318d
|
data/.rubocop.yml
CHANGED
@@ -30,8 +30,6 @@ Style/Documentation:
|
|
30
30
|
Enabled: false
|
31
31
|
Style/GuardClause:
|
32
32
|
Enabled: false
|
33
|
-
Style/MethodMissingSuper:
|
34
|
-
Enabled: false
|
35
33
|
Style/MixinUsage:
|
36
34
|
Exclude:
|
37
35
|
- 'spec/**/*'
|
@@ -47,6 +45,8 @@ Layout/SpaceAroundMethodCallOperator:
|
|
47
45
|
Enabled: true
|
48
46
|
Lint/DeprecatedOpenSSLConstant:
|
49
47
|
Enabled: true
|
48
|
+
Lint/MissingSuper:
|
49
|
+
Enabled: false
|
50
50
|
Lint/MixedRegexpCaptureTypes:
|
51
51
|
Enabled: true
|
52
52
|
Lint/RaiseException:
|
data/README.md
CHANGED
@@ -117,6 +117,9 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
117
117
|
* Support `require_relative` ([pull#298](https://github.com/winebarrel/ridgepole/pull/298))
|
118
118
|
* `>= 0.8.8`
|
119
119
|
* Fix keyword arguments warnings in Ruby 2.7 ([pull#303](https://github.com/winebarrel/ridgepole/pull/303))
|
120
|
+
* `>= 0.8.9`
|
121
|
+
* Fix unexpected differences on text types and blob types on Rails 6 ([pull#306](https://github.com/winebarrel/ridgepole/pull/306))
|
122
|
+
* Fix unexpected warning when a foreign key is added on the primary key ([pull#307](https://github.com/winebarrel/ridgepole/pull/307))
|
120
123
|
</details>
|
121
124
|
|
122
125
|
## Installation
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -386,6 +386,18 @@ module Ridgepole
|
|
386
386
|
attrs[:type] = :bigint
|
387
387
|
opts.delete(:limit)
|
388
388
|
end
|
389
|
+
|
390
|
+
if opts[:size] && (attrs[:type] == :text || attrs[:type] == :blob || attrs[:type] == :binary)
|
391
|
+
case opts.delete(:size)
|
392
|
+
when :tiny
|
393
|
+
attrs[:type] = :blob if attrs[:type] == :binary
|
394
|
+
opts[:limit] = 255
|
395
|
+
when :medium
|
396
|
+
opts[:limit] = 16_777_215
|
397
|
+
when :long
|
398
|
+
opts[:limit] = 4_294_967_295
|
399
|
+
end
|
400
|
+
end
|
389
401
|
end
|
390
402
|
end
|
391
403
|
|
data/lib/ridgepole/dsl_parser.rb
CHANGED
@@ -37,10 +37,11 @@ module Ridgepole
|
|
37
37
|
attrs[:foreign_keys].each do |_, foreign_key_attrs|
|
38
38
|
fk_index = foreign_key_attrs[:options][:column] || "#{foreign_key_attrs[:to_table].singularize}_id"
|
39
39
|
next if attrs[:indices]&.any? { |_k, v| v[:column_name].first == fk_index }
|
40
|
+
next if attrs[:options][:primary_key] == fk_index
|
40
41
|
|
41
42
|
Ridgepole::Logger.instance.warn(<<-MSG)
|
42
43
|
[WARNING] Table `#{table_name}` has a foreign key on `#{fk_index}` column, but doesn't have any indexes on the column.
|
43
|
-
Although an index will be added automatically by InnoDB, please add an index explicitly
|
44
|
+
Although an index will be added automatically by InnoDB, please add an index explicitly before the next operation.
|
44
45
|
MSG
|
45
46
|
end
|
46
47
|
end
|
data/lib/ridgepole/version.rb
CHANGED
@@ -188,13 +188,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
188
188
|
it {
|
189
189
|
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG).twice
|
190
190
|
[WARNING] Table `child` has a foreign key on `parent_id` column, but doesn't have any indexes on the column.
|
191
|
-
Although an index will be added automatically by InnoDB, please add an index explicitly
|
191
|
+
Although an index will be added automatically by InnoDB, please add an index explicitly before the next operation.
|
192
192
|
MSG
|
193
193
|
subject.diff(dsl).migrate
|
194
194
|
|
195
|
-
expect
|
196
|
-
subject.diff(dsl).migrate
|
197
|
-
end.to raise_error(/Mysql2::Error: Cannot drop index/)
|
195
|
+
expect(subject.diff(dsl).differ?).to be_truthy
|
198
196
|
}
|
199
197
|
end
|
200
198
|
|
@@ -219,7 +217,29 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
219
217
|
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
220
218
|
subject.diff(dsl).migrate
|
221
219
|
|
222
|
-
expect
|
220
|
+
expect(subject.diff(dsl).differ?).to be_falsey
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
context 'when create fk on the primary key' do
|
225
|
+
let(:dsl) do
|
226
|
+
erbh(<<-ERB)
|
227
|
+
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
228
|
+
end
|
229
|
+
|
230
|
+
create_table "icons", primary_key: "user_id", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
231
|
+
end
|
232
|
+
add_foreign_key "icons", "users", name: "fk_icons_users"
|
233
|
+
ERB
|
234
|
+
end
|
235
|
+
|
236
|
+
subject { client(dump_without_table_options: false) }
|
237
|
+
|
238
|
+
it {
|
239
|
+
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
240
|
+
subject.diff(dsl).migrate
|
241
|
+
|
242
|
+
expect(subject.diff(dsl).differ?).to be_falsey
|
223
243
|
}
|
224
244
|
end
|
225
245
|
end
|
@@ -5,7 +5,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
5
5
|
subject { client }
|
6
6
|
|
7
7
|
it do
|
8
|
-
|
8
|
+
table_def = <<-RUBY
|
9
9
|
create_table :foos, id: :unsigned_integer do |t|
|
10
10
|
t.blob :blob
|
11
11
|
t.tinyblob :tiny_blob
|
@@ -20,6 +20,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
20
20
|
t.unsigned_integer :unsigned_integer
|
21
21
|
end
|
22
22
|
RUBY
|
23
|
+
delta = subject.diff(table_def)
|
23
24
|
|
24
25
|
expect(delta.differ?).to be_truthy
|
25
26
|
delta.migrate
|
@@ -39,6 +40,8 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
39
40
|
t.integer "unsigned_integer", unsigned: true
|
40
41
|
end
|
41
42
|
ERB
|
43
|
+
|
44
|
+
expect(subject.diff(table_def).differ?).to be_falsey
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
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: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|