ridgepole 0.7.0.alpha → 0.7.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/README.md +7 -5
- data/bin/ridgepole +14 -14
- data/lib/ridgepole/cli/config.rb +1 -1
- data/lib/ridgepole/client.rb +0 -4
- data/lib/ridgepole/delta.rb +15 -9
- data/lib/ridgepole/diff.rb +13 -9
- data/lib/ridgepole/dsl_parser/context.rb +2 -6
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +3 -1
- data/spec/erb_helper.rb +0 -39
- data/spec/hide_pending_formatter.rb +6 -0
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
- data/spec/mysql/bigint_pk/int_pk_spec.rb +9 -9
- data/spec/mysql/cli/ridgepole_spec.rb +2 -2
- data/spec/mysql/collation/collation_spec.rb +28 -28
- data/spec/mysql/comment/comment_spec.rb +36 -36
- data/spec/mysql/default_lambda/default_lambda_spec.rb +1 -1
- data/spec/mysql/diff/diff2_spec.rb +41 -41
- data/spec/mysql/diff/diff_spec.rb +41 -41
- data/spec/mysql/dump/dump_class_method_spec.rb +26 -33
- data/spec/mysql/dump/dump_some_tables_spec.rb +16 -18
- data/spec/mysql/dump/dump_spec.rb +27 -34
- data/spec/mysql/dump/dump_without_table_options_spec.rb +5 -5
- data/spec/mysql/fk/migrate_change_fk_spec.rb +76 -23
- data/spec/mysql/fk/migrate_create_fk_spec.rb +70 -50
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +131 -32
- data/spec/mysql/migrate/check_orphan_index_spec.rb +19 -19
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -45
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +47 -47
- data/spec/mysql/migrate/migrate_add_column_spec.rb +75 -89
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +72 -86
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +72 -86
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +27 -32
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +78 -78
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +42 -42
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +60 -60
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +47 -47
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_change_column_spec.rb +65 -79
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +22 -27
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +52 -62
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +32 -38
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +24 -28
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +105 -119
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +27 -30
- data/spec/mysql/migrate/migrate_change_index_spec.rb +99 -120
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +14 -14
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +101 -112
- data/spec/mysql/migrate/migrate_create_index_spec.rb +55 -66
- data/spec/mysql/migrate/migrate_create_table_spec.rb +68 -91
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +1 -1
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +58 -70
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +62 -76
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +58 -72
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +63 -77
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +55 -66
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +51 -63
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +3 -3
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_empty_spec.rb +35 -42
- data/spec/mysql/migrate/migrate_execute_spec.rb +16 -24
- data/spec/mysql/migrate/migrate_log_file_spec.rb +58 -70
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +75 -99
- data/spec/mysql/migrate/migrate_noop_spec.rb +38 -38
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +74 -88
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +100 -97
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_same_spec.rb +29 -37
- data/spec/mysql/migrate/migrate_script_error_spec.rb +19 -19
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +148 -0
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +70 -84
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +70 -84
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +87 -87
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +61 -75
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +41 -41
- data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +10 -10
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +67 -78
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +67 -78
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +9 -9
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +35 -67
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
- data/spec/postgresql/diff/diff_spec.rb +37 -37
- data/spec/postgresql/dump/dump_spec.rb +27 -34
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +76 -23
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +73 -54
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +131 -32
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +63 -75
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +7 -7
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +53 -65
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +54 -68
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +56 -77
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +46 -60
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +41 -55
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +51 -62
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +48 -60
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -6
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +54 -68
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +62 -78
- data/spec/postgresql/migrate/migrate_same_spec.rb +27 -34
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +35 -66
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
- data/spec/spec_helper.rb +1 -1
- metadata +9 -8
- data/ridgepole.iml +0 -9
- data/spec/string_ext.rb +0 -40
@@ -3,26 +3,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "salaries", id: false, force: :cascade do |t|
|
6
|
-
t.integer "emp_no",
|
7
|
-
t.integer "salary",
|
6
|
+
t.integer "emp_no", null: false
|
7
|
+
t.integer "salary", null: false
|
8
8
|
t.date "from_date", null: false
|
9
|
-
t.date "to_date",
|
9
|
+
t.date "to_date", null: false
|
10
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
10
11
|
end
|
11
|
-
|
12
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
13
12
|
EOS
|
14
13
|
}
|
15
14
|
|
16
15
|
let(:expected_dsl) {
|
17
16
|
erbh(<<-EOS)
|
18
17
|
create_table "salaries", id: false, force: :cascade do |t|
|
19
|
-
t.integer "emp_no",
|
20
|
-
t.integer "salary",
|
18
|
+
t.integer "emp_no", null: false
|
19
|
+
t.integer "salary", null: false
|
21
20
|
t.date "from_date", null: false
|
22
|
-
t.date "to_date",
|
21
|
+
t.date "to_date", null: false
|
22
|
+
t.index "emp_no", name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
23
23
|
end
|
24
|
-
|
25
|
-
<%= add_index "salaries", "emp_no", name: "emp_no", using: :btree %>
|
26
24
|
EOS
|
27
25
|
}
|
28
26
|
|
@@ -39,39 +37,36 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
37
|
let(:actual_dsl) {
|
40
38
|
erbh(<<-EOS)
|
41
39
|
create_table "salaries", id: false, force: :cascade do |t|
|
42
|
-
t.integer "emp_no",
|
43
|
-
t.integer "salary",
|
44
|
-
t.date "from_date",
|
45
|
-
t.date "to_date",
|
40
|
+
t.integer "emp_no", null: false
|
41
|
+
t.integer "salary", null: false
|
42
|
+
t.date "from_date", null: false
|
43
|
+
t.date "to_date", null: false
|
44
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
46
45
|
end
|
47
|
-
|
48
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
49
46
|
EOS
|
50
47
|
}
|
51
48
|
|
52
49
|
let(:dsl) {
|
53
50
|
erbh(<<-EOS)
|
54
51
|
create_table "salaries", id: false, force: :cascade do |t|
|
55
|
-
t.integer "emp_no",
|
56
|
-
t.integer "salary",
|
52
|
+
t.integer "emp_no", null: false
|
53
|
+
t.integer "salary", null: false
|
57
54
|
t.date "from_date", null: false
|
58
|
-
t.date "to_date",
|
55
|
+
t.date "to_date", null: false
|
56
|
+
t.index "salary", name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
59
57
|
end
|
60
|
-
|
61
|
-
<%= add_index "salaries", "salary", name: "emp_no", using: :btree %>
|
62
58
|
EOS
|
63
59
|
}
|
64
60
|
|
65
61
|
let(:expected_dsl) {
|
66
62
|
erbh(<<-EOS)
|
67
63
|
create_table "salaries", id: false, force: :cascade do |t|
|
68
|
-
t.integer "emp_no",
|
69
|
-
t.integer "salary",
|
70
|
-
t.date "from_date",
|
71
|
-
t.date "to_date",
|
64
|
+
t.integer "emp_no", null: false
|
65
|
+
t.integer "salary", null: false
|
66
|
+
t.date "from_date", null: false
|
67
|
+
t.date "to_date", null: false
|
68
|
+
t.index ["salary"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
72
69
|
end
|
73
|
-
|
74
|
-
<%= add_index "salaries", ["salary"], name: "emp_no", using: :btree %>
|
75
70
|
EOS
|
76
71
|
}
|
77
72
|
|
@@ -3,26 +3,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "salaries", id: false, force: :cascade do |t|
|
6
|
-
t.integer "emp_no",
|
7
|
-
t.integer "salary",
|
6
|
+
t.integer "emp_no", null: false
|
7
|
+
t.integer "salary", null: false
|
8
8
|
t.date "from_date", null: false
|
9
|
-
t.date "to_date",
|
9
|
+
t.date "to_date", null: false
|
10
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
10
11
|
end
|
11
|
-
|
12
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
13
12
|
EOS
|
14
13
|
}
|
15
14
|
|
16
15
|
let(:expected_dsl) {
|
17
|
-
|
16
|
+
<<-EOS
|
18
17
|
create_table "salaries", id: false, force: :cascade do |t|
|
19
|
-
t.integer "emp_no",
|
20
|
-
t.integer "salary",
|
18
|
+
t.integer "emp_no", null: false
|
19
|
+
t.integer "salary", null: false
|
21
20
|
t.date "from_date", null: false
|
22
|
-
t.date "to_date",
|
21
|
+
t.date "to_date", null: false
|
22
|
+
t.index ["emp_no"], name: "emp_no"
|
23
23
|
end
|
24
|
-
|
25
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no" %>
|
26
24
|
EOS
|
27
25
|
}
|
28
26
|
|
@@ -39,48 +37,45 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
37
|
let(:actual_dsl) {
|
40
38
|
erbh(<<-EOS)
|
41
39
|
create_table "salaries", id: false, force: :cascade do |t|
|
42
|
-
t.integer "emp_no",
|
43
|
-
t.integer "salary",
|
44
|
-
t.date "from_date",
|
45
|
-
t.date "to_date",
|
40
|
+
t.integer "emp_no", null: false
|
41
|
+
t.integer "salary", null: false
|
42
|
+
t.date "from_date", null: false
|
43
|
+
t.date "to_date", null: false
|
44
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
46
45
|
end
|
47
|
-
|
48
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
49
46
|
EOS
|
50
47
|
}
|
51
48
|
|
52
49
|
let(:dsl) {
|
53
|
-
|
50
|
+
<<-EOS
|
54
51
|
create_table "salaries", id: false, force: :cascade do |t|
|
55
|
-
t.integer "emp_no",
|
56
|
-
t.integer "salary",
|
52
|
+
t.integer "emp_no", null: false
|
53
|
+
t.integer "salary", null: false
|
57
54
|
t.date "from_date", null: false
|
58
|
-
t.date "to_date",
|
55
|
+
t.date "to_date", null: false
|
56
|
+
t.index ["salary"], using: :hash
|
59
57
|
end
|
60
|
-
|
61
|
-
<%= add_index "salaries", ["salary"], using: :hash %>
|
62
58
|
EOS
|
63
59
|
}
|
64
60
|
|
65
61
|
let(:expected_dsl) {
|
66
|
-
|
62
|
+
<<-EOS
|
67
63
|
create_table "salaries", id: false, force: :cascade do |t|
|
68
|
-
t.integer "emp_no",
|
69
|
-
t.integer "salary",
|
70
|
-
t.date "from_date",
|
71
|
-
t.date "to_date",
|
64
|
+
t.integer "emp_no", null: false
|
65
|
+
t.integer "salary", null: false
|
66
|
+
t.date "from_date", null: false
|
67
|
+
t.date "to_date", null: false
|
68
|
+
t.index ["salary"], name: "index_salaries_on_salary", using: :hash
|
72
69
|
end
|
73
|
-
|
74
|
-
<%= add_index "salaries", ["salary"], name: "index_salaries_on_salary", using: :hash %>
|
75
70
|
EOS
|
76
71
|
}
|
77
72
|
|
78
|
-
before { subject.diff(
|
73
|
+
before { subject.diff(<<-EOS).migrate }
|
79
74
|
create_table "salaries", id: false, force: :cascade do |t|
|
80
|
-
t.integer "emp_no",
|
81
|
-
t.integer "salary",
|
82
|
-
t.date "from_date",
|
83
|
-
t.date "to_date",
|
75
|
+
t.integer "emp_no", null: false
|
76
|
+
t.integer "salary", null: false
|
77
|
+
t.date "from_date", null: false
|
78
|
+
t.date "to_date", null: false
|
84
79
|
end
|
85
80
|
|
86
81
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -101,26 +96,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
101
96
|
let(:actual_dsl) {
|
102
97
|
erbh(<<-EOS)
|
103
98
|
create_table "salaries", id: false, force: :cascade do |t|
|
104
|
-
t.integer "emp_no",
|
105
|
-
t.integer "salary",
|
99
|
+
t.integer "emp_no", null: false
|
100
|
+
t.integer "salary", null: false
|
106
101
|
t.date "from_date", null: false
|
107
|
-
t.date "to_date",
|
102
|
+
t.date "to_date", null: false
|
103
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
108
104
|
end
|
109
|
-
|
110
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
111
105
|
EOS
|
112
106
|
}
|
113
107
|
|
114
108
|
let(:expected_dsl) {
|
115
109
|
erbh(<<-EOS)
|
116
110
|
create_table "salaries", id: false, force: :cascade do |t|
|
117
|
-
t.integer "emp_no",
|
118
|
-
t.integer "salary",
|
111
|
+
t.integer "emp_no", null: false
|
112
|
+
t.integer "salary", null: false
|
119
113
|
t.date "from_date", null: false
|
120
|
-
t.date "to_date",
|
114
|
+
t.date "to_date", null: false
|
115
|
+
t.index ["emp_no"], <%= i cond(5.0, using: :btree) %>
|
121
116
|
end
|
122
|
-
|
123
|
-
<%= add_index "salaries", ["emp_no"], using: :btree %>
|
124
117
|
EOS
|
125
118
|
}
|
126
119
|
|
@@ -137,39 +130,36 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
137
130
|
let(:actual_dsl) {
|
138
131
|
erbh(<<-EOS)
|
139
132
|
create_table "salaries", id: false, force: :cascade do |t|
|
140
|
-
t.integer "emp_no",
|
141
|
-
t.integer "salary",
|
142
|
-
t.date "from_date",
|
143
|
-
t.date "to_date",
|
133
|
+
t.integer "emp_no", null: false
|
134
|
+
t.integer "salary", null: false
|
135
|
+
t.date "from_date", null: false
|
136
|
+
t.date "to_date", null: false
|
137
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
144
138
|
end
|
145
|
-
|
146
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
147
139
|
EOS
|
148
140
|
}
|
149
141
|
|
150
142
|
let(:dsl) {
|
151
143
|
erbh(<<-EOS)
|
152
144
|
create_table "salaries", id: false, force: :cascade do |t|
|
153
|
-
t.integer "emp_no",
|
154
|
-
t.integer "salary",
|
145
|
+
t.integer "emp_no", null: false
|
146
|
+
t.integer "salary", null: false
|
155
147
|
t.date "from_date", null: false
|
156
|
-
t.date "to_date",
|
148
|
+
t.date "to_date", null: false
|
149
|
+
t.index ["salary"], <%= i cond(5.0, using: :btree) %>
|
157
150
|
end
|
158
|
-
|
159
|
-
<%= add_index "salaries", ["salary"], using: :btree %>
|
160
151
|
EOS
|
161
152
|
}
|
162
153
|
|
163
154
|
let(:expected_dsl) {
|
164
155
|
erbh(<<-EOS)
|
165
156
|
create_table "salaries", id: false, force: :cascade do |t|
|
166
|
-
t.integer "emp_no",
|
167
|
-
t.integer "salary",
|
168
|
-
t.date "from_date",
|
169
|
-
t.date "to_date",
|
157
|
+
t.integer "emp_no", null: false
|
158
|
+
t.integer "salary", null: false
|
159
|
+
t.date "from_date", null: false
|
160
|
+
t.date "to_date", null: false
|
161
|
+
t.index ["salary"], name: "index_salaries_on_salary", <%= i cond(5.0, using: :btree) %>
|
170
162
|
end
|
171
|
-
|
172
|
-
<%= add_index "salaries", ["salary"], name: "index_salaries_on_salary", using: :btree %>
|
173
163
|
EOS
|
174
164
|
}
|
175
165
|
|
@@ -2,27 +2,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index (same name)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "salaries",
|
6
|
-
t.integer "emp_no",
|
7
|
-
t.integer "salary",
|
8
|
-
t.date "from_date",
|
9
|
-
t.date "to_date",
|
5
|
+
create_table "salaries", force: :cascade 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
|
+
t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
10
11
|
end
|
11
|
-
|
12
|
-
<%= add_index "salaries", ["emp_no", "id"], name: "emp_no", using: :btree %>
|
13
12
|
EOS
|
14
13
|
}
|
15
14
|
|
16
15
|
let(:expected_dsl) {
|
17
16
|
erbh(<<-EOS)
|
18
|
-
create_table "salaries",
|
19
|
-
t.integer "emp_no",
|
20
|
-
t.integer "salary",
|
21
|
-
t.date "from_date",
|
22
|
-
t.date "to_date",
|
17
|
+
create_table "salaries", 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
|
+
t.index ["salary", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
23
23
|
end
|
24
|
-
|
25
|
-
<%= add_index "salaries", ["salary", "id"], name: "emp_no", using: :btree %>
|
26
24
|
EOS
|
27
25
|
}
|
28
26
|
|
@@ -42,26 +40,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
42
40
|
let(:actual_dsl) {
|
43
41
|
erbh(<<-EOS)
|
44
42
|
create_table "salaries", id: false, force: :cascade do |t|
|
45
|
-
t.integer "emp_no",
|
46
|
-
t.integer "salary",
|
47
|
-
t.date "from_date",
|
48
|
-
t.date "to_date",
|
43
|
+
t.integer "emp_no", null: false
|
44
|
+
t.integer "salary", null: false
|
45
|
+
t.date "from_date", null: false
|
46
|
+
t.date "to_date", null: false
|
47
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
49
48
|
end
|
50
|
-
|
51
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
52
49
|
EOS
|
53
50
|
}
|
54
51
|
|
55
52
|
let(:expected_dsl) {
|
56
53
|
erbh(<<-EOS)
|
57
54
|
create_table "salaries", id: false, force: :cascade do |t|
|
58
|
-
t.integer "emp_no",
|
59
|
-
t.integer "salary",
|
60
|
-
t.date "from_date",
|
61
|
-
t.date "to_date",
|
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
|
+
t.index ["salary"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
62
60
|
end
|
63
|
-
|
64
|
-
<%= add_index "salaries", ["salary"], name: "emp_no", using: :btree %>
|
65
61
|
EOS
|
66
62
|
}
|
67
63
|
|
@@ -80,25 +76,23 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
80
76
|
context 'when change index (same name) (3)' do
|
81
77
|
let(:actual_dsl) {
|
82
78
|
erbh(<<-EOS)
|
83
|
-
create_table "salaries", primary_key: "emp_no",
|
84
|
-
t.integer "salary",
|
85
|
-
t.date "from_date",
|
86
|
-
t.date "to_date",
|
79
|
+
create_table "salaries", primary_key: "emp_no", force: :cascade do |t|
|
80
|
+
t.integer "salary", null: false
|
81
|
+
t.date "from_date", null: false
|
82
|
+
t.date "to_date", null: false
|
83
|
+
t.index ["salary", "emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
87
84
|
end
|
88
|
-
|
89
|
-
<%= add_index "salaries", ["salary", "emp_no"], name: "emp_no", using: :btree %>
|
90
85
|
EOS
|
91
86
|
}
|
92
87
|
|
93
88
|
let(:expected_dsl) {
|
94
89
|
erbh(<<-EOS)
|
95
|
-
create_table "salaries", primary_key: "emp_no",
|
96
|
-
t.integer "salary",
|
97
|
-
t.date "from_date",
|
98
|
-
t.date "to_date",
|
90
|
+
create_table "salaries", primary_key: "emp_no", force: :cascade do |t|
|
91
|
+
t.integer "salary", null: false
|
92
|
+
t.date "from_date", null: false
|
93
|
+
t.date "to_date", null: false
|
94
|
+
t.index ["from_date", "emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
99
95
|
end
|
100
|
-
|
101
|
-
<%= add_index "salaries", ["from_date", "emp_no"], name: "emp_no", using: :btree %>
|
102
96
|
EOS
|
103
97
|
}
|
104
98
|
|
@@ -2,27 +2,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index (unique: false)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "salaries",
|
6
|
-
t.integer "emp_no",
|
7
|
-
t.integer "salary",
|
8
|
-
t.date "from_date",
|
9
|
-
t.date "to_date",
|
5
|
+
create_table "salaries", force: :cascade 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
|
+
t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
10
11
|
end
|
11
|
-
|
12
|
-
<%= add_index "salaries", ["emp_no", "id"], name: "emp_no", using: :btree %>
|
13
12
|
EOS
|
14
13
|
}
|
15
14
|
|
16
15
|
let(:expected_dsl) {
|
17
16
|
erbh(<<-EOS)
|
18
|
-
create_table "salaries",
|
19
|
-
t.integer "emp_no",
|
20
|
-
t.integer "salary",
|
21
|
-
t.date "from_date",
|
22
|
-
t.date "to_date",
|
17
|
+
create_table "salaries", 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
|
+
t.index ["emp_no", "id"], name: "emp_no", unique: false, <%= i cond(5.0, using: :btree) %>
|
23
23
|
end
|
24
|
-
|
25
|
-
<%= add_index "salaries", ["emp_no", "id"], name: "emp_no", unique: false, using: :btree %>
|
26
24
|
EOS
|
27
25
|
}
|
28
26
|
|
@@ -38,27 +36,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
38
36
|
context 'when change index (unique: true)' do
|
39
37
|
let(:actual_dsl) {
|
40
38
|
erbh(<<-EOS)
|
41
|
-
create_table "salaries",
|
42
|
-
t.integer "emp_no",
|
43
|
-
t.integer "salary",
|
44
|
-
t.date "from_date",
|
45
|
-
t.date "to_date",
|
39
|
+
create_table "salaries", force: :cascade do |t|
|
40
|
+
t.integer "emp_no", null: false
|
41
|
+
t.integer "salary", null: false
|
42
|
+
t.date "from_date", null: false
|
43
|
+
t.date "to_date", null: false
|
44
|
+
t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
46
45
|
end
|
47
|
-
|
48
|
-
<%= add_index "salaries", ["emp_no", "id"], name: "emp_no", using: :btree %>
|
49
46
|
EOS
|
50
47
|
}
|
51
48
|
|
52
49
|
let(:expected_dsl) {
|
53
50
|
erbh(<<-EOS)
|
54
|
-
create_table "salaries",
|
55
|
-
t.integer "emp_no",
|
56
|
-
t.integer "salary",
|
57
|
-
t.date "from_date",
|
58
|
-
t.date "to_date",
|
51
|
+
create_table "salaries", force: :cascade do |t|
|
52
|
+
t.integer "emp_no", null: false
|
53
|
+
t.integer "salary", null: false
|
54
|
+
t.date "from_date", null: false
|
55
|
+
t.date "to_date", null: false
|
56
|
+
t.index ["emp_no", "id"], name: "emp_no", unique: true, <%= i cond(5.0, using: :btree) %>
|
59
57
|
end
|
60
|
-
|
61
|
-
<%= add_index "salaries", ["emp_no", "id"], name: "emp_no", unique: true, using: :btree %>
|
62
58
|
EOS
|
63
59
|
}
|
64
60
|
|