ridgepole 0.6.4 → 0.6.5.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +18 -8
- data/Appraisals +8 -0
- data/README.md +26 -2
- data/docker-compose.yml +12 -0
- data/gemfiles/activerecord_4.2.gemfile +8 -0
- data/gemfiles/activerecord_5.0.gemfile +7 -0
- data/lib/ridgepole/diff.rb +3 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +6 -2
- data/spec/cli_helper.rb +63 -0
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +45 -0
- data/spec/mysql/cli/config_spec.rb +0 -2
- data/spec/mysql/cli/ridgepole_spec.rb +58 -56
- data/spec/mysql/collation/collation_spec.rb +134 -138
- data/spec/mysql/diff/diff2_spec.rb +1 -3
- data/spec/mysql/diff/diff_spec.rb +1 -3
- data/spec/mysql/dump/dump_class_method_spec.rb +29 -11
- data/spec/mysql/dump/dump_some_tables_spec.rb +18 -8
- data/spec/mysql/dump/dump_spec.rb +28 -10
- data/spec/mysql/dump/dump_without_table_options_spec.rb +29 -33
- data/spec/mysql/fk/migrate_change_fk_spec.rb +2 -4
- data/spec/mysql/fk/migrate_create_fk_spec.rb +39 -29
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/mysql/migrate/check_orphan_index_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -26
- data/spec/mysql/migrate/migrate_add_column_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +27 -17
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +54 -44
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +8 -10
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +28 -30
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +34 -36
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +10 -12
- data/spec/mysql/migrate/migrate_change_column_spec.rb +41 -29
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +12 -14
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +24 -26
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +34 -24
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +38 -28
- data/spec/mysql/migrate/migrate_change_index_spec.rb +39 -29
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +26 -13
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_create_index_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_create_table_spec.rb +24 -14
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +4 -6
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +23 -13
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +35 -25
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +36 -26
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +29 -19
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_empty_spec.rb +24 -14
- data/spec/mysql/migrate/migrate_execute_spec.rb +78 -65
- data/spec/mysql/migrate/migrate_log_file_spec.rb +22 -12
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +31 -21
- data/spec/mysql/migrate/migrate_noop_spec.rb +55 -45
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +38 -28
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +43 -33
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_same_spec.rb +26 -12
- data/spec/mysql/migrate/migrate_script_error_spec.rb +3 -5
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +44 -46
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +6 -8
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +20 -22
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +22 -12
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +22 -12
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +39 -29
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/postgresql/diff/diff_spec.rb +7 -9
- data/spec/postgresql/dump/dump_spec.rb +2 -4
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +8 -10
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +24 -26
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +21 -23
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +19 -22
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +6 -8
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +17 -19
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +11 -13
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +6 -9
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +10 -12
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +7 -9
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -8
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +14 -16
- data/spec/postgresql/migrate/migrate_same_spec.rb +4 -6
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +24 -26
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/processing_for_travis.rb +9 -0
- data/spec/spec_condition.rb +24 -0
- data/spec/spec_const.rb +18 -0
- data/spec/spec_helper.rb +125 -196
- data/spec/string_ext.rb +0 -13
- metadata +106 -32
- data/spec/mysql/bigint_pk/bigint_pkspec.rb +0 -47
@@ -1,8 +1,7 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client.diff' do
|
3
2
|
context 'when change column' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "clubs", force: :cascade do |t|
|
7
6
|
t.string "name", limit: 255, default: "", null: false
|
8
7
|
end
|
@@ -66,11 +65,11 @@ describe 'Ridgepole::Client.diff' do
|
|
66
65
|
end
|
67
66
|
|
68
67
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
69
|
-
|
68
|
+
EOS
|
70
69
|
}
|
71
70
|
|
72
71
|
let(:expected_dsl) {
|
73
|
-
<<-
|
72
|
+
<<-EOS
|
74
73
|
create_table "clubs", force: :cascade do |t|
|
75
74
|
t.string "name", limit: 255, default: "", null: false
|
76
75
|
end
|
@@ -134,20 +133,19 @@ describe 'Ridgepole::Client.diff' do
|
|
134
133
|
end
|
135
134
|
|
136
135
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
137
|
-
|
136
|
+
EOS
|
138
137
|
}
|
139
138
|
|
140
139
|
subject { Ridgepole::Client }
|
141
140
|
|
142
141
|
it {
|
143
|
-
delta = subject.diff(actual_dsl, expected_dsl
|
142
|
+
delta = subject.diff(actual_dsl, expected_dsl)
|
144
143
|
expect(delta.differ?).to be_truthy
|
145
|
-
expect(delta.script).to
|
144
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
146
145
|
change_column("employee_clubs", "club_id", :integer, {:null=>true, :default=>nil})
|
147
146
|
|
148
147
|
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
149
|
-
|
148
|
+
EOS
|
150
149
|
}
|
151
150
|
end
|
152
151
|
end
|
153
|
-
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#dump' do
|
3
2
|
context 'when there is a tables' do
|
4
3
|
before { restore_tables }
|
5
4
|
subject { client }
|
6
5
|
|
7
6
|
it {
|
8
|
-
expect(subject.dump).to
|
7
|
+
expect(subject.dump).to match_fuzzy <<-EOS
|
9
8
|
create_table "clubs", force: :cascade do |t|
|
10
9
|
t.string "name", limit: 255, default: "", null: false
|
11
10
|
end
|
@@ -69,8 +68,7 @@ describe 'Ridgepole::Client#dump' do
|
|
69
68
|
end
|
70
69
|
|
71
70
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
72
|
-
|
71
|
+
EOS
|
73
72
|
}
|
74
73
|
end
|
75
74
|
end
|
76
|
-
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when change fk' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "parent", force: :cascade do |t|
|
7
6
|
end
|
8
7
|
|
@@ -13,11 +12,11 @@ end
|
|
13
12
|
add_index "child", ["parent_id"], name: "par_id", using: :btree
|
14
13
|
|
15
14
|
add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
|
16
|
-
|
15
|
+
EOS
|
17
16
|
}
|
18
17
|
|
19
18
|
let(:sorted_actual_dsl) {
|
20
|
-
<<-
|
19
|
+
<<-EOS
|
21
20
|
create_table "child", force: :cascade do |t|
|
22
21
|
t.integer "parent_id"
|
23
22
|
end
|
@@ -28,11 +27,11 @@ create_table "parent", force: :cascade do |t|
|
|
28
27
|
end
|
29
28
|
|
30
29
|
add_foreign_key "child", "parent", name: "child_ibfk_1", on_delete: :cascade
|
31
|
-
|
30
|
+
EOS
|
32
31
|
}
|
33
32
|
|
34
33
|
let(:expected_dsl) {
|
35
|
-
<<-
|
34
|
+
<<-EOS
|
36
35
|
create_table "child", force: :cascade do |t|
|
37
36
|
t.integer "parent_id"
|
38
37
|
end
|
@@ -43,7 +42,7 @@ create_table "parent", force: :cascade do |t|
|
|
43
42
|
end
|
44
43
|
|
45
44
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
46
|
-
|
45
|
+
EOS
|
47
46
|
}
|
48
47
|
|
49
48
|
before { subject.diff(actual_dsl).migrate }
|
@@ -53,10 +52,9 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
53
52
|
it {
|
54
53
|
delta = subject.diff(expected_dsl)
|
55
54
|
expect(delta.differ?).to be_truthy
|
56
|
-
expect(subject.dump
|
55
|
+
expect(subject.dump).to match_fuzzy sorted_actual_dsl
|
57
56
|
delta.migrate
|
58
|
-
expect(subject.dump
|
57
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
59
58
|
}
|
60
59
|
end
|
61
60
|
end
|
62
|
-
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when create fk' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "child", force: :cascade do |t|
|
7
6
|
t.integer "parent_id"
|
8
7
|
end
|
@@ -11,14 +10,14 @@ add_index "child", ["parent_id"], name: "par_id", using: :btree
|
|
11
10
|
|
12
11
|
create_table "parent", force: :cascade do |t|
|
13
12
|
end
|
14
|
-
|
13
|
+
EOS
|
15
14
|
}
|
16
15
|
|
17
16
|
let(:expected_dsl) {
|
18
|
-
actual_dsl + (<<-
|
17
|
+
actual_dsl + (<<-EOS)
|
19
18
|
|
20
19
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
21
|
-
|
20
|
+
EOS
|
22
21
|
}
|
23
22
|
|
24
23
|
before { subject.diff(actual_dsl).migrate }
|
@@ -27,34 +26,34 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
27
26
|
it {
|
28
27
|
delta = subject.diff(expected_dsl)
|
29
28
|
expect(delta.differ?).to be_truthy
|
30
|
-
expect(subject.dump
|
29
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
31
30
|
delta.migrate
|
32
|
-
expect(subject.dump
|
31
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
33
32
|
}
|
34
33
|
|
35
34
|
it {
|
36
35
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, default_int_limit: 4)
|
37
36
|
expect(delta.differ?).to be_truthy
|
38
|
-
expect(delta.script).to
|
37
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
39
38
|
remove_foreign_key("child", {:name=>"child_ibfk_1"})
|
40
|
-
|
39
|
+
EOS
|
41
40
|
}
|
42
41
|
|
43
42
|
it {
|
44
43
|
delta = client(bulk_change: true).diff(expected_dsl)
|
45
44
|
expect(delta.differ?).to be_truthy
|
46
|
-
expect(subject.dump
|
47
|
-
expect(delta.script).to
|
45
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
46
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
48
47
|
add_foreign_key("child", "parent", {:name=>"child_ibfk_1"})
|
49
|
-
|
48
|
+
EOS
|
50
49
|
delta.migrate
|
51
|
-
expect(subject.dump
|
50
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
52
51
|
}
|
53
52
|
end
|
54
53
|
|
55
54
|
context 'when create fk when create table' do
|
56
55
|
let(:dsl) {
|
57
|
-
<<-
|
56
|
+
<<-EOS
|
58
57
|
# Define parent before child
|
59
58
|
create_table "parent", force: :cascade do |t|
|
60
59
|
end
|
@@ -66,11 +65,11 @@ end
|
|
66
65
|
add_index "child", ["parent_id"], name: "par_id", using: :btree
|
67
66
|
|
68
67
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
69
|
-
|
68
|
+
EOS
|
70
69
|
}
|
71
70
|
|
72
71
|
let(:sorted_dsl) {
|
73
|
-
<<-
|
72
|
+
<<-EOS
|
74
73
|
create_table "child", force: :cascade do |t|
|
75
74
|
t.integer "parent_id"
|
76
75
|
end
|
@@ -81,7 +80,7 @@ create_table "parent", force: :cascade do |t|
|
|
81
80
|
end
|
82
81
|
|
83
82
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
84
|
-
|
83
|
+
EOS
|
85
84
|
}
|
86
85
|
|
87
86
|
before { client.diff('').migrate }
|
@@ -90,15 +89,15 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
90
89
|
it {
|
91
90
|
delta = subject.diff(dsl)
|
92
91
|
expect(delta.differ?).to be_truthy
|
93
|
-
expect(subject.dump
|
92
|
+
expect(subject.dump).to match_fuzzy ''
|
94
93
|
delta.migrate
|
95
|
-
expect(subject.dump
|
94
|
+
expect(subject.dump).to match_fuzzy sorted_dsl
|
96
95
|
}
|
97
96
|
end
|
98
97
|
|
99
98
|
context 'already defined' do
|
100
99
|
let(:dsl) {
|
101
|
-
<<-
|
100
|
+
<<-EOS
|
102
101
|
# Define parent before child
|
103
102
|
create_table "parent", force: :cascade do |t|
|
104
103
|
end
|
@@ -112,7 +111,7 @@ add_index "child", ["parent_id"], name: "par_id", using: :btree
|
|
112
111
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
113
112
|
|
114
113
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
115
|
-
|
114
|
+
EOS
|
116
115
|
}
|
117
116
|
|
118
117
|
subject { client }
|
@@ -126,7 +125,7 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
126
125
|
|
127
126
|
context 'no name' do
|
128
127
|
let(:dsl) {
|
129
|
-
<<-
|
128
|
+
<<-EOS
|
130
129
|
# Define parent before child
|
131
130
|
create_table "parent", force: :cascade do |t|
|
132
131
|
end
|
@@ -138,7 +137,7 @@ end
|
|
138
137
|
add_index "child", ["parent_id"], name: "par_id", using: :btree
|
139
138
|
|
140
139
|
add_foreign_key "child", "parent"
|
141
|
-
|
140
|
+
EOS
|
142
141
|
}
|
143
142
|
|
144
143
|
subject { client }
|
@@ -152,13 +151,13 @@ add_foreign_key "child", "parent"
|
|
152
151
|
|
153
152
|
context 'orphan fk' do
|
154
153
|
let(:dsl) {
|
155
|
-
<<-
|
154
|
+
<<-EOS
|
156
155
|
# Define parent before child
|
157
156
|
create_table "parent", force: :cascade do |t|
|
158
157
|
end
|
159
158
|
|
160
159
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
161
|
-
|
160
|
+
EOS
|
162
161
|
}
|
163
162
|
|
164
163
|
subject { client }
|
@@ -170,4 +169,3 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
170
169
|
}
|
171
170
|
end
|
172
171
|
end
|
173
|
-
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when drop fk' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "parent", force: :cascade do |t|
|
7
6
|
end
|
8
7
|
|
@@ -13,18 +12,18 @@ end
|
|
13
12
|
add_index "child", ["parent_id"], name: "par_id", using: :btree
|
14
13
|
|
15
14
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
16
|
-
|
15
|
+
EOS
|
17
16
|
}
|
18
17
|
|
19
18
|
let(:sorted_actual_dsl) {
|
20
|
-
expected_dsl + (<<-
|
19
|
+
expected_dsl + (<<-EOS)
|
21
20
|
|
22
21
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
23
|
-
|
22
|
+
EOS
|
24
23
|
}
|
25
24
|
|
26
25
|
let(:expected_dsl) {
|
27
|
-
<<-
|
26
|
+
<<-EOS
|
28
27
|
create_table "child", force: :cascade do |t|
|
29
28
|
t.integer "parent_id"
|
30
29
|
end
|
@@ -33,7 +32,7 @@ add_index "child", ["parent_id"], name: "par_id", using: :btree
|
|
33
32
|
|
34
33
|
create_table "parent", force: :cascade do |t|
|
35
34
|
end
|
36
|
-
|
35
|
+
EOS
|
37
36
|
}
|
38
37
|
|
39
38
|
before { subject.diff(actual_dsl).migrate }
|
@@ -42,34 +41,34 @@ end
|
|
42
41
|
it {
|
43
42
|
delta = subject.diff(expected_dsl)
|
44
43
|
expect(delta.differ?).to be_truthy
|
45
|
-
expect(subject.dump).to
|
44
|
+
expect(subject.dump).to match_fuzzy sorted_actual_dsl
|
46
45
|
delta.migrate
|
47
|
-
expect(subject.dump
|
46
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
48
47
|
}
|
49
48
|
|
50
49
|
it {
|
51
|
-
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true
|
50
|
+
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
52
51
|
expect(delta.differ?).to be_truthy
|
53
|
-
expect(delta.script).to
|
52
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
54
53
|
add_foreign_key("child", "parent", {:name=>"child_ibfk_1"})
|
55
|
-
|
54
|
+
EOS
|
56
55
|
}
|
57
56
|
|
58
57
|
it {
|
59
58
|
delta = client(bulk_change: true).diff(expected_dsl)
|
60
59
|
expect(delta.differ?).to be_truthy
|
61
|
-
expect(subject.dump).to
|
62
|
-
expect(delta.script).to
|
60
|
+
expect(subject.dump).to match_fuzzy sorted_actual_dsl
|
61
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
63
62
|
remove_foreign_key("child", {:name=>"child_ibfk_1"})
|
64
|
-
|
63
|
+
EOS
|
65
64
|
delta.migrate
|
66
|
-
expect(subject.dump
|
65
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
67
66
|
}
|
68
67
|
end
|
69
68
|
|
70
69
|
context 'when drop fk when drop table' do
|
71
70
|
let(:dsl) {
|
72
|
-
<<-
|
71
|
+
<<-EOS
|
73
72
|
create_table "parent", force: :cascade do |t|
|
74
73
|
end
|
75
74
|
|
@@ -81,11 +80,11 @@ end
|
|
81
80
|
add_index "child", ["parent_id"], name: "par_id", using: :btree
|
82
81
|
|
83
82
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
84
|
-
|
83
|
+
EOS
|
85
84
|
}
|
86
85
|
|
87
86
|
let(:sorted_dsl) {
|
88
|
-
<<-
|
87
|
+
<<-EOS
|
89
88
|
create_table "child", force: :cascade do |t|
|
90
89
|
t.integer "parent_id"
|
91
90
|
end
|
@@ -96,7 +95,7 @@ create_table "parent", force: :cascade do |t|
|
|
96
95
|
end
|
97
96
|
|
98
97
|
add_foreign_key "child", "parent", name: "child_ibfk_1"
|
99
|
-
|
98
|
+
EOS
|
100
99
|
}
|
101
100
|
|
102
101
|
before { subject.diff(dsl).migrate }
|
@@ -105,10 +104,9 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
105
104
|
it {
|
106
105
|
delta = subject.diff('')
|
107
106
|
expect(delta.differ?).to be_truthy
|
108
|
-
expect(subject.dump).to
|
107
|
+
expect(subject.dump).to match_fuzzy sorted_dsl
|
109
108
|
delta.migrate
|
110
|
-
expect(subject.dump
|
109
|
+
expect(subject.dump).to match_fuzzy ''
|
111
110
|
}
|
112
111
|
end
|
113
112
|
end
|
114
|
-
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when add column' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "clubs", force: :cascade do |t|
|
7
6
|
t.string "name", limit: 255, default: "", null: false
|
8
7
|
end
|
@@ -64,11 +63,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
64
63
|
end
|
65
64
|
|
66
65
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
67
|
-
|
66
|
+
EOS
|
68
67
|
}
|
69
68
|
|
70
69
|
let(:expected_dsl) {
|
71
|
-
<<-
|
70
|
+
<<-EOS
|
72
71
|
create_table "clubs", force: :cascade do |t|
|
73
72
|
t.string "name", limit: 255, default: "", null: false
|
74
73
|
end
|
@@ -133,7 +132,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
133
132
|
end
|
134
133
|
|
135
134
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
136
|
-
|
135
|
+
EOS
|
137
136
|
}
|
138
137
|
|
139
138
|
before { subject.diff(actual_dsl).migrate }
|
@@ -142,27 +141,27 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
142
141
|
it {
|
143
142
|
delta = subject.diff(expected_dsl)
|
144
143
|
expect(delta.differ?).to be_truthy
|
145
|
-
expect(subject.dump).to
|
144
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
146
145
|
delta.migrate
|
147
|
-
expect(subject.dump).to
|
146
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
148
147
|
}
|
149
148
|
|
150
149
|
it {
|
151
150
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
152
151
|
expect(delta.differ?).to be_truthy
|
153
|
-
expect(delta.script).to
|
152
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
154
153
|
remove_column("employee_clubs", "any_col")
|
155
154
|
|
156
155
|
remove_column("employees", "age")
|
157
156
|
remove_column("employees", "updated_at")
|
158
|
-
|
157
|
+
EOS
|
159
158
|
}
|
160
159
|
|
161
160
|
it {
|
162
161
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
163
162
|
expect(delta.differ?).to be_truthy
|
164
|
-
expect(subject.dump).to
|
165
|
-
expect(delta.script).to
|
163
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
164
|
+
expect(delta.script).to match_fuzzy <<-EOS
|
166
165
|
change_table("employee_clubs", {:bulk => true}) do |t|
|
167
166
|
t.column("any_col", :string, {:limit=>255, :null=>false, :after=>"club_id"})
|
168
167
|
end
|
@@ -171,26 +170,26 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
171
170
|
t.column("age", :integer, {:null=>false, :after=>"hire_date"})
|
172
171
|
t.column("updated_at", :date, {:after=>"age"})
|
173
172
|
end
|
174
|
-
|
173
|
+
EOS
|
175
174
|
delta.migrate
|
176
|
-
expect(subject.dump).to
|
175
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
177
176
|
}
|
178
177
|
end
|
179
178
|
|
180
179
|
context 'when add column (int/noop)' do
|
181
180
|
let(:actual_dsl) {
|
182
|
-
<<-
|
181
|
+
<<-EOS
|
183
182
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
184
183
|
t.integer "emp_no", null: false
|
185
184
|
t.string "dept_no", limit: 4, null: false
|
186
185
|
t.date "from_date", null: false
|
187
186
|
t.date "to_date", null: false
|
188
187
|
end
|
189
|
-
|
188
|
+
EOS
|
190
189
|
}
|
191
190
|
|
192
191
|
let(:expected_dsl) {
|
193
|
-
<<-
|
192
|
+
<<-EOS
|
194
193
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
195
194
|
t.integer "emp_no", null: false
|
196
195
|
t.integer "emp_no2", null: false
|
@@ -198,7 +197,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
198
197
|
t.date "from_date", null: false
|
199
198
|
t.date "to_date", null: false
|
200
199
|
end
|
201
|
-
|
200
|
+
EOS
|
202
201
|
}
|
203
202
|
|
204
203
|
before { subject.diff(actual_dsl).migrate }
|
@@ -207,14 +206,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
207
206
|
it {
|
208
207
|
delta = subject.diff(expected_dsl)
|
209
208
|
expect(delta.differ?).to be_truthy
|
210
|
-
expect(subject.dump).to
|
209
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
211
210
|
migrated, sql = delta.migrate(:noop => true)
|
212
211
|
expect(migrated).to be_truthy
|
213
|
-
expect(subject.dump).to
|
212
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
214
213
|
|
215
|
-
sql
|
216
|
-
expect(sql).to eq("ALTER TABLE \"dept_emp\" ADD \"emp_no2\" integer NOT NULL")
|
214
|
+
expect(sql).to match_fuzzy("ALTER TABLE \"dept_emp\" ADD \"emp_no2\" integer NOT NULL")
|
217
215
|
}
|
218
216
|
end
|
219
217
|
end
|
220
|
-
end
|
@@ -1,26 +1,25 @@
|
|
1
|
-
if postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when change column' do
|
4
3
|
let(:actual_dsl) {
|
5
|
-
<<-
|
4
|
+
<<-EOS
|
6
5
|
create_table "salaries", id: false, force: :cascade do |t|
|
7
6
|
t.integer "emp_no", default: 0, null: false
|
8
7
|
t.integer "salary", null: false
|
9
8
|
t.date "from_date", null: false
|
10
9
|
t.date "to_date", null: false
|
11
10
|
end
|
12
|
-
|
11
|
+
EOS
|
13
12
|
}
|
14
13
|
|
15
14
|
let(:expected_dsl) {
|
16
|
-
<<-
|
15
|
+
<<-EOS
|
17
16
|
create_table "salaries", id: false, force: :cascade do |t|
|
18
17
|
t.integer "emp_no", null: false
|
19
18
|
t.integer "salary", null: false
|
20
19
|
t.date "from_date", null: false
|
21
20
|
t.date "to_date", null: false
|
22
21
|
end
|
23
|
-
|
22
|
+
EOS
|
24
23
|
}
|
25
24
|
|
26
25
|
before { subject.diff(actual_dsl).migrate }
|
@@ -29,10 +28,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
28
|
it {
|
30
29
|
delta = subject.diff(expected_dsl)
|
31
30
|
expect(delta.differ?).to be_truthy
|
32
|
-
expect(subject.dump).to
|
31
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
33
32
|
delta.migrate
|
34
|
-
expect(subject.dump).to
|
33
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
35
34
|
}
|
36
35
|
end
|
37
36
|
end
|
38
|
-
end
|