ridgepole 0.5.3.beta4 → 0.6.0.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 +22 -50
- data/bin/ridgepole +8 -18
- data/lib/ridgepole/client.rb +10 -16
- data/lib/ridgepole/delta.rb +57 -19
- data/lib/ridgepole/diff.rb +45 -14
- data/lib/ridgepole/dsl_parser.rb +38 -8
- data/lib/ridgepole/execute_expander.rb +0 -29
- data/lib/ridgepole/ext/mysql_awesome.rb +1 -5
- data/lib/ridgepole/version.rb +1 -1
- data/lib/ridgepole.rb +10 -2
- data/ridgepole.gemspec +3 -8
- data/spec/bigint_pk/bigint_pkspec.rb +2 -2
- data/spec/cli/ridgepole_spec.rb +3 -5
- data/spec/collation/collation_spec.rb +35 -35
- data/spec/diff/diff2_spec.rb +18 -18
- data/spec/diff/diff_spec.rb +18 -18
- data/spec/dump/dump_class_method_spec.rb +18 -18
- data/spec/dump/dump_some_tables_spec.rb +12 -12
- data/spec/dump/dump_spec.rb +18 -18
- data/spec/dump/dump_without_table_options_spec.rb +6 -6
- data/spec/migrate/check_orphan_index_spec.rb +8 -8
- data/spec/migrate/migrate_add_column2_spec.rb +15 -15
- data/spec/migrate/migrate_add_column_spec.rb +40 -40
- data/spec/migrate/migrate_change_column2_spec.rb +5 -5
- data/spec/migrate/migrate_change_column3_spec.rb +26 -26
- data/spec/migrate/migrate_change_column_float_spec.rb +7 -7
- data/spec/migrate/migrate_change_column_spec.rb +42 -42
- data/spec/migrate/migrate_change_index2_spec.rb +13 -13
- data/spec/migrate/migrate_change_index3_spec.rb +26 -26
- data/spec/migrate/migrate_change_index4_spec.rb +28 -28
- data/spec/migrate/migrate_change_index_spec.rb +46 -46
- data/spec/migrate/migrate_change_table_option_spec.rb +2 -2
- data/spec/migrate/migrate_create_index_spec.rb +18 -18
- data/spec/migrate/migrate_create_table_spec.rb +18 -18
- data/spec/migrate/migrate_create_table_with_options_spec.rb +3 -3
- data/spec/migrate/migrate_drop_column_and_index_2_spec.rb +35 -35
- data/spec/migrate/migrate_drop_column_and_index_spec.rb +33 -33
- data/spec/migrate/migrate_drop_column_spec.rb +36 -36
- data/spec/migrate/migrate_drop_index_spec.rb +18 -18
- data/spec/migrate/migrate_drop_table_spec.rb +24 -24
- data/spec/migrate/migrate_duplicate_index_spec.rb +1 -1
- data/spec/migrate/migrate_duplicate_table_spec.rb +2 -2
- data/spec/migrate/migrate_empty_spec.rb +18 -18
- data/spec/migrate/migrate_execute_spec.rb +58 -49
- data/spec/migrate/migrate_merge_mode_spec.rb +38 -38
- data/spec/migrate/migrate_noop_spec.rb +40 -40
- data/spec/migrate/migrate_rename_column_spec.rb +37 -37
- data/spec/migrate/migrate_rename_table_spec.rb +39 -39
- data/spec/migrate/migrate_same_default_null_spec.rb +4 -4
- data/spec/migrate/migrate_same_spec.rb +18 -18
- data/spec/migrate/migrate_script_error_spec.rb +8 -8
- data/spec/migrate/migrate_skip_rename_column_spec.rb +36 -36
- data/spec/migrate/migrate_skip_rename_table_spec.rb +36 -36
- data/spec/migrate/migrate_with_ignore_tables_spec.rb +12 -12
- data/spec/migrate/migrate_with_pre_post_query_spec.rb +32 -32
- data/spec/migrate/migrate_with_tables_spec.rb +12 -12
- data/spec/migrate_0/migrate_change_fk_spec.rb +11 -11
- data/spec/migrate_0/migrate_create_fk_spec.rb +29 -30
- data/spec/migrate_0/migrate_drop_fk_spec.rb +22 -23
- data/spec/spec_helper.rb +24 -2
- metadata +10 -89
- data/lib/ridgepole/ext/foreign_key.rb +0 -121
- data/spec/0_diff/dump_disable_unsigned_spec.rb +0 -75
- data/spec/comment/comment_spec.rb +0 -179
- data/spec/migrate/migrate_same_default_unsigned_spec.rb +0 -63
- data/spec/~pkdump/pkdump_spec.rb +0 -67
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when use timestamps (no change)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "employees", primary_key: "emp_no", force:
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
6
|
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
8
8
|
t.string "last_name", limit: 16, null: false
|
@@ -16,7 +16,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
16
16
|
|
17
17
|
let(:expected_dsl) {
|
18
18
|
<<-RUBY
|
19
|
-
create_table "employees", primary_key: "emp_no", force:
|
19
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
20
20
|
t.date "birth_date", null: false
|
21
21
|
t.string "first_name", limit: 14, null: false
|
22
22
|
t.string "last_name", limit: 16, null: false
|
@@ -39,7 +39,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
39
|
context 'when use timestamps (change)' do
|
40
40
|
let(:actual_dsl) {
|
41
41
|
<<-RUBY
|
42
|
-
create_table "employees", primary_key: "emp_no", force:
|
42
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
43
43
|
t.date "birth_date", null: false
|
44
44
|
t.string "first_name", limit: 14, null: false
|
45
45
|
t.string "last_name", limit: 16, null: false
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
|
52
52
|
let(:dsl) {
|
53
53
|
<<-RUBY
|
54
|
-
create_table "employees", primary_key: "emp_no", force:
|
54
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
55
55
|
t.date "birth_date", null: false
|
56
56
|
t.string "first_name", limit: 14, null: false
|
57
57
|
t.string "last_name", limit: 16, null: false
|
@@ -64,7 +64,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
64
64
|
|
65
65
|
let(:expected_dsl) {
|
66
66
|
<<-RUBY
|
67
|
-
create_table "employees", primary_key: "emp_no", force:
|
67
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
68
68
|
t.date "birth_date", null: false
|
69
69
|
t.string "first_name", limit: 14, null: false
|
70
70
|
t.string "last_name", limit: 16, null: false
|
@@ -91,7 +91,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
91
91
|
context 'when use references (no change)' do
|
92
92
|
let(:actual_dsl) {
|
93
93
|
<<-RUBY
|
94
|
-
create_table "employees", primary_key: "emp_no", force:
|
94
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
95
95
|
t.date "birth_date", null: false
|
96
96
|
t.string "first_name", limit: 14, null: false
|
97
97
|
t.string "last_name", limit: 16, null: false
|
@@ -105,7 +105,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
105
105
|
|
106
106
|
let(:expected_dsl) {
|
107
107
|
<<-RUBY
|
108
|
-
create_table "employees", primary_key: "emp_no", force:
|
108
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
109
109
|
t.date "birth_date", null: false
|
110
110
|
t.string "first_name", limit: 14, null: false
|
111
111
|
t.string "last_name", limit: 16, null: false
|
@@ -128,7 +128,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
128
128
|
context 'when use references with polymorphic (no change)' do
|
129
129
|
let(:actual_dsl) {
|
130
130
|
<<-RUBY
|
131
|
-
create_table "employees", primary_key: "emp_no", force:
|
131
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
132
132
|
t.date "birth_date", null: false
|
133
133
|
t.string "first_name", limit: 14, null: false
|
134
134
|
t.string "last_name", limit: 16, null: false
|
@@ -144,7 +144,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
144
144
|
|
145
145
|
let(:expected_dsl) {
|
146
146
|
<<-RUBY
|
147
|
-
create_table "employees", primary_key: "emp_no", force:
|
147
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
148
148
|
t.date "birth_date", null: false
|
149
149
|
t.string "first_name", limit: 14, null: false
|
150
150
|
t.string "last_name", limit: 16, null: false
|
@@ -167,7 +167,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
167
167
|
context 'when use references (change)' do
|
168
168
|
let(:actual_dsl) {
|
169
169
|
<<-RUBY
|
170
|
-
create_table "employees", primary_key: "emp_no", force:
|
170
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
171
171
|
t.date "birth_date", null: false
|
172
172
|
t.string "first_name", limit: 14, null: false
|
173
173
|
t.string "last_name", limit: 16, null: false
|
@@ -179,7 +179,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
179
179
|
|
180
180
|
let(:dsl) {
|
181
181
|
<<-RUBY
|
182
|
-
create_table "employees", primary_key: "emp_no", force:
|
182
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
183
183
|
t.date "birth_date", null: false
|
184
184
|
t.string "first_name", limit: 14, null: false
|
185
185
|
t.string "last_name", limit: 16, null: false
|
@@ -192,14 +192,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
192
192
|
|
193
193
|
let(:expected_dsl) {
|
194
194
|
<<-RUBY
|
195
|
-
create_table "employees", primary_key: "emp_no", force:
|
195
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
196
196
|
t.date "birth_date", null: false
|
197
197
|
t.string "first_name", limit: 14, null: false
|
198
198
|
t.string "last_name", limit: 16, null: false
|
199
199
|
t.string "gender", limit: 1, null: false
|
200
200
|
t.date "hire_date", null: false
|
201
|
-
t.integer "products_id"
|
202
|
-
t.integer "user_id"
|
201
|
+
t.integer "products_id", limit: 4
|
202
|
+
t.integer "user_id", limit: 4
|
203
203
|
end
|
204
204
|
RUBY
|
205
205
|
}
|
@@ -219,7 +219,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
219
219
|
context 'when use references with polymorphic (change)' do
|
220
220
|
let(:actual_dsl) {
|
221
221
|
<<-RUBY
|
222
|
-
create_table "employees", primary_key: "emp_no", force:
|
222
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
223
223
|
t.date "birth_date", null: false
|
224
224
|
t.string "first_name", limit: 14, null: false
|
225
225
|
t.string "last_name", limit: 16, null: false
|
@@ -231,7 +231,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
231
231
|
|
232
232
|
let(:dsl) {
|
233
233
|
<<-RUBY
|
234
|
-
create_table "employees", primary_key: "emp_no", force:
|
234
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
235
235
|
t.date "birth_date", null: false
|
236
236
|
t.string "first_name", limit: 14, null: false
|
237
237
|
t.string "last_name", limit: 16, null: false
|
@@ -244,16 +244,16 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
244
244
|
|
245
245
|
let(:expected_dsl) {
|
246
246
|
<<-RUBY
|
247
|
-
create_table "employees", primary_key: "emp_no", force:
|
248
|
-
t.date "birth_date",
|
249
|
-
t.string "first_name", limit: 14,
|
250
|
-
t.string "last_name", limit: 16,
|
251
|
-
t.string "gender", limit: 1,
|
252
|
-
t.date "hire_date",
|
253
|
-
t.integer "products_id"
|
254
|
-
t.string "products_type"
|
255
|
-
t.integer "user_id"
|
256
|
-
t.string "user_type"
|
247
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
248
|
+
t.date "birth_date", null: false
|
249
|
+
t.string "first_name", limit: 14, null: false
|
250
|
+
t.string "last_name", limit: 16, null: false
|
251
|
+
t.string "gender", limit: 1, null: false
|
252
|
+
t.date "hire_date", null: false
|
253
|
+
t.integer "products_id", limit: 4
|
254
|
+
t.string "products_type", limit: 255
|
255
|
+
t.integer "user_id", limit: 4
|
256
|
+
t.string "user_type", limit: 255
|
257
257
|
end
|
258
258
|
RUBY
|
259
259
|
}
|
@@ -2,8 +2,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change float column' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "salaries", id: false, force:
|
6
|
-
t.integer "emp_no",
|
5
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
6
|
+
t.integer "emp_no", limit: 4, null: false
|
7
7
|
t.float "salary", limit: 24, null: false
|
8
8
|
t.date "from_date", null: false
|
9
9
|
t.date "to_date", null: false
|
@@ -13,7 +13,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
13
13
|
|
14
14
|
let(:expected_dsl) {
|
15
15
|
<<-RUBY
|
16
|
-
create_table "salaries", id: false, force:
|
16
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
17
17
|
t.integer "emp_no", null: false
|
18
18
|
t.float "salary", null: false
|
19
19
|
t.date "from_date", null: false
|
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
23
23
|
}
|
24
24
|
|
25
25
|
before { subject.diff(actual_dsl).migrate }
|
26
|
-
subject { client }
|
26
|
+
subject { client(default_float_limit: 0) }
|
27
27
|
|
28
28
|
it {
|
29
29
|
delta = subject.diff(expected_dsl)
|
@@ -37,7 +37,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
37
37
|
context 'when change float column (no change)' do
|
38
38
|
let(:actual_dsl) {
|
39
39
|
<<-RUBY
|
40
|
-
create_table "salaries", id: false, force:
|
40
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
41
41
|
t.integer "emp_no", null: false
|
42
42
|
t.float "salary", limit: 24, null: false
|
43
43
|
t.date "from_date", null: false
|
@@ -48,7 +48,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
48
48
|
|
49
49
|
let(:expected_dsl) {
|
50
50
|
<<-RUBY
|
51
|
-
create_table "salaries", id: false, force:
|
51
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
52
52
|
t.integer "emp_no", null: false
|
53
53
|
t.float "salary", null: false
|
54
54
|
t.date "from_date", null: false
|
@@ -58,7 +58,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
58
58
|
}
|
59
59
|
|
60
60
|
before { subject.diff(actual_dsl).migrate }
|
61
|
-
subject { client
|
61
|
+
subject { client }
|
62
62
|
|
63
63
|
it {
|
64
64
|
delta = subject.diff(expected_dsl)
|
@@ -2,20 +2,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change column' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "clubs", force:
|
6
|
-
t.string "name", default: "", null: false
|
5
|
+
create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
6
|
+
t.string "name", limit: 255, default: "", null: false
|
7
7
|
end
|
8
8
|
|
9
9
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
10
10
|
|
11
|
-
create_table "departments", primary_key: "dept_no", force:
|
11
|
+
create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
12
12
|
t.string "dept_name", limit: 40, null: false
|
13
13
|
end
|
14
14
|
|
15
15
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
16
16
|
|
17
|
-
create_table "dept_emp", id: false, force:
|
18
|
-
t.integer "emp_no",
|
17
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
+
t.integer "emp_no", limit: 4, null: false
|
19
19
|
t.string "dept_no", limit: 4, null: false
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
@@ -24,9 +24,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
24
24
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
25
25
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
26
26
|
|
27
|
-
create_table "dept_manager", id: false, force:
|
27
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
28
|
t.string "dept_no", limit: 4, null: false
|
29
|
-
t.integer "emp_no",
|
29
|
+
t.integer "emp_no", limit: 4, null: false
|
30
30
|
t.date "from_date", null: false
|
31
31
|
t.date "to_date", null: false
|
32
32
|
end
|
@@ -34,14 +34,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
34
34
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
35
35
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
36
36
|
|
37
|
-
create_table "employee_clubs", force:
|
38
|
-
t.integer "emp_no",
|
39
|
-
t.integer "club_id",
|
37
|
+
create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
38
|
+
t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
|
39
|
+
t.integer "club_id", limit: 4, null: false#{unsigned_if_enabled}
|
40
40
|
end
|
41
41
|
|
42
42
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
43
43
|
|
44
|
-
create_table "employees", primary_key: "emp_no", force:
|
44
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
45
45
|
t.date "birth_date", null: false
|
46
46
|
t.string "first_name", limit: 14, null: false
|
47
47
|
t.string "last_name", limit: 16, null: false
|
@@ -49,17 +49,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
49
49
|
t.date "hire_date", null: false
|
50
50
|
end
|
51
51
|
|
52
|
-
create_table "salaries", id: false, force:
|
53
|
-
t.integer "emp_no", null: false
|
54
|
-
t.integer "salary", null: false
|
55
|
-
t.date "from_date",
|
56
|
-
t.date "to_date",
|
52
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
+
t.integer "emp_no", limit: 4, null: false
|
54
|
+
t.integer "salary", limit: 4, null: false
|
55
|
+
t.date "from_date", null: false
|
56
|
+
t.date "to_date", null: false
|
57
57
|
end
|
58
58
|
|
59
59
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
60
60
|
|
61
|
-
create_table "titles", id: false, force:
|
62
|
-
t.integer "emp_no",
|
61
|
+
create_table "titles", id: false, force: :cascade do |t|
|
62
|
+
t.integer "emp_no", limit: 4, null: false
|
63
63
|
t.string "title", limit: 50, null: false
|
64
64
|
t.date "from_date", null: false
|
65
65
|
t.date "to_date"
|
@@ -71,20 +71,20 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
71
71
|
|
72
72
|
let(:expected_dsl) {
|
73
73
|
<<-RUBY
|
74
|
-
create_table "clubs", force:
|
75
|
-
t.string "name", default: "", null: false
|
74
|
+
create_table "clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
75
|
+
t.string "name", limit: 255, default: "", null: false
|
76
76
|
end
|
77
77
|
|
78
78
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
79
79
|
|
80
|
-
create_table "departments", primary_key: "dept_no", force:
|
80
|
+
create_table "departments", primary_key: "dept_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
81
81
|
t.string "dept_name", limit: 40, null: false
|
82
82
|
end
|
83
83
|
|
84
84
|
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
85
85
|
|
86
|
-
create_table "dept_emp", id: false, force:
|
87
|
-
t.integer "emp_no",
|
86
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
+
t.integer "emp_no", limit: 4, null: false
|
88
88
|
t.string "dept_no", limit: 4, null: false
|
89
89
|
t.date "from_date", null: false
|
90
90
|
t.date "to_date", null: false
|
@@ -93,9 +93,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
93
93
|
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
94
94
|
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
95
95
|
|
96
|
-
create_table "dept_manager", id: false, force:
|
96
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
97
|
t.string "dept_no", limit: 4, null: false
|
98
|
-
t.integer "emp_no",
|
98
|
+
t.integer "emp_no", limit: 4, null: false
|
99
99
|
t.date "from_date", null: false
|
100
100
|
t.date "to_date", null: false
|
101
101
|
end
|
@@ -103,14 +103,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
103
103
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
104
104
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
105
105
|
|
106
|
-
create_table "employee_clubs", force:
|
107
|
-
t.integer "emp_no",
|
108
|
-
t.integer "club_id",
|
106
|
+
create_table "employee_clubs"#{unsigned_if_enabled}, force: :cascade do |t|
|
107
|
+
t.integer "emp_no", limit: 4, null: false#{unsigned_if_enabled}
|
108
|
+
t.integer "club_id", limit: 4
|
109
109
|
end
|
110
110
|
|
111
111
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
112
112
|
|
113
|
-
create_table "employees", primary_key: "emp_no", force:
|
113
|
+
create_table "employees", primary_key: "emp_no"#{unsigned_if_enabled}, force: :cascade do |t|
|
114
114
|
t.date "birth_date", null: false
|
115
115
|
t.string "first_name", limit: 14, null: false
|
116
116
|
t.string "last_name", limit: 20, default: "XXX", null: false
|
@@ -118,17 +118,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
118
118
|
t.date "hire_date", null: false
|
119
119
|
end
|
120
120
|
|
121
|
-
create_table "salaries", id: false, force:
|
122
|
-
t.integer "emp_no", null: false
|
123
|
-
t.integer "salary", null: false
|
124
|
-
t.date "from_date",
|
125
|
-
t.date "to_date",
|
121
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
122
|
+
t.integer "emp_no", limit: 4, null: false
|
123
|
+
t.integer "salary", limit: 4, null: false
|
124
|
+
t.date "from_date", null: false
|
125
|
+
t.date "to_date", null: false
|
126
126
|
end
|
127
127
|
|
128
128
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
129
129
|
|
130
|
-
create_table "titles", id: false, force:
|
131
|
-
t.integer "emp_no",
|
130
|
+
create_table "titles", id: false, force: :cascade do |t|
|
131
|
+
t.integer "emp_no", limit: 4, null: false
|
132
132
|
t.string "title", limit: 50, null: false
|
133
133
|
t.date "from_date", null: false
|
134
134
|
t.date "to_date"
|
@@ -153,10 +153,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
153
153
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true, enable_mysql_unsigned: true)
|
154
154
|
expect(delta.differ?).to be_truthy
|
155
155
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
156
|
-
change_column("employee_clubs", "club_id", :integer, {:null=>false
|
156
|
+
change_column("employee_clubs", "club_id", :integer, {:null=>false#{unsigned_if_enabled2}})
|
157
157
|
|
158
|
-
change_column("employees", "last_name", :string, {:limit=>16, :null=>false
|
159
|
-
change_column("employees", "gender", :string, {:limit=>1, :null=>false
|
158
|
+
change_column("employees", "last_name", :string, {:limit=>16, :null=>false})
|
159
|
+
change_column("employees", "gender", :string, {:limit=>1, :null=>false})
|
160
160
|
RUBY
|
161
161
|
}
|
162
162
|
|
@@ -166,12 +166,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
166
166
|
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
167
167
|
expect(delta.script).to eq <<-RUBY.strip_heredoc.strip
|
168
168
|
change_table("employee_clubs", {:bulk => true}) do |t|
|
169
|
-
t.change("club_id", :integer, {:
|
169
|
+
t.change("club_id", :integer, {:null=>true, :default=>nil#{unsigned_false_if_enabled2}})
|
170
170
|
end
|
171
171
|
|
172
172
|
change_table("employees", {:bulk => true}) do |t|
|
173
|
-
t.change("last_name", :string, {:limit=>20, :default=>"XXX", :null=>false
|
174
|
-
t.change("gender", :string, {:limit=>2, :null=>false
|
173
|
+
t.change("last_name", :string, {:limit=>20, :default=>"XXX", :null=>false#{unsigned_false_if_enabled2}})
|
174
|
+
t.change("gender", :string, {:limit=>2, :null=>false#{unsigned_false_if_enabled2}})
|
175
175
|
end
|
176
176
|
RUBY
|
177
177
|
delta.migrate
|
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index (no change)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "salaries", id: false, force:
|
5
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
6
6
|
t.integer "emp_no", null: false
|
7
7
|
t.integer "salary", null: false
|
8
8
|
t.date "from_date", null: false
|
@@ -15,7 +15,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
15
15
|
|
16
16
|
let(:expected_dsl) {
|
17
17
|
<<-RUBY
|
18
|
-
create_table "salaries", id: false, force:
|
18
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
19
19
|
t.integer "emp_no", null: false
|
20
20
|
t.integer "salary", null: false
|
21
21
|
t.date "from_date", null: false
|
@@ -38,11 +38,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
38
38
|
context 'when change index (change)' do
|
39
39
|
let(:actual_dsl) {
|
40
40
|
<<-RUBY
|
41
|
-
create_table "salaries", id: false, force:
|
42
|
-
t.integer "emp_no", null: false
|
43
|
-
t.integer "salary", null: false
|
44
|
-
t.date "from_date",
|
45
|
-
t.date "to_date",
|
41
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
42
|
+
t.integer "emp_no", limit: 4, null: false
|
43
|
+
t.integer "salary", limit: 4, null: false
|
44
|
+
t.date "from_date", null: false
|
45
|
+
t.date "to_date", null: false
|
46
46
|
end
|
47
47
|
|
48
48
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
|
52
52
|
let(:dsl) {
|
53
53
|
<<-RUBY
|
54
|
-
create_table "salaries", id: false, force:
|
54
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
55
55
|
t.integer "emp_no", null: false
|
56
56
|
t.integer "salary", null: false
|
57
57
|
t.date "from_date", null: false
|
@@ -64,11 +64,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
64
64
|
|
65
65
|
let(:expected_dsl) {
|
66
66
|
<<-RUBY
|
67
|
-
create_table "salaries", id: false, force:
|
68
|
-
t.integer "emp_no", null: false
|
69
|
-
t.integer "salary", null: false
|
70
|
-
t.date "from_date",
|
71
|
-
t.date "to_date",
|
67
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
68
|
+
t.integer "emp_no", limit: 4, null: false
|
69
|
+
t.integer "salary", limit: 4, null: false
|
70
|
+
t.date "from_date", null: false
|
71
|
+
t.date "to_date", null: false
|
72
72
|
end
|
73
73
|
|
74
74
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
@@ -2,7 +2,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index without using (no change)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
<<-RUBY
|
5
|
-
create_table "salaries", id: false, force:
|
5
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
6
6
|
t.integer "emp_no", null: false
|
7
7
|
t.integer "salary", null: false
|
8
8
|
t.date "from_date", null: false
|
@@ -15,7 +15,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
15
15
|
|
16
16
|
let(:expected_dsl) {
|
17
17
|
<<-RUBY
|
18
|
-
create_table "salaries", id: false, force:
|
18
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
19
19
|
t.integer "emp_no", null: false
|
20
20
|
t.integer "salary", null: false
|
21
21
|
t.date "from_date", null: false
|
@@ -38,11 +38,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
38
38
|
context 'when change index without using (change)' do
|
39
39
|
let(:actual_dsl) {
|
40
40
|
<<-RUBY
|
41
|
-
create_table "salaries", id: false, force:
|
42
|
-
t.integer "emp_no", null: false
|
43
|
-
t.integer "salary", null: false
|
44
|
-
t.date "from_date",
|
45
|
-
t.date "to_date",
|
41
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
42
|
+
t.integer "emp_no", limit: 4, null: false
|
43
|
+
t.integer "salary", limit: 4, null: false
|
44
|
+
t.date "from_date", null: false
|
45
|
+
t.date "to_date", null: false
|
46
46
|
end
|
47
47
|
|
48
48
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
|
52
52
|
let(:dsl) {
|
53
53
|
<<-RUBY
|
54
|
-
create_table "salaries", id: false, force:
|
54
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
55
55
|
t.integer "emp_no", null: false
|
56
56
|
t.integer "salary", null: false
|
57
57
|
t.date "from_date", null: false
|
@@ -64,11 +64,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
64
64
|
|
65
65
|
let(:expected_dsl) {
|
66
66
|
<<-RUBY
|
67
|
-
create_table "salaries", id: false, force:
|
68
|
-
t.integer "emp_no", null: false
|
69
|
-
t.integer "salary", null: false
|
70
|
-
t.date "from_date",
|
71
|
-
t.date "to_date",
|
67
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
68
|
+
t.integer "emp_no", limit: 4, null: false
|
69
|
+
t.integer "salary", limit: 4, null: false
|
70
|
+
t.date "from_date", null: false
|
71
|
+
t.date "to_date", null: false
|
72
72
|
end
|
73
73
|
|
74
74
|
add_index "salaries", ["salary"], name: "index_salaries_on_salary", using: :hash
|
@@ -90,7 +90,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
context 'when change index without name (no change)' do
|
91
91
|
let(:actual_dsl) {
|
92
92
|
<<-RUBY
|
93
|
-
create_table "salaries", id: false, force:
|
93
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
94
94
|
t.integer "emp_no", null: false
|
95
95
|
t.integer "salary", null: false
|
96
96
|
t.date "from_date", null: false
|
@@ -103,7 +103,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
103
103
|
|
104
104
|
let(:expected_dsl) {
|
105
105
|
<<-RUBY
|
106
|
-
create_table "salaries", id: false, force:
|
106
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
107
107
|
t.integer "emp_no", null: false
|
108
108
|
t.integer "salary", null: false
|
109
109
|
t.date "from_date", null: false
|
@@ -126,11 +126,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
126
126
|
context 'when change index without name (change)' do
|
127
127
|
let(:actual_dsl) {
|
128
128
|
<<-RUBY
|
129
|
-
create_table "salaries", id: false, force:
|
130
|
-
t.integer "emp_no", null: false
|
131
|
-
t.integer "salary", null: false
|
132
|
-
t.date "from_date",
|
133
|
-
t.date "to_date",
|
129
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
130
|
+
t.integer "emp_no", limit: 4, null: false
|
131
|
+
t.integer "salary", limit: 4, null: false
|
132
|
+
t.date "from_date", null: false
|
133
|
+
t.date "to_date", null: false
|
134
134
|
end
|
135
135
|
|
136
136
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
@@ -139,7 +139,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
139
139
|
|
140
140
|
let(:dsl) {
|
141
141
|
<<-RUBY
|
142
|
-
create_table "salaries", id: false, force:
|
142
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
143
143
|
t.integer "emp_no", null: false
|
144
144
|
t.integer "salary", null: false
|
145
145
|
t.date "from_date", null: false
|
@@ -152,11 +152,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
152
152
|
|
153
153
|
let(:expected_dsl) {
|
154
154
|
<<-RUBY
|
155
|
-
create_table "salaries", id: false, force:
|
156
|
-
t.integer "emp_no", null: false
|
157
|
-
t.integer "salary", null: false
|
158
|
-
t.date "from_date",
|
159
|
-
t.date "to_date",
|
155
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
156
|
+
t.integer "emp_no", limit: 4, null: false
|
157
|
+
t.integer "salary", limit: 4, null: false
|
158
|
+
t.date "from_date", null: false
|
159
|
+
t.date "to_date", null: false
|
160
160
|
end
|
161
161
|
|
162
162
|
add_index "salaries", ["salary"], name: "index_salaries_on_salary", using: :btree
|