ridgepole 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/ridgepole/dsl_parser/table_definition.rb +3 -0
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/migrate/migrate_create_index_spec.rb +60 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a762662665b42c22bb32b659ae668644d13f41b41df82e69769c9c1a3a734f5f
|
4
|
+
data.tar.gz: dae6ee8668accb92507a2b35874d59178d250ae8a0ede0eb7e802a17a4f19635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed8b55d0b0acfa7126d53f97ac76b228138369ec3b5c6351bdaf0806565d0cf8cc5c8ac2b0928f9329c07aba08edfff311e6340fec42e78e627eb228f72b6b3
|
7
|
+
data.tar.gz: 4c46611a9eae8bfa9461087e12847a12a62539e132ac01ace71ac3a336a48fcb17437583c7f71af5a922f7839c31b76736be544c945b75ebedd4e2d52d753ca5
|
data/README.md
CHANGED
@@ -137,6 +137,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
137
137
|
* Fix PK AUTO_INCREMENT change bug ([pull#334](https://github.com/winebarrel/ridgepole/pull/334))
|
138
138
|
* `>= 0.9.1`
|
139
139
|
* Support `t.foreign_key` ([pull#348](https://github.com/winebarrel/ridgepole/pull/348))
|
140
|
+
* `>= 0.9.2`
|
141
|
+
* Support `t.column index option` ([pull#353](https://github.com/winebarrel/ridgepole/pull/353))
|
140
142
|
</details>
|
141
143
|
|
142
144
|
**Notice**
|
@@ -298,8 +300,8 @@ create_table "parent", force: :cascade do |t|
|
|
298
300
|
end
|
299
301
|
|
300
302
|
create_table "child", id: false, force: :cascade do |t|
|
301
|
-
t.
|
302
|
-
t.
|
303
|
+
t.bigint "id"
|
304
|
+
t.bigint "parent_id"
|
303
305
|
end
|
304
306
|
|
305
307
|
add_index "child", ["parent_id"], name: "par_ind", using: :btree
|
@@ -13,11 +13,14 @@ module Ridgepole
|
|
13
13
|
|
14
14
|
def column(name, type, options = {})
|
15
15
|
name = name.to_s
|
16
|
+
index_options = options.key?(:index) ? options.delete(:index) : false
|
16
17
|
|
17
18
|
@__definition[name] = {
|
18
19
|
type: type,
|
19
20
|
options: options,
|
20
21
|
}
|
22
|
+
|
23
|
+
index(name, index_options.is_a?(Hash) ? index_options : {}) if index_options
|
21
24
|
end
|
22
25
|
|
23
26
|
DEFAULT_PRIMARY_KEY_TYPE = :bigint
|
data/lib/ridgepole/version.rb
CHANGED
@@ -157,4 +157,64 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
157
157
|
expect(subject.dump).to match_ruby expected_dsl
|
158
158
|
}
|
159
159
|
end
|
160
|
+
|
161
|
+
context 'when using index option' do
|
162
|
+
let(:dsl) do
|
163
|
+
erbh(<<-ERB)
|
164
|
+
create_table "clubs", force: :cascade do |t|
|
165
|
+
t.string "name", default: "", null: false, index: { unique: true }
|
166
|
+
end
|
167
|
+
|
168
|
+
create_table "titles", id: false, force: :cascade do |t|
|
169
|
+
t.integer "emp_no", null: false, index: { name: "emp_no" }
|
170
|
+
t.string "title", limit: 50, null: false
|
171
|
+
t.date "from_date", null: false
|
172
|
+
t.date "to_date"
|
173
|
+
end
|
174
|
+
ERB
|
175
|
+
end
|
176
|
+
|
177
|
+
let(:actual_dsl) do
|
178
|
+
erbh(<<-ERB)
|
179
|
+
create_table "clubs", force: :cascade do |t|
|
180
|
+
t.string "name", default: "", null: false
|
181
|
+
end
|
182
|
+
|
183
|
+
create_table "titles", id: false, force: :cascade do |t|
|
184
|
+
t.integer "emp_no", null: false
|
185
|
+
t.string "title", limit: 50, null: false
|
186
|
+
t.date "from_date", null: false
|
187
|
+
t.date "to_date"
|
188
|
+
end
|
189
|
+
ERB
|
190
|
+
end
|
191
|
+
|
192
|
+
let(:expected_dsl) do
|
193
|
+
erbh(<<-ERB)
|
194
|
+
create_table "clubs", force: :cascade do |t|
|
195
|
+
t.string "name", default: "", null: false
|
196
|
+
t.index ["name"], name: "index_clubs_on_name", unique: true
|
197
|
+
end
|
198
|
+
|
199
|
+
create_table "titles", id: false, force: :cascade do |t|
|
200
|
+
t.integer "emp_no", null: false
|
201
|
+
t.string "title", limit: 50, null: false
|
202
|
+
t.date "from_date", null: false
|
203
|
+
t.date "to_date"
|
204
|
+
t.index ["emp_no"], name: "emp_no"
|
205
|
+
end
|
206
|
+
ERB
|
207
|
+
end
|
208
|
+
|
209
|
+
before { subject.diff(actual_dsl).migrate }
|
210
|
+
subject { client }
|
211
|
+
|
212
|
+
it {
|
213
|
+
delta = subject.diff(dsl)
|
214
|
+
expect(delta.differ?).to be_truthy
|
215
|
+
expect(subject.dump).to match_ruby actual_dsl
|
216
|
+
delta.migrate
|
217
|
+
expect(subject.dump).to match_ruby expected_dsl
|
218
|
+
}
|
219
|
+
end
|
160
220
|
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: 0.9.
|
4
|
+
version: 0.9.2
|
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-
|
11
|
+
date: 2021-03-13 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.
|
475
|
+
rubygems_version: 3.0.3
|
476
476
|
signing_key:
|
477
477
|
specification_version: 4
|
478
478
|
summary: Ridgepole is a tool to manage DB schema.
|