ridgepole 0.9.3 → 0.9.4

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: 3453e48af2d76cbb35301fcc70d7177f0016c47f4279593b6adbf269190d0b01
4
- data.tar.gz: e4e61ed5bbbfae92a0660244a4e021fc387d945ccd5e85971d20c1ff184dc79f
3
+ metadata.gz: 4b1fa89270221dcad6cdfa188a879de277c0ed1ea8672d2d9456b3057fe70ac1
4
+ data.tar.gz: 1d30c79ae7adf620347c70f769a12e0cb01e38fdf799cf6cbe67f952ab014d9c
5
5
  SHA512:
6
- metadata.gz: aa213105207d7a0a73adae7254885966fb06b0e0cc22cec7e2e44f7bd2082f7a6b10b2e7d8b5c5822c57b333447cd8ebb591db691b95a541f1493adcf3d46153
7
- data.tar.gz: 3e1a1c8bbcde1f7d313df1a151d5ca3096e1bba911a099cc4e8969b877941dd85061d2c3d18c17afff976c5119d3cc00f9c9966f9037af5365d8d5b0c87243c0
6
+ metadata.gz: 853d1138335b2c697c7f84d1beceae743badacc2891fd05bb8d9349c7b8c10d763516d5d2c6e63d88a7f60d0c0f887270baa03738cc3496409bca6609990097c
7
+ data.tar.gz: f4b38e66c8a5295bdc7241a407b5a2c848a3558d6421a1cbe12520f5cd85aff08154783d353f0fc2d7ce4798f620e31e5b59fc31f2225ec4d52fefc33e8dec14
data/README.md CHANGED
@@ -140,7 +140,9 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
140
140
  * `>= 0.9.2`
141
141
  * Support `t.column index option` ([pull#353](https://github.com/winebarrel/ridgepole/pull/353))
142
142
  * `>= 0.9.3`
143
- * Fix `limit` option for `t.integer` ([pull#354](https://github.com/winebarrel/ridgepole/pull/453))
143
+ * Fix `limit` option for `t.integer` ([pull#354](https://github.com/winebarrel/ridgepole/pull/354))
144
+ * `>= 0.9.4`
145
+ * Fix `--alter-extra` option for unique index ([pull#356](https://github.com/winebarrel/ridgepole/pull/356))
144
146
  </details>
145
147
 
146
148
  **Notice**
@@ -50,7 +50,7 @@ module Ridgepole
50
50
  case sql
51
51
  when /\AALTER\b/i
52
52
  sql += ',' + Ridgepole::ExecuteExpander.alter_extra
53
- when /\A(CREATE|DROP)\s+INDEX\b/i
53
+ when /\A(CREATE|DROP)\s+((ONLINE|OFFLINE)\s+)?((UNIQUE|FULLTEXT|SPATIAL)\s+)?INDEX\b/i
54
54
  # https://dev.mysql.com/doc/refman/5.6/en/create-index.html
55
55
  # https://dev.mysql.com/doc/refman/5.6/en/drop-index.html
56
56
  sql += ' ' + Ridgepole::ExecuteExpander.alter_extra.tr(',', ' ')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ridgepole
4
- VERSION = '0.9.3'
4
+ VERSION = '0.9.4'
5
5
  end
@@ -186,6 +186,51 @@ describe 'Ridgepole::Client#diff -> migrate' do
186
186
  }
187
187
  end
188
188
 
189
+ context 'when add unique index' do
190
+ let(:actual_dsl) do
191
+ erbh(<<-ERB)
192
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
193
+ t.date "birth_date", null: false
194
+ t.string "first_name", limit: 14, null: false
195
+ t.string "last_name", limit: 16, null: false
196
+ t.string "gender", limit: 1, null: false
197
+ t.date "hire_date", null: false
198
+ end
199
+ ERB
200
+ end
201
+
202
+ let(:expected_dsl) do
203
+ erbh(<<-ERB)
204
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
205
+ t.date "birth_date", null: false
206
+ t.string "first_name", limit: 14, null: false
207
+ t.string "last_name", limit: 16, null: false
208
+ t.string "gender", limit: 1, null: false
209
+ t.date "hire_date", null: false
210
+ t.index ["first_name"], name: "idx_first_name", unique: true
211
+ end
212
+ ERB
213
+ end
214
+
215
+ let(:alter_extra) { 'LOCK=DEFAULT, ALGORITHM=DEFAULT' }
216
+
217
+ before { subject.diff(actual_dsl).migrate }
218
+ subject { client }
219
+
220
+ it {
221
+ delta = subject.diff(expected_dsl)
222
+ expect(delta.differ?).to be_truthy
223
+ expect(subject.dump).to match_ruby actual_dsl
224
+ migrated, sql = delta.migrate(alter_extra: alter_extra, noop: true)
225
+ expect(migrated).to be_truthy
226
+ expect(sql).to match_fuzzy erbh(<<-SQL)
227
+ CREATE UNIQUE INDEX `idx_first_name` ON `employees` (`first_name`) LOCK=DEFAULT ALGORITHM=DEFAULT
228
+ SQL
229
+ delta.migrate(alter_extra: alter_extra)
230
+ expect(subject.dump).to match_ruby expected_dsl
231
+ }
232
+ end
233
+
189
234
  context 'when drop index' do
190
235
  let(:actual_dsl) do
191
236
  erbh(<<-ERB)
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.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-12 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -472,7 +472,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
472
472
  - !ruby/object:Gem::Version
473
473
  version: '0'
474
474
  requirements: []
475
- rubygems_version: 3.0.3
475
+ rubygems_version: 3.1.4
476
476
  signing_key:
477
477
  specification_version: 4
478
478
  summary: Ridgepole is a tool to manage DB schema.