ridgepole 0.8.8 → 0.8.9

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: 9c506e7bf27fec2d935daf79fae7e9b653dd3b65114633e401b8683755e9ca7a
4
- data.tar.gz: a4615e7fe4fa35628471d512fc70fd969774ef1c8270e0ad161eb58772207dac
3
+ metadata.gz: b4a820687bccfcbcfaa3290b28536a0ea3599d32a35a16e897f37a20a4e1ef75
4
+ data.tar.gz: c25c8a48b003aa297f7b1a979f609898b776c3393628d42c2dc2a0897d87be0e
5
5
  SHA512:
6
- metadata.gz: 67459d1042f159bbe4345335d12029470cfb272cf75bba8ebfa7b2de05234e3fd0adba87c303817f927567654676db93efc0e8563ec9e47745b6f3c906c4d241
7
- data.tar.gz: 4713c918e439078a179a185c148606d14e4c526261b4094d1417277cd471b30cdf2b3b4f0c7bca66c7e73637f1125ce3296b9cac4d55f38873d9b16d3527fd65
6
+ metadata.gz: d58fae0cd35607eb2980be9600b0d31b04605c559445932d7f73ab7cec066267bb45da5ef783c0ab577fec2272f664214afd190d088c1976f299fcfb30a6c54a
7
+ data.tar.gz: 498c6a55c4d7480a7ac019e58ddc63a8212961bda3d587f9d30d860be1d04d8a8f33e5bcbac72044d759919a3abba46f36750cc4cf2bcd44b87d4af352f7318d
@@ -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
@@ -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
 
@@ -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 for your future operations.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '0.8.8'
4
+ VERSION = '0.8.9'
5
5
  end
@@ -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 for your future operations.
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 do
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 { subject.diff(dsl).migrate }.to_not raise_error
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
- delta = subject.diff(<<-RUBY)
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.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-07-12 00:00:00.000000000 Z
11
+ date: 2020-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord