ridgepole 0.7.0 → 0.7.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -30
- data/bin/ridgepole +0 -1
- data/lib/ridgepole/delta.rb +9 -6
- data/lib/ridgepole/diff.rb +10 -24
- data/lib/ridgepole/version.rb +1 -1
- data/spec/mysql/cli/ridgepole_spec.rb +0 -1
- data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -16
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -16
- data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -11
- data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -11
- data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -15
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -10
- data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -12
- data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -12
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +50 -0
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -16
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -12
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -25
- data/spec/mysql/migrate/migrate_empty_spec.rb +0 -22
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -5
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -12
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +24 -13
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -5
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -5
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +1 -5
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -24
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -8
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -8
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -8
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -16
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -16
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -11
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -10
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -15
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -12
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -15
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -12
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -24
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -10
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -8
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -8
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -8
- 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: ed6f5b00c9332bcd40b24033c2419b08130a5879
|
4
|
+
data.tar.gz: 5eba0f7b43c51fcc70413bacf8c262f5224347fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 606f4bbc6c975f8fbb8cb3ebfda3589b102e17eda2b807006a19e75ba2a9fe7bbced5e38bb53cec7764ba3cda125e84c76985aca5e2030107cca0997479513ca
|
7
|
+
data.tar.gz: c8316fbc6e3814f3cd5d974ab5ff1985832309b175181949d4dd37ee113de9aa12131889e1100fbe64cbba9a1bd01c6f12d86a9ce9bc92bae9b80186b4fce659
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Ridgepole is a tool to manage DB schema.
|
|
5
5
|
It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps), and updates DB schema according to DSL.
|
6
6
|
(like Chef/Puppet)
|
7
7
|
|
8
|
-
[![Prev Version](https://img.shields.io/badge/
|
8
|
+
[![Prev Version](https://img.shields.io/badge/prev_version-0.6.6-brightgreen.svg)](https://rubygems.org/gems/ridgepole/versions/0.7.0.rc1)
|
9
9
|
[![Build Status](https://travis-ci.org/winebarrel/ridgepole.svg?branch=0.6)](https://travis-ci.org/winebarrel/ridgepole)
|
10
10
|
[![Coverage Status](https://coveralls.io/repos/github/winebarrel/ridgepole/badge.svg?branch=0.6)](https://coveralls.io/github/winebarrel/ridgepole?branch=0.6)
|
11
11
|
|
@@ -79,6 +79,8 @@ It defines DB schema using [Rails DSL](http://guides.rubyonrails.org/migrations.
|
|
79
79
|
* Add `--skip-column-comment-change` option
|
80
80
|
* Add `--default-bigint-limit` option
|
81
81
|
* Add `--ignore-table-comment` option
|
82
|
+
* `>= 0.7.1`
|
83
|
+
* Remove `--reverse` option
|
82
84
|
|
83
85
|
## Installation
|
84
86
|
|
@@ -120,7 +122,6 @@ Usage: ridgepole [options]
|
|
120
122
|
--split
|
121
123
|
--split-with-dir
|
122
124
|
-d, --diff DSL1 DSL2
|
123
|
-
--reverse
|
124
125
|
--with-apply
|
125
126
|
-o, --output SCHEMAFILE
|
126
127
|
-t, --tables TABLES
|
@@ -290,34 +291,6 @@ $ ridgepole --diff config.yml file1.schema
|
|
290
291
|
remove_column("articles", "author")
|
291
292
|
```
|
292
293
|
|
293
|
-
### Reverse diff
|
294
|
-
```sh
|
295
|
-
$ cat file1.schema
|
296
|
-
create_table "articles", force: :cascade do |t|
|
297
|
-
t.string "title"
|
298
|
-
t.text "text"
|
299
|
-
t.datetime "created_at"
|
300
|
-
t.datetime "updated_at"
|
301
|
-
end
|
302
|
-
|
303
|
-
$ cat file2.schema
|
304
|
-
create_table "articles", force: :cascade do |t|
|
305
|
-
t.string "title"
|
306
|
-
t.text "desc", renamed_from: "text"
|
307
|
-
t.text "author"
|
308
|
-
t.datetime "created_at"
|
309
|
-
t.datetime "updated_at"
|
310
|
-
end
|
311
|
-
|
312
|
-
$ ridgepole --diff file1.schema file2.schema
|
313
|
-
add_column("articles", "author", :text, {:after=>"title"})
|
314
|
-
rename_column("articles", "text", "desc")
|
315
|
-
|
316
|
-
$ ridgepole --diff file1.schema file2.schema --reverse
|
317
|
-
rename_column("articles", "desc", "text")
|
318
|
-
remove_column("articles", "author")
|
319
|
-
```
|
320
|
-
|
321
294
|
## Execute SQL using external script
|
322
295
|
|
323
296
|
```sh
|
data/bin/ridgepole
CHANGED
@@ -111,7 +111,6 @@ ARGV.options do |opt|
|
|
111
111
|
ARGV.shift
|
112
112
|
diff_files = [diff_arg1, diff_arg2]
|
113
113
|
}
|
114
|
-
opt.on('', '--reverse') { options[:reverse] = true }
|
115
114
|
opt.on('', '--with-apply') { diff_with_apply = true }
|
116
115
|
opt.on('-o', '--output SCHEMAFILE') {|v| output_file = v }
|
117
116
|
opt.on('-t', '--tables TABLES', Array) {|v| options[:tables] = v }
|
data/lib/ridgepole/delta.rb
CHANGED
@@ -290,8 +290,9 @@ execute "ALTER TABLE #{ActiveRecord::Base.connection.quote_table_name(table_name
|
|
290
290
|
|
291
291
|
if not definition.empty? or not indices.empty?
|
292
292
|
append_change_table(table_name, buf) do
|
293
|
+
append_delete_indices(table_name, indices, buf)
|
293
294
|
append_change_definition(table_name, definition, buf)
|
294
|
-
|
295
|
+
append_add_indices(table_name, indices, buf)
|
295
296
|
end
|
296
297
|
end
|
297
298
|
|
@@ -392,16 +393,18 @@ remove_column(#{table_name.inspect}, #{column_name.inspect})
|
|
392
393
|
end
|
393
394
|
end
|
394
395
|
|
395
|
-
def
|
396
|
-
(delta[:delete] || {}).each do |index_name, attrs|
|
397
|
-
append_remove_index(table_name, index_name, attrs, buf)
|
398
|
-
end
|
399
|
-
|
396
|
+
def append_add_indices(table_name, delta, buf)
|
400
397
|
(delta[:add] || {}).each do |index_name, attrs|
|
401
398
|
append_add_index(table_name, index_name, attrs, buf)
|
402
399
|
end
|
403
400
|
end
|
404
401
|
|
402
|
+
def append_delete_indices(table_name, delta, buf)
|
403
|
+
(delta[:delete] || {}).each do |index_name, attrs|
|
404
|
+
append_remove_index(table_name, index_name, attrs, buf)
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
405
408
|
def append_add_index(table_name, index_name, attrs, buf)
|
406
409
|
column_name = attrs.fetch(:column_name)
|
407
410
|
options = attrs[:options] || {}
|
data/lib/ridgepole/diff.rb
CHANGED
@@ -8,17 +8,12 @@ class Ridgepole::Diff
|
|
8
8
|
from = (from || {}).deep_dup
|
9
9
|
to = (to || {}).deep_dup
|
10
10
|
|
11
|
-
if @options[:reverse]
|
12
|
-
from, to = to, from
|
13
|
-
end
|
14
11
|
check_table_existence(to)
|
15
12
|
|
16
13
|
delta = {}
|
17
14
|
relation_info = {}
|
18
15
|
|
19
16
|
scan_table_rename(from, to, delta)
|
20
|
-
# for reverse option
|
21
|
-
scan_table_rename(to, from, delta)
|
22
17
|
|
23
18
|
to.each do |table_name, to_attrs|
|
24
19
|
collect_relation_info!(table_name, to_attrs, relation_info)
|
@@ -65,20 +60,18 @@ class Ridgepole::Diff
|
|
65
60
|
from_table_name = from_table_name.to_s if from_table_name
|
66
61
|
|
67
62
|
# Already renamed
|
68
|
-
|
63
|
+
if from[table_name]
|
64
|
+
@logger.warn("[WARNING] The table `#{from_table_name}` has already been renamed to the table `#{table_name}`.")
|
65
|
+
next
|
66
|
+
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
68
|
+
unless from[from_table_name]
|
69
|
+
@logger.warn("[WARNING] The table `#{from_table_name}` to be renamed does not exist.")
|
70
|
+
next
|
71
|
+
end
|
74
72
|
|
75
73
|
delta[:rename] ||= {}
|
76
|
-
|
77
|
-
if @options[:reverse]
|
78
|
-
delta[:rename][from_table_name] = table_name
|
79
|
-
else
|
80
|
-
delta[:rename][table_name] = from_table_name
|
81
|
-
end
|
74
|
+
delta[:rename][table_name] = from_table_name
|
82
75
|
|
83
76
|
from.delete(from_table_name)
|
84
77
|
to.delete(table_name)
|
@@ -148,8 +141,6 @@ class Ridgepole::Diff
|
|
148
141
|
definition_delta = {}
|
149
142
|
|
150
143
|
scan_column_rename(from, to, definition_delta)
|
151
|
-
# for reverse option
|
152
|
-
scan_column_rename(to, from, definition_delta)
|
153
144
|
|
154
145
|
if table_options[:id] == false or table_options[:primary_key].is_a?(Array)
|
155
146
|
priv_column_name = nil
|
@@ -241,12 +232,7 @@ class Ridgepole::Diff
|
|
241
232
|
end
|
242
233
|
|
243
234
|
definition_delta[:rename] ||= {}
|
244
|
-
|
245
|
-
if @options[:reverse]
|
246
|
-
definition_delta[:rename][from_column_name] = column_name
|
247
|
-
else
|
248
|
-
definition_delta[:rename][column_name] = from_column_name
|
249
|
-
end
|
235
|
+
definition_delta[:rename][column_name] = from_column_name
|
250
236
|
|
251
237
|
from.delete(from_column_name)
|
252
238
|
to.delete(column_name)
|
data/lib/ridgepole/version.rb
CHANGED
@@ -29,14 +29,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
expect(subject.dump).to match_fuzzy expected_dsl
|
30
30
|
}
|
31
31
|
|
32
|
-
it {
|
33
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
34
|
-
expect(delta.differ?).to be_truthy
|
35
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
36
|
-
remove_foreign_key("child", {:name=>"child_ibfk_1"})
|
37
|
-
EOS
|
38
|
-
}
|
39
|
-
|
40
32
|
it {
|
41
33
|
delta = client(bulk_change: true).diff(expected_dsl)
|
42
34
|
expect(delta.differ?).to be_truthy
|
@@ -145,14 +137,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
145
137
|
expect(subject.dump).to match_fuzzy expected_dsl
|
146
138
|
}
|
147
139
|
|
148
|
-
it {
|
149
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
150
|
-
expect(delta.differ?).to be_truthy
|
151
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
152
|
-
remove_foreign_key("child", "parent")
|
153
|
-
EOS
|
154
|
-
}
|
155
|
-
|
156
140
|
it {
|
157
141
|
delta = client(bulk_change: true).diff(expected_dsl)
|
158
142
|
expect(delta.differ?).to be_truthy
|
@@ -43,14 +43,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
43
43
|
expect(subject.dump).to match_fuzzy expected_dsl
|
44
44
|
}
|
45
45
|
|
46
|
-
it {
|
47
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
48
|
-
expect(delta.differ?).to be_truthy
|
49
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
50
|
-
add_foreign_key("child", "parent", {:name=>"child_ibfk_1"})
|
51
|
-
EOS
|
52
|
-
}
|
53
|
-
|
54
46
|
it {
|
55
47
|
delta = client(bulk_change: true).diff(expected_dsl)
|
56
48
|
expect(delta.differ?).to be_truthy
|
@@ -148,14 +140,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
140
|
expect(subject.dump).to match_fuzzy expected_dsl
|
149
141
|
}
|
150
142
|
|
151
|
-
it {
|
152
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
153
|
-
expect(delta.differ?).to be_truthy
|
154
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
155
|
-
add_foreign_key("child", "parent", {})
|
156
|
-
EOS
|
157
|
-
}
|
158
|
-
|
159
143
|
it {
|
160
144
|
delta = client(bulk_change: true).diff(expected_dsl)
|
161
145
|
expect(delta.differ?).to be_truthy
|
@@ -138,17 +138,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
138
138
|
expect(subject.dump).to match_fuzzy expected_dsl
|
139
139
|
}
|
140
140
|
|
141
|
-
it {
|
142
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
143
|
-
expect(delta.differ?).to be_truthy
|
144
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
145
|
-
remove_column("employee_clubs", "any_col")
|
146
|
-
|
147
|
-
remove_column("employees", "age")
|
148
|
-
remove_column("employees", "updated_at")
|
149
|
-
EOS
|
150
|
-
}
|
151
|
-
|
152
141
|
it {
|
153
142
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
154
143
|
expect(delta.differ?).to be_truthy
|
@@ -135,17 +135,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
135
135
|
expect(subject.dump).to match_fuzzy expected_dsl
|
136
136
|
}
|
137
137
|
|
138
|
-
it {
|
139
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, enable_mysql_unsigned: true)
|
140
|
-
expect(delta.differ?).to be_truthy
|
141
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
142
|
-
change_column("employee_clubs", "club_id", :integer, <%= {:null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
143
|
-
|
144
|
-
change_column("employees", "last_name", :string,<%= {:limit=>16, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
145
|
-
change_column("employees", "gender", :string,<%= {:limit=>1, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
146
|
-
EOS
|
147
|
-
}
|
148
|
-
|
149
138
|
it {
|
150
139
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
151
140
|
expect(delta.differ?).to be_truthy
|
@@ -197,21 +197,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
197
197
|
expect(subject.dump).to match_fuzzy expected_dsl
|
198
198
|
}
|
199
199
|
|
200
|
-
it {
|
201
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
202
|
-
expect(delta.differ?).to be_truthy
|
203
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
204
|
-
remove_index("dept_emp", {:name=>"emp_no"})
|
205
|
-
add_index("dept_emp", ["emp_no"], {:name=>"emp_no", :using=>:btree, :unique=>false})
|
206
|
-
|
207
|
-
remove_index("dept_manager", {:name=>"emp_no"})
|
208
|
-
add_index("dept_manager", ["emp_no"], {:name=>"emp_no", :using=>:btree, :unique=>false})
|
209
|
-
|
210
|
-
remove_index("salaries", {:name=>"emp_no"})
|
211
|
-
add_index("salaries", ["emp_no"], {:name=>"emp_no", :using=>:btree, :unique=>false})
|
212
|
-
EOS
|
213
|
-
}
|
214
|
-
|
215
200
|
it {
|
216
201
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
217
202
|
expect(delta.differ?).to be_truthy
|
@@ -39,16 +39,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
39
|
delta.migrate
|
40
40
|
expect(subject.dump).to match_fuzzy actual_dsl
|
41
41
|
}
|
42
|
-
|
43
|
-
it {
|
44
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
|
45
|
-
[WARNING] No difference of schema configuration for table `employees` but table options differ.
|
46
|
-
from: {:primary_key=>"emp_no2"}
|
47
|
-
to: {:primary_key=>"emp_no"}
|
48
|
-
EOS
|
49
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
50
|
-
expect(delta.differ?).to be_falsey
|
51
|
-
}
|
52
42
|
end
|
53
43
|
|
54
44
|
context 'when create_table options are different (ignore comment)' do
|
@@ -134,18 +134,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
expect(subject.dump).to match_fuzzy expected_dsl
|
135
135
|
}
|
136
136
|
|
137
|
-
it {
|
138
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
139
|
-
expect(delta.differ?).to be_truthy
|
140
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
141
|
-
remove_index("clubs", {:name=>"idx_name"})
|
142
|
-
|
143
|
-
remove_index("employee_clubs", {:name=>"idx_emp_no_club_id"})
|
144
|
-
|
145
|
-
remove_index("titles", {:name=>"emp_no"})
|
146
|
-
EOS
|
147
|
-
}
|
148
|
-
|
149
137
|
it {
|
150
138
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
151
139
|
expect(delta.differ?).to be_truthy
|
@@ -117,17 +117,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
117
117
|
delta.migrate
|
118
118
|
expect(subject.dump).to match_fuzzy expected_dsl
|
119
119
|
}
|
120
|
-
|
121
|
-
it {
|
122
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
123
|
-
expect(delta.differ?).to be_truthy
|
124
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
125
|
-
drop_table("clubs")
|
126
|
-
|
127
|
-
drop_table("employee_clubs")
|
128
|
-
|
129
|
-
drop_table("employees")
|
130
|
-
EOS
|
131
|
-
}
|
132
120
|
end
|
133
121
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when drop column and unique index' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
|
+
t.string "first_name", limit: 14, null: false
|
7
|
+
t.string "last_name", limit: 16, null: false
|
8
|
+
t.index ["first_name", "last_name"], name: "first_name_last_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
9
|
+
end
|
10
|
+
EOS
|
11
|
+
}
|
12
|
+
|
13
|
+
let(:expected_dsl) {
|
14
|
+
erbh(<<-EOS)
|
15
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
16
|
+
t.string "first_name", limit: 14, null: false
|
17
|
+
end
|
18
|
+
EOS
|
19
|
+
}
|
20
|
+
|
21
|
+
before do
|
22
|
+
subject.diff(actual_dsl).migrate
|
23
|
+
ActiveRecord::Base.connection.execute(<<-'SQL'
|
24
|
+
insert into
|
25
|
+
employees (first_name, last_name)
|
26
|
+
values
|
27
|
+
('Taro', 'Yamada'), ('Taro', 'Sato')
|
28
|
+
;
|
29
|
+
SQL
|
30
|
+
)
|
31
|
+
end
|
32
|
+
subject { client }
|
33
|
+
|
34
|
+
it {
|
35
|
+
delta = subject.diff(expected_dsl)
|
36
|
+
expect(delta.differ?).to be_truthy
|
37
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
38
|
+
delta.migrate
|
39
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
40
|
+
}
|
41
|
+
|
42
|
+
it {
|
43
|
+
delta = subject.diff(expected_dsl)
|
44
|
+
expect(delta.differ?).to be_truthy
|
45
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
46
|
+
delta.migrate(:noop => true)
|
47
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
@@ -128,22 +128,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
128
128
|
expect(subject.dump).to match_fuzzy expected_dsl
|
129
129
|
}
|
130
130
|
|
131
|
-
it {
|
132
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
133
|
-
expect(delta.differ?).to be_truthy
|
134
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
135
|
-
add_column("dept_emp", "from_date", :date, {:null=>false, :after=>"dept_no"})
|
136
|
-
add_column("dept_emp", "to_date", :date, {:null=>false, :after=>"from_date"})
|
137
|
-
|
138
|
-
add_column("dept_manager", "from_date", :date, {:null=>false, :after=>"emp_no"})
|
139
|
-
add_column("dept_manager", "to_date", :date, {:null=>false, :after=>"from_date"})
|
140
|
-
|
141
|
-
add_column("employees", "last_name", :string, {:limit=>16, :null=>false, :after=>"first_name"})
|
142
|
-
add_column("employees", "gender", :string, {:limit=>1, :null=>false, :after=>"last_name"})
|
143
|
-
add_column("employees", "hire_date", :date, {:null=>false, :after=>"gender"})
|
144
|
-
EOS
|
145
|
-
}
|
146
|
-
|
147
131
|
it {
|
148
132
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
149
133
|
expect(delta.differ?).to be_truthy
|
@@ -134,18 +134,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
expect(subject.dump).to match_fuzzy expected_dsl
|
135
135
|
}
|
136
136
|
|
137
|
-
it {
|
138
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
139
|
-
expect(delta.differ?).to be_truthy
|
140
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
141
|
-
add_index("clubs", ["name"], <%= {:name=>"idx_name", :unique=>true} + cond(5.0, using: :btree) %>)
|
142
|
-
|
143
|
-
add_index("employee_clubs", ["emp_no", "club_id"], <%= {:name=>"idx_emp_no_club_id"} + cond(5.0, using: :btree) %>)
|
144
|
-
|
145
|
-
add_index("titles", ["emp_no"], <%= {:name=>"emp_no"} + cond(5.0, using: :btree) %>)
|
146
|
-
EOS
|
147
|
-
}
|
148
|
-
|
149
137
|
it {
|
150
138
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
151
139
|
expect(delta.differ?).to be_truthy
|
@@ -117,30 +117,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
117
117
|
delta.migrate
|
118
118
|
expect(subject.dump).to match_fuzzy expected_dsl
|
119
119
|
}
|
120
|
-
|
121
|
-
it {
|
122
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
123
|
-
expect(delta.differ?).to be_truthy
|
124
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
125
|
-
create_table("clubs", {}) do |t|
|
126
|
-
t.column("name", :"string", {:default=>"", :null=>false, :limit=>255})
|
127
|
-
end
|
128
|
-
add_index("clubs", ["name"], <%= {:name=>"idx_name", :unique=>true} + cond(5.0, using: :btree) %>)
|
129
|
-
|
130
|
-
create_table("employee_clubs", {}) do |t|
|
131
|
-
t.column("emp_no", :"integer", {:null=>false, :limit=>4})
|
132
|
-
t.column("club_id", :"integer", {:null=>false, :limit=>4})
|
133
|
-
end
|
134
|
-
add_index("employee_clubs", ["emp_no", "club_id"], <%= {:name=>"idx_emp_no_club_id"} + cond(5.0, using: :btree) %>)
|
135
|
-
|
136
|
-
create_table("employees", {:primary_key=>"emp_no"}) do |t|
|
137
|
-
t.column("birth_date", :"date", {:null=>false})
|
138
|
-
t.column("first_name", :"string", {:limit=>14, :null=>false})
|
139
|
-
t.column("last_name", :"string", {:limit=>16, :null=>false})
|
140
|
-
t.column("gender", :"string", {:limit=>1, :null=>false})
|
141
|
-
t.column("hire_date", :"date", {:null=>false})
|
142
|
-
end
|
143
|
-
EOS
|
144
|
-
}
|
145
120
|
end
|
146
121
|
end
|
@@ -72,27 +72,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
72
72
|
delta.migrate
|
73
73
|
expect(subject.dump).to match_fuzzy expected_dsl
|
74
74
|
}
|
75
|
-
|
76
|
-
it {
|
77
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
78
|
-
expect(delta.differ?).to be_truthy
|
79
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
80
|
-
drop_table("clubs")
|
81
|
-
|
82
|
-
drop_table("departments")
|
83
|
-
|
84
|
-
drop_table("dept_emp")
|
85
|
-
|
86
|
-
drop_table("dept_manager")
|
87
|
-
|
88
|
-
drop_table("employee_clubs")
|
89
|
-
|
90
|
-
drop_table("employees")
|
91
|
-
|
92
|
-
drop_table("salaries")
|
93
|
-
|
94
|
-
drop_table("titles")
|
95
|
-
EOS
|
96
|
-
}
|
97
75
|
end
|
98
76
|
end
|
@@ -139,10 +139,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
139
139
|
# `clubs` table is not deleted
|
140
140
|
expect(subject.dump).to match_fuzzy expected_dsl
|
141
141
|
}
|
142
|
-
|
143
|
-
it {
|
144
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, merge: true, reverse: true)
|
145
|
-
expect(delta.differ?).to be_falsey
|
146
|
-
}
|
147
142
|
end
|
148
143
|
end
|
@@ -135,18 +135,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
135
135
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/\s*,\s*renamed_from:.*$/, '')
|
136
136
|
}
|
137
137
|
|
138
|
-
it {
|
139
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
140
|
-
expect(delta.differ?).to be_truthy
|
141
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
142
|
-
rename_column("dept_emp", "from_date2", "from_date")
|
143
|
-
|
144
|
-
rename_column("dept_manager", "to_date2", "to_date")
|
145
|
-
|
146
|
-
rename_column("employees", "gender2", "gender")
|
147
|
-
EOS
|
148
|
-
}
|
149
|
-
|
150
138
|
it {
|
151
139
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
152
140
|
expect(delta.differ?).to be_truthy
|
@@ -134,15 +134,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
delta.migrate
|
135
135
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/, renamed_from: ('employees'|:titles)/, '')
|
136
136
|
}
|
137
|
-
|
138
|
-
it {
|
139
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
140
|
-
expect(delta.differ?).to be_truthy
|
141
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
142
|
-
rename_table("employees2", "employees")
|
143
|
-
rename_table("titles2", "titles")
|
144
|
-
EOS
|
145
|
-
}
|
146
137
|
end
|
147
138
|
|
148
139
|
context 'when rename table (dry-run)' do
|
@@ -219,10 +210,30 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
219
210
|
}
|
220
211
|
|
221
212
|
it {
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
213
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with("[WARNING] The table `not_employees` to be renamed does not exist.")
|
214
|
+
subject.diff(dsl)
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'when rename table (already exist)' do
|
219
|
+
before { subject.diff(dsl).migrate }
|
220
|
+
subject { client }
|
221
|
+
|
222
|
+
let(:dsl) {
|
223
|
+
erbh(<<-EOS)
|
224
|
+
create_table "employees2", primary_key: "emp_no", force: :cascade, renamed_from: 'employees' do |t|
|
225
|
+
t.date "birth_date", null: false
|
226
|
+
t.string "first_name", limit: 14, null: false
|
227
|
+
t.string "last_name", limit: 16, null: false
|
228
|
+
t.string "gender", limit: 1, null: false
|
229
|
+
t.date "hire_date", null: false
|
230
|
+
end
|
231
|
+
EOS
|
232
|
+
}
|
233
|
+
|
234
|
+
it {
|
235
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with("[WARNING] The table `employees` has already been renamed to the table `employees2`.")
|
236
|
+
subject.diff(dsl)
|
226
237
|
}
|
227
238
|
end
|
228
239
|
end
|
@@ -139,10 +139,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
139
139
|
# `clubs` table is not deleted
|
140
140
|
expect(subject.dump).to match_fuzzy expected_dsl
|
141
141
|
}
|
142
|
-
|
143
|
-
it {
|
144
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, skip_drop_table: true, reverse: true)
|
145
|
-
expect(delta.differ?).to be_falsey
|
146
|
-
}
|
147
142
|
end
|
148
143
|
end
|
@@ -134,10 +134,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
delta.migrate
|
135
135
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/\s*,\s*renamed_from:.*$/, '')
|
136
136
|
}
|
137
|
-
|
138
|
-
it {
|
139
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
140
|
-
expect(delta.differ?).to be_falsey
|
141
|
-
}
|
142
137
|
end
|
143
138
|
end
|
@@ -128,16 +128,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
128
128
|
subject { client }
|
129
129
|
|
130
130
|
it {
|
131
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with("[WARNING] The table `employees` has already been renamed to the table `employees2`.")
|
131
132
|
delta = subject.diff(expected_dsl)
|
132
133
|
expect(delta.differ?).to be_falsey
|
133
134
|
expect(subject.dump).to match_fuzzy actual_dsl
|
134
135
|
delta.migrate
|
135
136
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/, renamed_from: 'employees'/, '')
|
136
137
|
}
|
137
|
-
|
138
|
-
it {
|
139
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
140
|
-
expect(delta.differ?).to be_falsey
|
141
|
-
}
|
142
138
|
end
|
143
139
|
end
|
@@ -143,14 +143,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
143
143
|
delta.migrate
|
144
144
|
expect(subject.dump).to match_fuzzy after_dsl
|
145
145
|
}
|
146
|
-
|
147
|
-
it {
|
148
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
149
|
-
expect(delta.differ?).to be_truthy
|
150
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
151
|
-
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
152
|
-
EOS
|
153
|
-
}
|
154
146
|
end
|
155
147
|
|
156
148
|
context 'when with ignore tables option (target and ignore)' do
|
@@ -230,14 +222,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
230
222
|
delta.migrate
|
231
223
|
expect(subject.dump).to match_fuzzy after_dsl
|
232
224
|
}
|
233
|
-
|
234
|
-
it {
|
235
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
236
|
-
expect(delta.differ?).to be_truthy
|
237
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
238
|
-
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
239
|
-
EOS
|
240
|
-
}
|
241
225
|
end
|
242
226
|
|
243
227
|
context 'when with ignore tables option (target)' do
|
@@ -317,13 +301,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
317
301
|
delta.migrate
|
318
302
|
expect(subject.dump).to match_fuzzy after_dsl
|
319
303
|
}
|
320
|
-
|
321
|
-
it {
|
322
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
323
|
-
expect(delta.differ?).to be_truthy
|
324
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
325
|
-
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
326
|
-
EOS
|
327
|
-
}
|
328
304
|
end
|
329
305
|
end
|
@@ -143,13 +143,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
143
143
|
delta.migrate
|
144
144
|
expect(subject.dump).to match_fuzzy after_dsl
|
145
145
|
}
|
146
|
-
|
147
|
-
it {
|
148
|
-
delta = Ridgepole::Client.diff(current_schema, dsl, tables: ['employees'], reverse: true, enable_mysql_awesome: true)
|
149
|
-
expect(delta.differ?).to be_truthy
|
150
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
151
|
-
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
152
|
-
EOS
|
153
|
-
}
|
154
146
|
end
|
155
147
|
end
|
@@ -29,14 +29,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
expect(subject.dump).to match_fuzzy expected_dsl
|
30
30
|
}
|
31
31
|
|
32
|
-
it {
|
33
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4, dump_with_default_fk_name: true)
|
34
|
-
expect(delta.differ?).to be_truthy
|
35
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
36
|
-
remove_foreign_key("child", {:name=>"fk_rails_e74ce85cbc"})
|
37
|
-
EOS
|
38
|
-
}
|
39
|
-
|
40
32
|
it {
|
41
33
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
42
34
|
expect(delta.differ?).to be_truthy
|
@@ -43,14 +43,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
43
43
|
expect(subject.dump).to match_fuzzy expected_dsl
|
44
44
|
}
|
45
45
|
|
46
|
-
it {
|
47
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4, dump_with_default_fk_name: true)
|
48
|
-
expect(delta.differ?).to be_truthy
|
49
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
50
|
-
add_foreign_key("child", "parent", {:name=>"fk_rails_e74ce85cbc"})
|
51
|
-
EOS
|
52
|
-
}
|
53
|
-
|
54
46
|
it {
|
55
47
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
56
48
|
expect(delta.differ?).to be_truthy
|
@@ -29,14 +29,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
expect(subject.dump).to match_fuzzy expected_dsl
|
30
30
|
}
|
31
31
|
|
32
|
-
it {
|
33
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
34
|
-
expect(delta.differ?).to be_truthy
|
35
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
36
|
-
remove_foreign_key("child", {:name=>"child_ibfk_1"})
|
37
|
-
EOS
|
38
|
-
}
|
39
|
-
|
40
32
|
it {
|
41
33
|
delta = client(bulk_change: true).diff(expected_dsl)
|
42
34
|
expect(delta.differ?).to be_truthy
|
@@ -148,14 +140,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
140
|
expect(subject.dump).to match_fuzzy expected_dsl
|
149
141
|
}
|
150
142
|
|
151
|
-
it {
|
152
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
153
|
-
expect(delta.differ?).to be_truthy
|
154
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
155
|
-
remove_foreign_key("child", "parent")
|
156
|
-
EOS
|
157
|
-
}
|
158
|
-
|
159
143
|
it {
|
160
144
|
delta = client(bulk_change: true).diff(expected_dsl)
|
161
145
|
expect(delta.differ?).to be_truthy
|
@@ -43,14 +43,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
43
43
|
expect(subject.dump).to match_fuzzy expected_dsl
|
44
44
|
}
|
45
45
|
|
46
|
-
it {
|
47
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
48
|
-
expect(delta.differ?).to be_truthy
|
49
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
50
|
-
add_foreign_key("child", "parent", {:name=>"child_ibfk_1"})
|
51
|
-
EOS
|
52
|
-
}
|
53
|
-
|
54
46
|
it {
|
55
47
|
delta = client(bulk_change: true).diff(expected_dsl)
|
56
48
|
expect(delta.differ?).to be_truthy
|
@@ -148,14 +140,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
140
|
expect(subject.dump).to match_fuzzy expected_dsl
|
149
141
|
}
|
150
142
|
|
151
|
-
it {
|
152
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
153
|
-
expect(delta.differ?).to be_truthy
|
154
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
155
|
-
add_foreign_key("child", "parent", {})
|
156
|
-
EOS
|
157
|
-
}
|
158
|
-
|
159
143
|
it {
|
160
144
|
delta = client(bulk_change: true).diff(expected_dsl)
|
161
145
|
expect(delta.differ?).to be_truthy
|
@@ -134,17 +134,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
expect(subject.dump).to match_fuzzy expected_dsl
|
135
135
|
}
|
136
136
|
|
137
|
-
it {
|
138
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
139
|
-
expect(delta.differ?).to be_truthy
|
140
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
141
|
-
remove_column("employee_clubs", "any_col")
|
142
|
-
|
143
|
-
remove_column("employees", "age")
|
144
|
-
remove_column("employees", "updated_at")
|
145
|
-
EOS
|
146
|
-
}
|
147
|
-
|
148
137
|
it {
|
149
138
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
150
139
|
expect(delta.differ?).to be_truthy
|
@@ -131,16 +131,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
131
131
|
expect(subject.dump).to match_fuzzy expected_dsl
|
132
132
|
}
|
133
133
|
|
134
|
-
it {
|
135
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
136
|
-
expect(delta.differ?).to be_truthy
|
137
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
138
|
-
change_column("employee_clubs", "club_id", :integer, {:null=>false, :default=>nil})
|
139
|
-
|
140
|
-
change_column("employees", "last_name", :string, {:limit=>16, :default=>nil})
|
141
|
-
EOS
|
142
|
-
}
|
143
|
-
|
144
134
|
it {
|
145
135
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
146
136
|
expect(delta.differ?).to be_truthy
|
@@ -133,21 +133,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
133
133
|
expect(subject.dump).to match_fuzzy expected_dsl
|
134
134
|
}
|
135
135
|
|
136
|
-
it {
|
137
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
138
|
-
expect(delta.differ?).to be_truthy
|
139
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
140
|
-
remove_index("dept_emp", {:name=>"idx_dept_emp_emp_no"})
|
141
|
-
add_index("dept_emp", ["emp_no"], {:name=>"idx_dept_emp_emp_no", :using=>:btree, :unique=>false})
|
142
|
-
|
143
|
-
remove_index("dept_manager", {:name=>"idx_dept_manager_emp_no"})
|
144
|
-
add_index("dept_manager", ["emp_no"], {:name=>"idx_dept_manager_emp_no", :using=>:btree, :unique=>false})
|
145
|
-
|
146
|
-
remove_index("salaries", {:name=>"idx_salaries_emp_no"})
|
147
|
-
add_index("salaries", ["emp_no"], {:name=>"idx_salaries_emp_no", :using=>:btree, :unique=>false})
|
148
|
-
EOS
|
149
|
-
}
|
150
|
-
|
151
136
|
it {
|
152
137
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
153
138
|
expect(delta.differ?).to be_truthy
|
@@ -114,17 +114,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
114
114
|
delta.migrate
|
115
115
|
expect(subject.dump).to match_fuzzy expected_dsl
|
116
116
|
}
|
117
|
-
|
118
|
-
it {
|
119
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
120
|
-
expect(delta.differ?).to be_truthy
|
121
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
122
|
-
drop_table("clubs")
|
123
|
-
|
124
|
-
drop_table("employee_clubs")
|
125
|
-
|
126
|
-
drop_table("employees")
|
127
|
-
EOS
|
128
|
-
}
|
129
117
|
end
|
130
118
|
end
|
@@ -127,21 +127,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
127
127
|
expect(subject.dump).to match_fuzzy expected_dsl
|
128
128
|
}
|
129
129
|
|
130
|
-
it {
|
131
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
132
|
-
expect(delta.differ?).to be_truthy
|
133
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
134
|
-
add_column("dept_emp", "from_date", :date, {:null=>false})
|
135
|
-
add_column("dept_emp", "to_date", :date, {:null=>false})
|
136
|
-
|
137
|
-
add_column("dept_manager", "from_date", :date, {:null=>false})
|
138
|
-
add_column("dept_manager", "to_date", :date, {:null=>false})
|
139
|
-
|
140
|
-
add_column("employees", "last_name", :string, {:limit=>16, :null=>false})
|
141
|
-
add_column("employees", "hire_date", :date, {:null=>false})
|
142
|
-
EOS
|
143
|
-
}
|
144
|
-
|
145
130
|
it {
|
146
131
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
147
132
|
expect(delta.differ?).to be_truthy
|
@@ -132,18 +132,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
132
132
|
expect(subject.dump).to match_fuzzy expected_dsl
|
133
133
|
}
|
134
134
|
|
135
|
-
it {
|
136
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
137
|
-
expect(delta.differ?).to be_truthy
|
138
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
139
|
-
add_index("clubs", ["name"], <%= {:name=>"idx_name", :unique=>true} + cond(5.0, using: :btree) %>)
|
140
|
-
|
141
|
-
add_index("employee_clubs", ["emp_no", "club_id"], <%= {:name=>"idx_employee_clubs_emp_no_club_id"} + cond(5.0, using: :btree) %>)
|
142
|
-
|
143
|
-
add_index("titles", ["emp_no"], <%= {:name=>"idx_titles_emp_no"} + cond(5.0, using: :btree) %>)
|
144
|
-
EOS
|
145
|
-
}
|
146
|
-
|
147
135
|
it {
|
148
136
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
149
137
|
expect(delta.differ?).to be_truthy
|
@@ -116,29 +116,5 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
116
116
|
delta.migrate
|
117
117
|
expect(subject.dump).to match_fuzzy expected_dsl
|
118
118
|
}
|
119
|
-
|
120
|
-
it {
|
121
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
122
|
-
expect(delta.differ?).to be_truthy
|
123
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
124
|
-
create_table("clubs", {}) do |t|
|
125
|
-
t.column("name", :"string", {:limit=>255, :default=>"", :null=>false})
|
126
|
-
end
|
127
|
-
add_index("clubs", ["name"], <%= {:name=>"idx_name", :unique=>true} + cond(5.0, using: :btree) %>)
|
128
|
-
|
129
|
-
create_table("employee_clubs", {}) do |t|
|
130
|
-
t.column("emp_no", :"integer", {:null=>false})
|
131
|
-
t.column("club_id", :"integer", {:null=>false})
|
132
|
-
end
|
133
|
-
add_index("employee_clubs", ["emp_no", "club_id"], <%= {:name=>"idx_employee_clubs_emp_no_club_id"} + cond(5.0, using: :btree) %>)
|
134
|
-
|
135
|
-
create_table("employees", {:primary_key=>"emp_no"}) do |t|
|
136
|
-
t.column("birth_date", :"date", {:null=>false})
|
137
|
-
t.column("first_name", :"string", {:limit=>14, :null=>false})
|
138
|
-
t.column("last_name", :"string", {:limit=>16, :null=>false})
|
139
|
-
t.column("hire_date", :"date", {:null=>false})
|
140
|
-
end
|
141
|
-
EOS
|
142
|
-
}
|
143
119
|
end
|
144
120
|
end
|
@@ -133,16 +133,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
133
133
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/\s*,\s*renamed_from:.*$/, '')
|
134
134
|
}
|
135
135
|
|
136
|
-
it {
|
137
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
138
|
-
expect(delta.differ?).to be_truthy
|
139
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
140
|
-
rename_column("dept_emp", "from_date2", "from_date")
|
141
|
-
|
142
|
-
rename_column("dept_manager", "to_date2", "to_date")
|
143
|
-
EOS
|
144
|
-
}
|
145
|
-
|
146
136
|
it {
|
147
137
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
148
138
|
expect(delta.differ?).to be_truthy
|
@@ -132,14 +132,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
132
132
|
delta.migrate
|
133
133
|
expect(subject.dump).to match_fuzzy expected_dsl.gsub(/, renamed_from: 'employees'/, '')
|
134
134
|
}
|
135
|
-
|
136
|
-
it {
|
137
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
138
|
-
expect(delta.differ?).to be_truthy
|
139
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
140
|
-
rename_table("employees2", "employees")
|
141
|
-
EOS
|
142
|
-
}
|
143
135
|
end
|
144
136
|
|
145
137
|
context 'when rename table (dry-run)' do
|
@@ -29,14 +29,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
expect(subject.dump).to match_fuzzy expected_dsl
|
30
30
|
}
|
31
31
|
|
32
|
-
it {
|
33
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4, dump_with_default_fk_name: true)
|
34
|
-
expect(delta.differ?).to be_truthy
|
35
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
36
|
-
remove_foreign_key("child", {:name=>"fk_rails_e74ce85cbc"})
|
37
|
-
EOS
|
38
|
-
}
|
39
|
-
|
40
32
|
it {
|
41
33
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
42
34
|
expect(delta.differ?).to be_truthy
|
@@ -43,14 +43,6 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
43
43
|
expect(subject.dump).to match_fuzzy expected_dsl
|
44
44
|
}
|
45
45
|
|
46
|
-
it {
|
47
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4, dump_with_default_fk_name: true)
|
48
|
-
expect(delta.differ?).to be_truthy
|
49
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
50
|
-
add_foreign_key("child", "parent", {:name=>"fk_rails_e74ce85cbc"})
|
51
|
-
EOS
|
52
|
-
}
|
53
|
-
|
54
46
|
it {
|
55
47
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
56
48
|
expect(delta.differ?).to be_truthy
|
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.7.
|
4
|
+
version: 0.7.1.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: 2017-07-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -295,6 +295,7 @@ files:
|
|
295
295
|
- spec/mysql/migrate/migrate_create_table_with_script_spec.rb
|
296
296
|
- spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb
|
297
297
|
- spec/mysql/migrate/migrate_drop_column_and_index_spec.rb
|
298
|
+
- spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
|
298
299
|
- spec/mysql/migrate/migrate_drop_column_spec.rb
|
299
300
|
- spec/mysql/migrate/migrate_drop_index_spec.rb
|
300
301
|
- spec/mysql/migrate/migrate_drop_table_spec.rb
|
@@ -379,12 +380,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
379
380
|
version: 2.2.7
|
380
381
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
381
382
|
requirements:
|
382
|
-
- - "
|
383
|
+
- - ">"
|
383
384
|
- !ruby/object:Gem::Version
|
384
|
-
version:
|
385
|
+
version: 1.3.1
|
385
386
|
requirements: []
|
386
387
|
rubyforge_project:
|
387
|
-
rubygems_version: 2.
|
388
|
+
rubygems_version: 2.6.12
|
388
389
|
signing_key:
|
389
390
|
specification_version: 4
|
390
391
|
summary: Ridgepole is a tool to manage DB schema.
|
@@ -442,6 +443,7 @@ test_files:
|
|
442
443
|
- spec/mysql/migrate/migrate_create_table_with_script_spec.rb
|
443
444
|
- spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb
|
444
445
|
- spec/mysql/migrate/migrate_drop_column_and_index_spec.rb
|
446
|
+
- spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
|
445
447
|
- spec/mysql/migrate/migrate_drop_column_spec.rb
|
446
448
|
- spec/mysql/migrate/migrate_drop_index_spec.rb
|
447
449
|
- spec/mysql/migrate/migrate_drop_table_spec.rb
|