ridgepole 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ridgepole/diff.rb +21 -1
- data/lib/ridgepole/dsl_parser.rb +1 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +2 -2
- data/spec/migrate/migrate_change_index3_spec.rb +125 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03b066ad5d7807bd60303e0433ee67703aff903e
|
4
|
+
data.tar.gz: fc2f852d90be9b0c24acf521d0fc5c62dea4f9c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e7998e9e154814fae664cfa94be66b33750919729c810c126e3fea9659599f9cf68c13071661ca1d047a4e66030c14f829b77444f78ec06fd8ba4d4090b750
|
7
|
+
data.tar.gz: 40f62f7da32cf5c8a22c53a71a1725e87728f571021e10286acb5f959f0f4a970a5a7133d82d7226f81e2196c4f7a2f73653fc88b74a7eabbb4df5246a40c59b
|
data/README.md
CHANGED
data/lib/ridgepole/diff.rb
CHANGED
@@ -177,7 +177,21 @@ class Ridgepole::Diff
|
|
177
177
|
indices_delta = {}
|
178
178
|
|
179
179
|
to.each do |index_name, to_attrs|
|
180
|
-
if
|
180
|
+
if index_name.kind_of?(Array)
|
181
|
+
from_index_name, from_attrs = from.find {|name, attrs| attrs[:column_name] == index_name }
|
182
|
+
|
183
|
+
if from_attrs
|
184
|
+
from.delete(from_index_name)
|
185
|
+
from_attrs[:options].delete(:name)
|
186
|
+
end
|
187
|
+
else
|
188
|
+
from_attrs = from.delete(index_name)
|
189
|
+
end
|
190
|
+
|
191
|
+
if from_attrs
|
192
|
+
normalize_index_options!(from_attrs[:options])
|
193
|
+
normalize_index_options!(to_attrs[:options])
|
194
|
+
|
181
195
|
if from_attrs != to_attrs
|
182
196
|
indices_delta[:add] ||= {}
|
183
197
|
indices_delta[:add][index_name] = to_attrs
|
@@ -222,8 +236,14 @@ class Ridgepole::Diff
|
|
222
236
|
def normalize_column_options!(opts)
|
223
237
|
opts[:null] = true unless opts.has_key?(:null)
|
224
238
|
|
239
|
+
# XXX: MySQL only?
|
225
240
|
unless @options[:disable_mysql_unsigned]
|
226
241
|
opts[:unsigned] = false unless opts.has_key?(:unsigned)
|
227
242
|
end
|
228
243
|
end
|
244
|
+
|
245
|
+
def normalize_index_options!(opts)
|
246
|
+
# XXX: MySQL only?
|
247
|
+
opts[:using] = :btree unless opts.has_key?(:using)
|
248
|
+
end
|
229
249
|
end
|
data/lib/ridgepole/dsl_parser.rb
CHANGED
@@ -39,7 +39,7 @@ class Ridgepole::DSLParser
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def timestamps(*args)
|
42
|
-
options = {
|
42
|
+
options = {:null => false}.merge(args.extract_options!)
|
43
43
|
column(:created_at, :datetime, options.dup)
|
44
44
|
column(:updated_at, :datetime, options.dup)
|
45
45
|
end
|
data/lib/ridgepole/version.rb
CHANGED
data/ridgepole.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Ridgepole::VERSION
|
9
9
|
spec.authors = ['Genki Sugawara']
|
10
10
|
spec.email = ['sugawara@cookpad.com']
|
11
|
-
spec.summary = %q{Ridgepole is a tool to DB schema.}
|
12
|
-
spec.description = %q{Ridgepole is a tool to DB schema. It defines DB schema using Rails DSL, and updates DB schema according to DSL.}
|
11
|
+
spec.summary = %q{Ridgepole is a tool to manage DB schema.}
|
12
|
+
spec.description = %q{Ridgepole is a tool to manage DB schema. It defines DB schema using Rails DSL, and updates DB schema according to DSL.}
|
13
13
|
spec.homepage = 'https://github.com/winebarrel/ridgepole'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when change index without using (no change)' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-RUBY
|
5
|
+
create_table "salaries", id: false, force: true do |t|
|
6
|
+
t.integer "emp_no", null: false
|
7
|
+
t.integer "salary", null: false
|
8
|
+
t.date "from_date", null: false
|
9
|
+
t.date "to_date", null: false
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
13
|
+
RUBY
|
14
|
+
}
|
15
|
+
|
16
|
+
let(:expected_dsl) {
|
17
|
+
<<-RUBY
|
18
|
+
create_table "salaries", id: false, force: true do |t|
|
19
|
+
t.integer "emp_no", null: false
|
20
|
+
t.integer "salary", null: false
|
21
|
+
t.date "from_date", null: false
|
22
|
+
t.date "to_date", null: false
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index "salaries", ["emp_no"], name: "emp_no"
|
26
|
+
RUBY
|
27
|
+
}
|
28
|
+
|
29
|
+
before { subject.diff(actual_dsl).migrate }
|
30
|
+
subject { client }
|
31
|
+
|
32
|
+
it {
|
33
|
+
delta = subject.diff(expected_dsl)
|
34
|
+
expect(delta.differ?).to be_falsey
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when change index without name (no change)' do
|
39
|
+
let(:actual_dsl) {
|
40
|
+
<<-RUBY
|
41
|
+
create_table "salaries", id: false, force: true do |t|
|
42
|
+
t.integer "emp_no", null: false
|
43
|
+
t.integer "salary", null: false
|
44
|
+
t.date "from_date", null: false
|
45
|
+
t.date "to_date", null: false
|
46
|
+
end
|
47
|
+
|
48
|
+
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
49
|
+
RUBY
|
50
|
+
}
|
51
|
+
|
52
|
+
let(:expected_dsl) {
|
53
|
+
<<-RUBY
|
54
|
+
create_table "salaries", id: false, force: true do |t|
|
55
|
+
t.integer "emp_no", null: false
|
56
|
+
t.integer "salary", null: false
|
57
|
+
t.date "from_date", null: false
|
58
|
+
t.date "to_date", null: false
|
59
|
+
end
|
60
|
+
|
61
|
+
add_index "salaries", ["emp_no"], using: :btree
|
62
|
+
RUBY
|
63
|
+
}
|
64
|
+
|
65
|
+
before { subject.diff(actual_dsl).migrate }
|
66
|
+
subject { client }
|
67
|
+
|
68
|
+
it {
|
69
|
+
delta = subject.diff(expected_dsl)
|
70
|
+
expect(delta.differ?).to be_falsey
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when change index without name (change)' do
|
75
|
+
let(:actual_dsl) {
|
76
|
+
<<-RUBY
|
77
|
+
create_table "salaries", id: false, force: true do |t|
|
78
|
+
t.integer "emp_no", null: false
|
79
|
+
t.integer "salary", null: false
|
80
|
+
t.date "from_date", null: false
|
81
|
+
t.date "to_date", null: false
|
82
|
+
end
|
83
|
+
|
84
|
+
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
85
|
+
RUBY
|
86
|
+
}
|
87
|
+
|
88
|
+
let(:dsl) {
|
89
|
+
<<-RUBY
|
90
|
+
create_table "salaries", id: false, force: true do |t|
|
91
|
+
t.integer "emp_no", null: false
|
92
|
+
t.integer "salary", null: false
|
93
|
+
t.date "from_date", null: false
|
94
|
+
t.date "to_date", null: false
|
95
|
+
end
|
96
|
+
|
97
|
+
add_index "salaries", ["salary"], using: :btree
|
98
|
+
RUBY
|
99
|
+
}
|
100
|
+
|
101
|
+
let(:expected_dsl) {
|
102
|
+
<<-RUBY
|
103
|
+
create_table "salaries", id: false, force: true do |t|
|
104
|
+
t.integer "emp_no", null: false
|
105
|
+
t.integer "salary", null: false
|
106
|
+
t.date "from_date", null: false
|
107
|
+
t.date "to_date", null: false
|
108
|
+
end
|
109
|
+
|
110
|
+
add_index "salaries", ["salary"], name: "index_salaries_on_salary", using: :btree
|
111
|
+
RUBY
|
112
|
+
}
|
113
|
+
|
114
|
+
before { subject.diff(actual_dsl).migrate }
|
115
|
+
subject { client }
|
116
|
+
|
117
|
+
it {
|
118
|
+
delta = subject.diff(dsl)
|
119
|
+
expect(delta.differ?).to be_truthy
|
120
|
+
expect(subject.dump.delete_empty_lines).to eq actual_dsl.strip_heredoc.strip.delete_empty_lines
|
121
|
+
delta.migrate
|
122
|
+
expect(subject.dump.delete_empty_lines).to eq expected_dsl.strip_heredoc.strip.delete_empty_lines
|
123
|
+
}
|
124
|
+
end
|
125
|
+
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.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -94,8 +94,8 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description: Ridgepole is a tool to DB schema. It defines DB schema using Rails
|
98
|
-
and updates DB schema according to DSL.
|
97
|
+
description: Ridgepole is a tool to manage DB schema. It defines DB schema using Rails
|
98
|
+
DSL, and updates DB schema according to DSL.
|
99
99
|
email:
|
100
100
|
- sugawara@cookpad.com
|
101
101
|
executables:
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- spec/migrate/migrate_change_column3_spec.rb
|
136
136
|
- spec/migrate/migrate_change_column_spec.rb
|
137
137
|
- spec/migrate/migrate_change_index2_spec.rb
|
138
|
+
- spec/migrate/migrate_change_index3_spec.rb
|
138
139
|
- spec/migrate/migrate_change_index_spec.rb
|
139
140
|
- spec/migrate/migrate_change_table_option_spec.rb
|
140
141
|
- spec/migrate/migrate_create_index_spec.rb
|
@@ -188,7 +189,7 @@ rubyforge_project:
|
|
188
189
|
rubygems_version: 2.4.1
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
|
-
summary: Ridgepole is a tool to DB schema.
|
192
|
+
summary: Ridgepole is a tool to manage DB schema.
|
192
193
|
test_files:
|
193
194
|
- spec/0_diff/dump_disable_unsigned_spec.rb
|
194
195
|
- spec/diff/diff_spec.rb
|
@@ -202,6 +203,7 @@ test_files:
|
|
202
203
|
- spec/migrate/migrate_change_column3_spec.rb
|
203
204
|
- spec/migrate/migrate_change_column_spec.rb
|
204
205
|
- spec/migrate/migrate_change_index2_spec.rb
|
206
|
+
- spec/migrate/migrate_change_index3_spec.rb
|
205
207
|
- spec/migrate/migrate_change_index_spec.rb
|
206
208
|
- spec/migrate/migrate_change_table_option_spec.rb
|
207
209
|
- spec/migrate/migrate_create_index_spec.rb
|