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,18 +3,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
let(:current_schema) {
|
4
4
|
<<-EOS
|
5
5
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
|
-
t.date "birth_date",
|
6
|
+
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
8
|
-
t.string "last_name",
|
9
|
-
t.string "gender",
|
10
|
-
t.date "hire_date",
|
8
|
+
t.string "last_name", limit: 16, null: false
|
9
|
+
t.string "gender", limit: 1, null: false
|
10
|
+
t.date "hire_date", null: false
|
11
11
|
end
|
12
12
|
|
13
13
|
create_table "salaries", id: false, force: :cascade do |t|
|
14
|
-
t.integer "emp_no",
|
15
|
-
t.integer "salary",
|
14
|
+
t.integer "emp_no", null: false
|
15
|
+
t.integer "salary", null: false
|
16
16
|
t.date "from_date", null: false
|
17
|
-
t.date "to_date",
|
17
|
+
t.date "to_date", null: false
|
18
18
|
end
|
19
19
|
|
20
20
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
@@ -24,18 +24,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
24
24
|
let(:dsl) {
|
25
25
|
<<-EOS
|
26
26
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
27
|
-
t.date "birth_date",
|
27
|
+
t.date "birth_date", null: false
|
28
28
|
t.string "first_name", limit: 14, null: false
|
29
|
-
t.string "last_name",
|
30
|
-
t.string "gender",
|
31
|
-
t.date "hire_date",
|
29
|
+
t.string "last_name", limit: 16, null: false
|
30
|
+
t.string "gender", limit: 1, null: false
|
31
|
+
t.date "hire_date", null: false
|
32
32
|
end
|
33
33
|
|
34
34
|
create_table "salaries", id: false, force: :cascade do |t|
|
35
|
-
t.integer "emp_no",
|
36
|
-
t.integer "salary",
|
35
|
+
t.integer "emp_no", null: false
|
36
|
+
t.integer "salary", null: false
|
37
37
|
t.date "from_date", null: false
|
38
|
-
t.date "to_date",
|
38
|
+
t.date "to_date", null: false
|
39
39
|
end
|
40
40
|
|
41
41
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -45,11 +45,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
45
45
|
let(:expected_dsl) {
|
46
46
|
<<-EOS
|
47
47
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
48
|
-
t.date "birth_date",
|
48
|
+
t.date "birth_date", null: false
|
49
49
|
t.string "first_name", limit: 14, null: false
|
50
|
-
t.string "last_name",
|
51
|
-
t.string "gender",
|
52
|
-
t.date "hire_date",
|
50
|
+
t.string "last_name", limit: 16, null: false
|
51
|
+
t.string "gender", limit: 1, null: false
|
52
|
+
t.date "hire_date", null: false
|
53
53
|
end
|
54
54
|
EOS
|
55
55
|
}
|
@@ -70,18 +70,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
70
70
|
let(:current_schema) {
|
71
71
|
<<-EOS
|
72
72
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
73
|
-
t.date "birth_date",
|
73
|
+
t.date "birth_date", null: false
|
74
74
|
t.string "first_name", limit: 14, null: false
|
75
|
-
t.string "last_name",
|
76
|
-
t.string "gender",
|
77
|
-
t.date "hire_date",
|
75
|
+
t.string "last_name", limit: 16, null: false
|
76
|
+
t.string "gender", limit: 1, null: false
|
77
|
+
t.date "hire_date", null: false
|
78
78
|
end
|
79
79
|
|
80
80
|
create_table "salaries", id: false, force: :cascade do |t|
|
81
|
-
t.integer "emp_no",
|
82
|
-
t.integer "salary",
|
81
|
+
t.integer "emp_no", null: false
|
82
|
+
t.integer "salary", null: false
|
83
83
|
t.date "from_date", null: false
|
84
|
-
t.date "to_date",
|
84
|
+
t.date "to_date", null: false
|
85
85
|
end
|
86
86
|
|
87
87
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
@@ -91,18 +91,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
91
91
|
let(:dsl) {
|
92
92
|
<<-EOS
|
93
93
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
94
|
-
t.date "birth_date",
|
94
|
+
t.date "birth_date", null: false
|
95
95
|
t.string "first_name", limit: 15, null: false
|
96
|
-
t.string "last_name",
|
97
|
-
t.string "gender",
|
98
|
-
t.date "hire_date",
|
96
|
+
t.string "last_name", limit: 16, null: false
|
97
|
+
t.string "gender", limit: 1, null: false
|
98
|
+
t.date "hire_date", null: false
|
99
99
|
end
|
100
100
|
|
101
101
|
create_table "salaries", id: false, force: :cascade do |t|
|
102
|
-
t.integer "emp_no",
|
103
|
-
t.integer "salary",
|
102
|
+
t.integer "emp_no", null: false
|
103
|
+
t.integer "salary", null: false
|
104
104
|
t.date "from_date", null: false
|
105
|
-
t.date "to_date",
|
105
|
+
t.date "to_date", null: false
|
106
106
|
end
|
107
107
|
|
108
108
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -112,11 +112,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
112
112
|
let(:before_dsl) {
|
113
113
|
<<-EOS
|
114
114
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
115
|
-
t.date "birth_date",
|
115
|
+
t.date "birth_date", null: false
|
116
116
|
t.string "first_name", limit: 14, null: false
|
117
|
-
t.string "last_name",
|
118
|
-
t.string "gender",
|
119
|
-
t.date "hire_date",
|
117
|
+
t.string "last_name", limit: 16, null: false
|
118
|
+
t.string "gender", limit: 1, null: false
|
119
|
+
t.date "hire_date", null: false
|
120
120
|
end
|
121
121
|
EOS
|
122
122
|
}
|
@@ -124,11 +124,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
124
124
|
let(:after_dsl) {
|
125
125
|
<<-EOS
|
126
126
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
127
|
-
t.date "birth_date",
|
127
|
+
t.date "birth_date", null: false
|
128
128
|
t.string "first_name", limit: 15, null: false
|
129
|
-
t.string "last_name",
|
130
|
-
t.string "gender",
|
131
|
-
t.date "hire_date",
|
129
|
+
t.string "last_name", limit: 16, null: false
|
130
|
+
t.string "gender", limit: 1, null: false
|
131
|
+
t.date "hire_date", null: false
|
132
132
|
end
|
133
133
|
EOS
|
134
134
|
}
|
@@ -148,7 +148,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
148
|
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
149
149
|
expect(delta.differ?).to be_truthy
|
150
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(
|
151
|
+
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
152
152
|
EOS
|
153
153
|
}
|
154
154
|
end
|
@@ -157,18 +157,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
157
157
|
let(:current_schema) {
|
158
158
|
<<-EOS
|
159
159
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
160
|
-
t.date "birth_date",
|
160
|
+
t.date "birth_date", null: false
|
161
161
|
t.string "first_name", limit: 14, null: false
|
162
|
-
t.string "last_name",
|
163
|
-
t.string "gender",
|
164
|
-
t.date "hire_date",
|
162
|
+
t.string "last_name", limit: 16, null: false
|
163
|
+
t.string "gender", limit: 1, null: false
|
164
|
+
t.date "hire_date", null: false
|
165
165
|
end
|
166
166
|
|
167
167
|
create_table "salaries", id: false, force: :cascade do |t|
|
168
|
-
t.integer "emp_no",
|
169
|
-
t.integer "salary",
|
168
|
+
t.integer "emp_no", null: false
|
169
|
+
t.integer "salary", null: false
|
170
170
|
t.date "from_date", null: false
|
171
|
-
t.date "to_date",
|
171
|
+
t.date "to_date", null: false
|
172
172
|
end
|
173
173
|
|
174
174
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
@@ -178,18 +178,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
178
178
|
let(:dsl) {
|
179
179
|
<<-EOS
|
180
180
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
181
|
-
t.date "birth_date",
|
181
|
+
t.date "birth_date", null: false
|
182
182
|
t.string "first_name", limit: 15, null: false
|
183
|
-
t.string "last_name",
|
184
|
-
t.string "gender",
|
185
|
-
t.date "hire_date",
|
183
|
+
t.string "last_name", limit: 16, null: false
|
184
|
+
t.string "gender", limit: 1, null: false
|
185
|
+
t.date "hire_date", null: false
|
186
186
|
end
|
187
187
|
|
188
188
|
create_table "salaries", id: false, force: :cascade do |t|
|
189
|
-
t.integer "emp_no",
|
190
|
-
t.integer "salary",
|
189
|
+
t.integer "emp_no", null: false
|
190
|
+
t.integer "salary", null: false
|
191
191
|
t.date "from_date", null: false
|
192
|
-
t.date "to_date",
|
192
|
+
t.date "to_date", null: false
|
193
193
|
end
|
194
194
|
|
195
195
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -199,11 +199,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
199
199
|
let(:before_dsl) {
|
200
200
|
<<-EOS
|
201
201
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
202
|
-
t.date "birth_date",
|
202
|
+
t.date "birth_date", null: false
|
203
203
|
t.string "first_name", limit: 14, null: false
|
204
|
-
t.string "last_name",
|
205
|
-
t.string "gender",
|
206
|
-
t.date "hire_date",
|
204
|
+
t.string "last_name", limit: 16, null: false
|
205
|
+
t.string "gender", limit: 1, null: false
|
206
|
+
t.date "hire_date", null: false
|
207
207
|
end
|
208
208
|
EOS
|
209
209
|
}
|
@@ -211,11 +211,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
211
211
|
let(:after_dsl) {
|
212
212
|
<<-EOS
|
213
213
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
214
|
-
t.date "birth_date",
|
214
|
+
t.date "birth_date", null: false
|
215
215
|
t.string "first_name", limit: 15, null: false
|
216
|
-
t.string "last_name",
|
217
|
-
t.string "gender",
|
218
|
-
t.date "hire_date",
|
216
|
+
t.string "last_name", limit: 16, null: false
|
217
|
+
t.string "gender", limit: 1, null: false
|
218
|
+
t.date "hire_date", null: false
|
219
219
|
end
|
220
220
|
EOS
|
221
221
|
}
|
@@ -235,7 +235,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
235
235
|
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
236
236
|
expect(delta.differ?).to be_truthy
|
237
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(
|
238
|
+
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
239
239
|
EOS
|
240
240
|
}
|
241
241
|
end
|
@@ -244,18 +244,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
244
244
|
let(:current_schema) {
|
245
245
|
<<-EOS
|
246
246
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
247
|
-
t.date "birth_date",
|
247
|
+
t.date "birth_date", null: false
|
248
248
|
t.string "first_name", limit: 14, null: false
|
249
|
-
t.string "last_name",
|
250
|
-
t.string "gender",
|
251
|
-
t.date "hire_date",
|
249
|
+
t.string "last_name", limit: 16, null: false
|
250
|
+
t.string "gender", limit: 1, null: false
|
251
|
+
t.date "hire_date", null: false
|
252
252
|
end
|
253
253
|
|
254
254
|
create_table "salaries", id: false, force: :cascade do |t|
|
255
|
-
t.integer "emp_no",
|
256
|
-
t.integer "salary",
|
255
|
+
t.integer "emp_no", null: false
|
256
|
+
t.integer "salary", null: false
|
257
257
|
t.date "from_date", null: false
|
258
|
-
t.date "to_date",
|
258
|
+
t.date "to_date", null: false
|
259
259
|
end
|
260
260
|
|
261
261
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
@@ -265,18 +265,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
265
265
|
let(:dsl) {
|
266
266
|
<<-EOS
|
267
267
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
268
|
-
t.date "birth_date",
|
268
|
+
t.date "birth_date", null: false
|
269
269
|
t.string "first_name", limit: 15, null: false
|
270
|
-
t.string "last_name",
|
271
|
-
t.string "gender",
|
272
|
-
t.date "hire_date",
|
270
|
+
t.string "last_name", limit: 16, null: false
|
271
|
+
t.string "gender", limit: 1, null: false
|
272
|
+
t.date "hire_date", null: false
|
273
273
|
end
|
274
274
|
|
275
275
|
create_table "salaries", id: false, force: :cascade do |t|
|
276
|
-
t.integer "emp_no",
|
277
|
-
t.integer "salary",
|
276
|
+
t.integer "emp_no", null: false
|
277
|
+
t.integer "salary", null: false
|
278
278
|
t.date "from_date", null: false
|
279
|
-
t.date "to_date",
|
279
|
+
t.date "to_date", null: false
|
280
280
|
end
|
281
281
|
|
282
282
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -286,11 +286,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
286
286
|
let(:before_dsl) {
|
287
287
|
<<-EOS
|
288
288
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
289
|
-
t.date "birth_date",
|
289
|
+
t.date "birth_date", null: false
|
290
290
|
t.string "first_name", limit: 14, null: false
|
291
|
-
t.string "last_name",
|
292
|
-
t.string "gender",
|
293
|
-
t.date "hire_date",
|
291
|
+
t.string "last_name", limit: 16, null: false
|
292
|
+
t.string "gender", limit: 1, null: false
|
293
|
+
t.date "hire_date", null: false
|
294
294
|
end
|
295
295
|
EOS
|
296
296
|
}
|
@@ -298,11 +298,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
298
298
|
let(:after_dsl) {
|
299
299
|
<<-EOS
|
300
300
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
301
|
-
t.date "birth_date",
|
301
|
+
t.date "birth_date", null: false
|
302
302
|
t.string "first_name", limit: 15, null: false
|
303
|
-
t.string "last_name",
|
304
|
-
t.string "gender",
|
305
|
-
t.date "hire_date",
|
303
|
+
t.string "last_name", limit: 16, null: false
|
304
|
+
t.string "gender", limit: 1, null: false
|
305
|
+
t.date "hire_date", null: false
|
306
306
|
end
|
307
307
|
EOS
|
308
308
|
}
|
@@ -322,7 +322,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
322
322
|
delta = Ridgepole::Client.diff(current_schema, dsl, ignore_tables: [/^salaries$/], reverse: true, enable_mysql_awesome: true)
|
323
323
|
expect(delta.differ?).to be_truthy
|
324
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(
|
325
|
+
change_column("employees", "first_name", :string, <%= {:limit=>14, :null=>false, :default=>nil, :unsigned=>false} + cond(5.1, comment: nil) %>)
|
326
326
|
EOS
|
327
327
|
}
|
328
328
|
end
|
@@ -5,145 +5,131 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
5
5
|
erbh(<<-EOS)
|
6
6
|
create_table "clubs", force: :cascade do |t|
|
7
7
|
t.string "name", default: "", null: false
|
8
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
8
9
|
end
|
9
10
|
|
10
|
-
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
11
|
-
|
12
11
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
12
|
t.string "dept_name", limit: 40, null: false
|
13
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
14
14
|
end
|
15
15
|
|
16
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
17
|
-
|
18
16
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
19
|
-
t.integer "emp_no",
|
20
|
-
t.string "dept_no",
|
21
|
-
t.date "from_date",
|
22
|
-
t.date "to_date",
|
17
|
+
t.integer "emp_no", null: false
|
18
|
+
t.string "dept_no", null: false
|
19
|
+
t.date "from_date", null: false
|
20
|
+
t.date "to_date", null: false
|
21
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
22
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
23
23
|
end
|
24
24
|
|
25
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
26
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
27
|
-
|
28
25
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
29
|
-
t.string "dept_no",
|
30
|
-
t.integer "emp_no",
|
31
|
-
t.date "from_date",
|
32
|
-
t.date "to_date",
|
26
|
+
t.string "dept_no", null: false
|
27
|
+
t.integer "emp_no", null: false
|
28
|
+
t.date "from_date", null: false
|
29
|
+
t.date "to_date", null: false
|
30
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
31
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
33
32
|
end
|
34
33
|
|
35
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
36
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
37
|
-
|
38
34
|
create_table "employee_clubs", force: :cascade do |t|
|
39
|
-
t.integer "emp_no",
|
35
|
+
t.integer "emp_no", null: false
|
40
36
|
t.integer "club_id", null: false
|
37
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
41
38
|
end
|
42
39
|
|
43
|
-
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
44
|
-
|
45
40
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
46
|
-
t.date "birth_date",
|
41
|
+
t.date "birth_date", null: false
|
47
42
|
t.string "first_name", limit: 14, null: false
|
48
|
-
t.string "last_name",
|
49
|
-
t.string "gender",
|
50
|
-
t.date "hire_date",
|
43
|
+
t.string "last_name", limit: 16, null: false
|
44
|
+
t.string "gender", limit: 1, null: false
|
45
|
+
t.date "hire_date", null: false
|
51
46
|
end
|
52
47
|
|
53
48
|
create_table "salaries", id: false, force: :cascade do |t|
|
54
|
-
t.integer "emp_no",
|
55
|
-
t.integer "salary",
|
49
|
+
t.integer "emp_no", null: false
|
50
|
+
t.integer "salary", null: false
|
56
51
|
t.date "from_date", null: false
|
57
|
-
t.date "to_date",
|
52
|
+
t.date "to_date", null: false
|
53
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
58
54
|
end
|
59
55
|
|
60
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
61
|
-
|
62
56
|
create_table "titles", id: false, force: :cascade do |t|
|
63
|
-
t.integer "emp_no",
|
64
|
-
t.string "title",
|
65
|
-
t.date "from_date",
|
57
|
+
t.integer "emp_no", null: false
|
58
|
+
t.string "title", limit: 50, null: false
|
59
|
+
t.date "from_date", null: false
|
66
60
|
t.date "to_date"
|
61
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
67
62
|
end
|
68
|
-
|
69
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
70
63
|
EOS
|
71
64
|
}
|
72
65
|
|
73
66
|
let(:expected_dsl) {
|
74
67
|
erbh(<<-EOS)
|
75
68
|
create_table "clubs", force: :cascade do |t|
|
76
|
-
t.string "name",
|
69
|
+
t.string "name", default: "", null: false
|
70
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
77
71
|
end
|
78
72
|
|
79
|
-
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
80
|
-
|
81
73
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
82
74
|
t.string "dept_name", limit: 40, null: false
|
75
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
83
76
|
end
|
84
77
|
|
85
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
86
|
-
|
87
78
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
88
|
-
t.integer "emp_no",
|
89
|
-
t.string "dept_no",
|
90
|
-
t.date "from_date",
|
91
|
-
t.date "to_date",
|
79
|
+
t.integer "emp_no", null: false
|
80
|
+
t.string "dept_no", null: false
|
81
|
+
t.date "from_date", null: false
|
82
|
+
t.date "to_date", null: false
|
83
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
84
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
92
85
|
end
|
93
86
|
|
94
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
95
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
96
|
-
|
97
87
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
98
|
-
t.string "dept_no",
|
99
|
-
t.integer "emp_no",
|
100
|
-
t.date "from_date",
|
101
|
-
t.date "to_date",
|
88
|
+
t.string "dept_no", null: false
|
89
|
+
t.integer "emp_no", null: false
|
90
|
+
t.date "from_date", null: false
|
91
|
+
t.date "to_date", null: false
|
92
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
93
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
102
94
|
end
|
103
95
|
|
104
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
105
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
106
|
-
|
107
96
|
create_table "employee_clubs", force: :cascade do |t|
|
108
|
-
t.integer "emp_no",
|
109
|
-
t.integer "club_id",
|
97
|
+
t.integer "emp_no", null: false
|
98
|
+
t.integer "club_id", null: false
|
99
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
110
100
|
end
|
111
101
|
|
112
|
-
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
113
|
-
|
114
102
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
115
|
-
t.date "birth_date",
|
103
|
+
t.date "birth_date", null: false
|
116
104
|
t.string "first_name", limit: 14, null: false
|
117
|
-
t.string "last_name",
|
118
|
-
t.string "gender",
|
119
|
-
t.date "hire_date",
|
105
|
+
t.string "last_name", limit: 16, null: false
|
106
|
+
t.string "gender", limit: 1, null: false
|
107
|
+
t.date "hire_date", null: false
|
120
108
|
end
|
121
109
|
|
122
110
|
create_table "post", id: false, force: :cascade do |t|
|
123
|
-
t.integer "id"
|
111
|
+
t.integer "id"
|
124
112
|
end
|
125
113
|
|
126
114
|
create_table "pre", id: false, force: :cascade do |t|
|
127
|
-
t.integer "id"
|
115
|
+
t.integer "id"
|
128
116
|
end
|
129
117
|
|
130
118
|
create_table "salaries", id: false, force: :cascade do |t|
|
131
|
-
t.integer "emp_no",
|
132
|
-
t.integer "salary",
|
133
|
-
t.date "from_date",
|
134
|
-
t.date "to_date",
|
119
|
+
t.integer "emp_no", null: false
|
120
|
+
t.integer "salary", null: false
|
121
|
+
t.date "from_date", null: false
|
122
|
+
t.date "to_date", null: false
|
123
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
135
124
|
end
|
136
125
|
|
137
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
138
|
-
|
139
126
|
create_table "titles", id: false, force: :cascade do |t|
|
140
|
-
t.integer "emp_no",
|
141
|
-
t.string "title",
|
142
|
-
t.date "from_date",
|
127
|
+
t.integer "emp_no", null: false
|
128
|
+
t.string "title", limit: 50, null: false
|
129
|
+
t.date "from_date", null: false
|
143
130
|
t.date "to_date"
|
131
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
144
132
|
end
|
145
|
-
|
146
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
147
133
|
EOS
|
148
134
|
}
|
149
135
|
|