ridgepole 0.6.2 → 0.6.3.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +3 -1
- data/lib/ridgepole/diff.rb +30 -3
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/diff/diff2_spec.rb +2 -2
- data/spec/mysql/diff/diff_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +204 -0
- data/spec/mysql/migrate/migrate_change_column_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +1 -1
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +1 -1
- data/spec/postgresql/diff/diff_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +38 -0
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +3 -3
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0f9257b25ebf5d941734433df6dd1866b5b0e9
|
4
|
+
data.tar.gz: 84097da34f74782d0b1ca02bdd29842ca9167b52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ba059da276af54510fc6e9b8c7932f3f3060b033e736bb1dfda339fdc26f534f227ae0d5071b263044d83a6aac13dfa95d68d67e79745c3f92c8983d138dce
|
7
|
+
data.tar.gz: b13e98c9181aca062630f96cbd79f4b87e83cb69dcb48cdf8217b90dc1c41bd7a02566851a41c5158f054d3c4d54ac82c6c43beb7907baa803b20854e6e7234d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
7
7
|
|
8
8
|
[![Gem Version](https://badge.fury.io/rb/ridgepole.svg)](http://badge.fury.io/rb/ridgepole)
|
9
9
|
[![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=master)](https://travis-ci.org/winebarrel/ridgepole)
|
10
|
-
[![Coverage Status](https://
|
10
|
+
[![Coverage Status](https://coveralls.io/repos/winebarrel/ridgepole/badge.svg?branch=master)](https://coveralls.io/r/winebarrel/ridgepole?branch=master)
|
11
11
|
|
12
12
|
**Notice**
|
13
13
|
|
@@ -38,6 +38,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
38
38
|
* Remove `--mysql-awesome-unsigned-pk` option
|
39
39
|
* `>= 0.6.1`
|
40
40
|
* Support [PostgreSQL columns](https://github.com/winebarrel/rails/blob/v4.2.1/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L79)
|
41
|
+
* `>= 0.6.3`
|
42
|
+
* Fix `default` option ([pull#48](https://github.com/winebarrel/ridgepole/pull/48))
|
41
43
|
|
42
44
|
## Installation
|
43
45
|
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -76,7 +76,7 @@ class Ridgepole::Diff
|
|
76
76
|
table_delta = {}
|
77
77
|
|
78
78
|
scan_options_change(table_name, from[:options], to[:options], table_delta)
|
79
|
-
scan_definition_change(from[:definition], to[:definition], from[:indices], from[:options], table_delta)
|
79
|
+
scan_definition_change(from[:definition], to[:definition], from[:indices], table_name, from[:options], table_delta)
|
80
80
|
scan_indices_change(from[:indices], to[:indices], to[:definition], table_delta, from[:options], to[:options])
|
81
81
|
scan_foreign_keys_change(from[:foreign_keys], to[:foreign_keys], table_delta, @options)
|
82
82
|
|
@@ -92,7 +92,7 @@ class Ridgepole::Diff
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
def scan_definition_change(from, to, from_indices, table_options, table_delta)
|
95
|
+
def scan_definition_change(from, to, from_indices, table_name, table_options, table_delta)
|
96
96
|
from = (from || {}).dup
|
97
97
|
to = (to || {}).dup
|
98
98
|
definition_delta = {}
|
@@ -114,6 +114,7 @@ class Ridgepole::Diff
|
|
114
114
|
|
115
115
|
if from_attrs != to_attrs
|
116
116
|
definition_delta[:change] ||= {}
|
117
|
+
to_attrs = fix_change_column_options(table_name, from_attrs, to_attrs)
|
117
118
|
definition_delta[:change][column_name] = to_attrs
|
118
119
|
end
|
119
120
|
else
|
@@ -258,7 +259,7 @@ class Ridgepole::Diff
|
|
258
259
|
opts.delete(:limit) if opts[:limit] == default_limit
|
259
260
|
|
260
261
|
# XXX: MySQL only?
|
261
|
-
if not opts.has_key?(:default)
|
262
|
+
if not opts.has_key?(:default)
|
262
263
|
opts[:default] = nil
|
263
264
|
end
|
264
265
|
|
@@ -316,4 +317,30 @@ class Ridgepole::Diff
|
|
316
317
|
table_delta[:foreign_keys] = foreign_keys_delta
|
317
318
|
end
|
318
319
|
end
|
320
|
+
|
321
|
+
|
322
|
+
# XXX: MySQL only?
|
323
|
+
# https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb#L760
|
324
|
+
# https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb#L102
|
325
|
+
def fix_change_column_options(table_name, from_attrs, to_attrs)
|
326
|
+
# default: 0, null: false -> default: nil, null: false | default: nil
|
327
|
+
# default: 0, null: false -> null: false | default: nil
|
328
|
+
# default: 0, null: false -> default: nil, null: true | default: nil, null: true
|
329
|
+
# default: 0, null: false -> null: true | default: nil, null: true
|
330
|
+
# default: 0, null: true -> default: nil, null: true | default: nil
|
331
|
+
# default: 0, null: true -> null: true | default: nil
|
332
|
+
# default: 0, null: true -> default: nil, null: false | default: nil, null: false (`default: nil` is ignored)
|
333
|
+
# default: 0, null: true -> null: false | default: nil, null: false (`default: nil` is ignored)
|
334
|
+
|
335
|
+
if from_attrs[:options][:default] != to_attrs[:options][:default] and from_attrs[:options][:null] == to_attrs[:options][:null]
|
336
|
+
to_attrs = to_attrs.deep_dup
|
337
|
+
to_attrs[:options].delete(:null)
|
338
|
+
end
|
339
|
+
|
340
|
+
if to_attrs[:options][:default] == nil and to_attrs[:options][:null] == false
|
341
|
+
Ridgepole::Logger.instance.warn("[WARNING] Table `#{table_name}`: `default: nil` is ignored when `null: false`. Please apply twice")
|
342
|
+
end
|
343
|
+
|
344
|
+
to_attrs
|
345
|
+
end
|
319
346
|
end
|
data/lib/ridgepole/version.rb
CHANGED
@@ -173,8 +173,8 @@ describe 'Ridgepole::Client.diff' do
|
|
173
173
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
174
174
|
change_column("employee_clubs", "club_id", :integer, {:unsigned=>false, :null=>true, :default=>nil})
|
175
175
|
|
176
|
-
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"
|
177
|
-
change_column("employees", "gender", :string, {:limit=>2, :null=>false})
|
176
|
+
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
177
|
+
change_column("employees", "gender", :string, {:limit=>2, :null=>false, :default=>nil})
|
178
178
|
RUBY
|
179
179
|
}
|
180
180
|
|
@@ -147,8 +147,8 @@ describe 'Ridgepole::Client.diff' do
|
|
147
147
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
148
148
|
change_column("employee_clubs", "club_id", :integer, {:unsigned=>false, :null=>true, :default=>nil})
|
149
149
|
|
150
|
-
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"
|
151
|
-
change_column("employees", "gender", :string, {:limit=>2, :null=>false})
|
150
|
+
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
151
|
+
change_column("employees", "gender", :string, {:limit=>2, :null=>false, :default=>nil})
|
152
152
|
RUBY
|
153
153
|
}
|
154
154
|
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
unless postgresql?
|
2
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
3
|
+
context 'when default:0 -> (emply)' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
7
|
+
t.integer "emp_no", limit: 4, default: 0, null: false
|
8
|
+
t.float "salary", limit: 24, null: false
|
9
|
+
t.date "from_date", null: false
|
10
|
+
t.date "to_date", null: false
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-RUBY
|
17
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
18
|
+
t.integer "emp_no", limit: 4, null: true
|
19
|
+
t.float "salary", limit: 24, null: false
|
20
|
+
t.date "from_date", null: false
|
21
|
+
t.date "to_date", null: false
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
}
|
25
|
+
|
26
|
+
let(:result_dsl) {
|
27
|
+
<<-RUBY
|
28
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
29
|
+
t.integer "emp_no", limit: 4
|
30
|
+
t.float "salary", limit: 24, null: false
|
31
|
+
t.date "from_date", null: false
|
32
|
+
t.date "to_date", null: false
|
33
|
+
end
|
34
|
+
RUBY
|
35
|
+
}
|
36
|
+
|
37
|
+
before { subject.diff(actual_dsl).migrate }
|
38
|
+
subject { client }
|
39
|
+
|
40
|
+
it {
|
41
|
+
delta = subject.diff(expected_dsl)
|
42
|
+
expect(delta.differ?).to be_truthy
|
43
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
44
|
+
delta.migrate
|
45
|
+
expect(subject.dump).to eq result_dsl.strip_heredoc.strip
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when default:0 -> (emply with null:false)' do
|
50
|
+
let(:actual_dsl) {
|
51
|
+
<<-RUBY
|
52
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
+
t.integer "emp_no", limit: 4, default: 0, null: false
|
54
|
+
t.float "salary", limit: 24, null: false
|
55
|
+
t.date "from_date", null: false
|
56
|
+
t.date "to_date", null: false
|
57
|
+
end
|
58
|
+
RUBY
|
59
|
+
}
|
60
|
+
|
61
|
+
let(:expected_dsl) {
|
62
|
+
<<-RUBY
|
63
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
64
|
+
t.integer "emp_no", limit: 4, null: false
|
65
|
+
t.float "salary", limit: 24, null: false
|
66
|
+
t.date "from_date", null: false
|
67
|
+
t.date "to_date", null: false
|
68
|
+
end
|
69
|
+
RUBY
|
70
|
+
}
|
71
|
+
|
72
|
+
before { subject.diff(actual_dsl).migrate }
|
73
|
+
subject { client }
|
74
|
+
|
75
|
+
it {
|
76
|
+
delta = subject.diff(expected_dsl)
|
77
|
+
expect(delta.differ?).to be_truthy
|
78
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
79
|
+
delta.migrate
|
80
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when default:0 -> default:0' do
|
85
|
+
let(:actual_dsl) {
|
86
|
+
<<-RUBY
|
87
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
88
|
+
t.integer "emp_no", limit: 4, default: 0, null: false
|
89
|
+
t.float "salary", limit: 24, null: false
|
90
|
+
t.date "from_date", null: false
|
91
|
+
t.date "to_date", null: false
|
92
|
+
end
|
93
|
+
RUBY
|
94
|
+
}
|
95
|
+
|
96
|
+
before { subject.diff(actual_dsl).migrate }
|
97
|
+
subject { client }
|
98
|
+
|
99
|
+
it {
|
100
|
+
delta = subject.diff(actual_dsl)
|
101
|
+
expect(delta.differ?).to be_falsey
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when default:0 -> default:0/null:true' do
|
106
|
+
let(:actual_dsl) {
|
107
|
+
<<-RUBY
|
108
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
109
|
+
t.integer "emp_no", limit: 4, default: 0, null: false
|
110
|
+
t.float "salary", limit: 24, null: false
|
111
|
+
t.date "from_date", null: false
|
112
|
+
t.date "to_date", null: false
|
113
|
+
end
|
114
|
+
RUBY
|
115
|
+
}
|
116
|
+
|
117
|
+
let(:expected_dsl) {
|
118
|
+
<<-RUBY
|
119
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
120
|
+
t.integer "emp_no", limit: 4, default: 0, null: true
|
121
|
+
t.float "salary", limit: 24, null: false
|
122
|
+
t.date "from_date", null: false
|
123
|
+
t.date "to_date", null: false
|
124
|
+
end
|
125
|
+
RUBY
|
126
|
+
}
|
127
|
+
|
128
|
+
let(:result_dsl) {
|
129
|
+
<<-RUBY
|
130
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
131
|
+
t.integer "emp_no", limit: 4, default: 0
|
132
|
+
t.float "salary", limit: 24, null: false
|
133
|
+
t.date "from_date", null: false
|
134
|
+
t.date "to_date", null: false
|
135
|
+
end
|
136
|
+
RUBY
|
137
|
+
}
|
138
|
+
|
139
|
+
before { subject.diff(actual_dsl).migrate }
|
140
|
+
subject { client }
|
141
|
+
|
142
|
+
it {
|
143
|
+
delta = subject.diff(expected_dsl)
|
144
|
+
expect(delta.differ?).to be_truthy
|
145
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
146
|
+
delta.migrate
|
147
|
+
expect(subject.dump).to eq result_dsl.strip_heredoc.strip
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'when default:0/null:true -> default:nil/null:false' do
|
152
|
+
let(:actual_dsl) {
|
153
|
+
<<-RUBY
|
154
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
155
|
+
t.integer "emp_no", limit: 4, default: 0
|
156
|
+
t.float "salary", limit: 24, null: false
|
157
|
+
t.date "from_date", null: false
|
158
|
+
t.date "to_date", null: false
|
159
|
+
end
|
160
|
+
RUBY
|
161
|
+
}
|
162
|
+
|
163
|
+
let(:expected_dsl) {
|
164
|
+
<<-RUBY
|
165
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
166
|
+
t.integer "emp_no", limit: 4, null: false
|
167
|
+
t.float "salary", limit: 24, null: false
|
168
|
+
t.date "from_date", null: false
|
169
|
+
t.date "to_date", null: false
|
170
|
+
end
|
171
|
+
RUBY
|
172
|
+
}
|
173
|
+
|
174
|
+
let(:result_dsl) {
|
175
|
+
<<-RUBY
|
176
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
177
|
+
t.integer "emp_no", limit: 4, default: 0, null: false
|
178
|
+
t.float "salary", limit: 24, null: false
|
179
|
+
t.date "from_date", null: false
|
180
|
+
t.date "to_date", null: false
|
181
|
+
end
|
182
|
+
RUBY
|
183
|
+
}
|
184
|
+
|
185
|
+
before { subject.diff(actual_dsl).migrate }
|
186
|
+
subject { client }
|
187
|
+
|
188
|
+
it {
|
189
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with('[WARNING] Table `salaries`: `default: nil` is ignored when `null: false`. Please apply twice')
|
190
|
+
delta = subject.diff(expected_dsl)
|
191
|
+
expect(delta.differ?).to be_truthy
|
192
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
193
|
+
delta.migrate
|
194
|
+
expect(subject.dump).to eq result_dsl.strip_heredoc.strip
|
195
|
+
|
196
|
+
delta = subject.diff(expected_dsl)
|
197
|
+
expect(delta.differ?).to be_truthy
|
198
|
+
expect(subject.dump).to eq result_dsl.strip_heredoc.strip
|
199
|
+
delta.migrate
|
200
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
201
|
+
}
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -154,10 +154,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
154
154
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, enable_mysql_unsigned: true)
|
155
155
|
expect(delta.differ?).to be_truthy
|
156
156
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
157
|
-
change_column("employee_clubs", "club_id", :integer, {:null=>false#{unsigned_if_enabled2}})
|
157
|
+
change_column("employee_clubs", "club_id", :integer, {:null=>false#{unsigned_if_enabled2}, :default=>nil})
|
158
158
|
|
159
|
-
change_column("employees", "last_name", :string, {:limit=>16, :
|
160
|
-
change_column("employees", "gender", :string, {:limit=>1, :null=>false})
|
159
|
+
change_column("employees", "last_name", :string, {:limit=>16, :default=>nil})
|
160
|
+
change_column("employees", "gender", :string, {:limit=>1, :null=>false, :default=>nil})
|
161
161
|
RUBY
|
162
162
|
}
|
163
163
|
|
@@ -171,8 +171,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
change_table("employees", {:bulk => true}) do |t|
|
174
|
-
t.change("last_name", :string, {:limit=>20, :default=>"XXX"
|
175
|
-
t.change("gender", :string, {:limit=>2, :null=>false#{unsigned_false_if_enabled2}})
|
174
|
+
t.change("last_name", :string, {:limit=>20, :default=>"XXX"#{unsigned_false_if_enabled2}})
|
175
|
+
t.change("gender", :string, {:limit=>2, :null=>false, :default=>nil#{unsigned_false_if_enabled2}})
|
176
176
|
end
|
177
177
|
RUBY
|
178
178
|
delta.migrate
|
@@ -149,7 +149,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
149
149
|
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
150
150
|
expect(delta.differ?).to be_truthy
|
151
151
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
152
|
-
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
|
152
|
+
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :default=>nil, :unsigned=>false})
|
153
153
|
RUBY
|
154
154
|
}
|
155
155
|
end
|
@@ -149,7 +149,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
149
149
|
delta = Ridgepole::Client.diff(current_schema, dsl, tables: ['employees'], reverse: true, enable_mysql_awesome: true)
|
150
150
|
expect(delta.differ?).to be_truthy
|
151
151
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
152
|
-
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :unsigned=>false})
|
152
|
+
change_column("employees", "first_name", :string, {:limit=>14, :null=>false, :default=>nil, :unsigned=>false})
|
153
153
|
RUBY
|
154
154
|
}
|
155
155
|
end
|
@@ -145,7 +145,7 @@ describe 'Ridgepole::Client.diff' do
|
|
145
145
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
146
146
|
change_column("employee_clubs", "club_id", :integer, {:null=>true, :default=>nil})
|
147
147
|
|
148
|
-
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"
|
148
|
+
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
149
149
|
RUBY
|
150
150
|
}
|
151
151
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
if postgresql?
|
2
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
3
|
+
context 'when change column' do
|
4
|
+
let(:actual_dsl) {
|
5
|
+
<<-RUBY
|
6
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
7
|
+
t.integer "emp_no", default: 0, null: false
|
8
|
+
t.integer "salary", null: false
|
9
|
+
t.date "from_date", null: false
|
10
|
+
t.date "to_date", null: false
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:expected_dsl) {
|
16
|
+
<<-RUBY
|
17
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
18
|
+
t.integer "emp_no", null: false
|
19
|
+
t.integer "salary", null: false
|
20
|
+
t.date "from_date", null: false
|
21
|
+
t.date "to_date", null: false
|
22
|
+
end
|
23
|
+
RUBY
|
24
|
+
}
|
25
|
+
|
26
|
+
before { subject.diff(actual_dsl).migrate }
|
27
|
+
subject { client }
|
28
|
+
|
29
|
+
it {
|
30
|
+
delta = subject.diff(expected_dsl)
|
31
|
+
expect(delta.differ?).to be_truthy
|
32
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
33
|
+
delta.migrate
|
34
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip #.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -148,9 +148,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
148
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, enable_mysql_unsigned: true)
|
149
149
|
expect(delta.differ?).to be_truthy
|
150
150
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
151
|
-
change_column("employee_clubs", "club_id", :integer, {:null=>false})
|
151
|
+
change_column("employee_clubs", "club_id", :integer, {:null=>false, :default=>nil})
|
152
152
|
|
153
|
-
change_column("employees", "last_name", :string, {:limit=>16, :
|
153
|
+
change_column("employees", "last_name", :string, {:limit=>16, :default=>nil})
|
154
154
|
RUBY
|
155
155
|
}
|
156
156
|
|
@@ -164,7 +164,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
change_table("employees", {:bulk => true}) do |t|
|
167
|
-
t.change("last_name", :string, {:limit=>20, :default=>"XXX"
|
167
|
+
t.change("last_name", :string, {:limit=>20, :default=>"XXX"})
|
168
168
|
end
|
169
169
|
RUBY
|
170
170
|
delta.migrate
|
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.6.
|
4
|
+
version: 0.6.3.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- spec/mysql/migrate/migrate_change_column4_spec.rb
|
175
175
|
- spec/mysql/migrate/migrate_change_column5_spec.rb
|
176
176
|
- spec/mysql/migrate/migrate_change_column6_spec.rb
|
177
|
+
- spec/mysql/migrate/migrate_change_column_default_spec.rb
|
177
178
|
- spec/mysql/migrate/migrate_change_column_float_spec.rb
|
178
179
|
- spec/mysql/migrate/migrate_change_column_spec.rb
|
179
180
|
- spec/mysql/migrate/migrate_change_index2_spec.rb
|
@@ -214,6 +215,7 @@ files:
|
|
214
215
|
- spec/postgresql/fk/migrate_create_fk_spec.rb
|
215
216
|
- spec/postgresql/fk/migrate_drop_fk_spec.rb
|
216
217
|
- spec/postgresql/migrate/migrate_add_column_spec.rb
|
218
|
+
- spec/postgresql/migrate/migrate_change_column_default_spec.rb
|
217
219
|
- spec/postgresql/migrate/migrate_change_column_spec.rb
|
218
220
|
- spec/postgresql/migrate/migrate_change_index_spec.rb
|
219
221
|
- spec/postgresql/migrate/migrate_create_table_spec.rb
|
@@ -244,9 +246,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
244
246
|
version: '0'
|
245
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
248
|
requirements:
|
247
|
-
- - '
|
249
|
+
- - '>'
|
248
250
|
- !ruby/object:Gem::Version
|
249
|
-
version:
|
251
|
+
version: 1.3.1
|
250
252
|
requirements: []
|
251
253
|
rubyforge_project:
|
252
254
|
rubygems_version: 2.0.14
|
@@ -275,6 +277,7 @@ test_files:
|
|
275
277
|
- spec/mysql/migrate/migrate_change_column4_spec.rb
|
276
278
|
- spec/mysql/migrate/migrate_change_column5_spec.rb
|
277
279
|
- spec/mysql/migrate/migrate_change_column6_spec.rb
|
280
|
+
- spec/mysql/migrate/migrate_change_column_default_spec.rb
|
278
281
|
- spec/mysql/migrate/migrate_change_column_float_spec.rb
|
279
282
|
- spec/mysql/migrate/migrate_change_column_spec.rb
|
280
283
|
- spec/mysql/migrate/migrate_change_index2_spec.rb
|
@@ -315,6 +318,7 @@ test_files:
|
|
315
318
|
- spec/postgresql/fk/migrate_create_fk_spec.rb
|
316
319
|
- spec/postgresql/fk/migrate_drop_fk_spec.rb
|
317
320
|
- spec/postgresql/migrate/migrate_add_column_spec.rb
|
321
|
+
- spec/postgresql/migrate/migrate_change_column_default_spec.rb
|
318
322
|
- spec/postgresql/migrate/migrate_change_column_spec.rb
|
319
323
|
- spec/postgresql/migrate/migrate_change_index_spec.rb
|
320
324
|
- spec/postgresql/migrate/migrate_create_table_spec.rb
|