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
@@ -2,200 +2,186 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index (use t.index)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "clubs",
|
6
|
-
t.string "name",
|
5
|
+
create_table "clubs", force: :cascade do |t|
|
6
|
+
t.string "name", default: "", null: false
|
7
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
10
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
12
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
16
|
-
|
17
15
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no",
|
19
|
-
t.string "dept_no",
|
20
|
-
t.date "from_date",
|
21
|
-
t.date "to_date",
|
16
|
+
t.integer "emp_no", null: false
|
17
|
+
t.string "dept_no", null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
26
|
-
|
27
24
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
|
-
t.string "dept_no",
|
29
|
-
t.integer "emp_no",
|
30
|
-
t.date "from_date",
|
31
|
-
t.date "to_date",
|
25
|
+
t.string "dept_no", null: false
|
26
|
+
t.integer "emp_no", null: false
|
27
|
+
t.date "from_date", null: false
|
28
|
+
t.date "to_date", null: false
|
29
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
39
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
33
|
+
create_table "employee_clubs", force: :cascade do |t|
|
34
|
+
t.integer "emp_no", null: false
|
35
|
+
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
45
|
-
t.date "birth_date", null: false
|
39
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
40
|
+
t.date "birth_date", null: false
|
46
41
|
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name",
|
48
|
-
t.string "gender",
|
49
|
-
t.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.string "gender", limit: 1, null: false
|
44
|
+
t.date "hire_date", null: false
|
50
45
|
end
|
51
46
|
|
52
47
|
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
-
t.integer "emp_no",
|
54
|
-
t.integer "salary",
|
55
|
-
t.date "from_date",
|
56
|
-
t.date "to_date",
|
48
|
+
t.integer "emp_no", null: false
|
49
|
+
t.integer "salary", null: false
|
50
|
+
t.date "from_date", null: false
|
51
|
+
t.date "to_date", null: false
|
52
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
57
53
|
end
|
58
54
|
|
59
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
60
|
-
|
61
55
|
create_table "titles", id: false, force: :cascade do |t|
|
62
|
-
t.integer "emp_no",
|
63
|
-
t.string "title",
|
64
|
-
t.date "from_date",
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.string "title", limit: 50, null: false
|
58
|
+
t.date "from_date", null: false
|
65
59
|
t.date "to_date"
|
60
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
66
61
|
end
|
67
|
-
|
68
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
69
62
|
EOS
|
70
63
|
}
|
71
64
|
|
72
65
|
let(:expected_dsl) {
|
73
66
|
erbh(<<-EOS)
|
74
|
-
create_table "clubs",
|
75
|
-
t.string "name",
|
67
|
+
create_table "clubs", force: :cascade do |t|
|
68
|
+
t.string "name", default: "", null: false
|
69
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
76
70
|
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
72
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
81
73
|
t.string "dept_name", limit: 40, null: false
|
74
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
82
75
|
end
|
83
76
|
|
84
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
85
|
-
|
86
77
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
-
t.integer "emp_no",
|
88
|
-
t.string "dept_no",
|
89
|
-
t.date "from_date",
|
90
|
-
t.date "to_date",
|
78
|
+
t.integer "emp_no", null: false
|
79
|
+
t.string "dept_no", null: false
|
80
|
+
t.date "from_date", null: false
|
81
|
+
t.date "to_date", null: false
|
82
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
83
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
91
84
|
end
|
92
85
|
|
93
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
94
|
-
<%= add_index "dept_emp", ["from_date"], name: "emp_no", using: :btree %>
|
95
|
-
|
96
86
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
|
-
t.string "dept_no",
|
98
|
-
t.integer "emp_no",
|
99
|
-
t.date "from_date",
|
100
|
-
t.date "to_date",
|
87
|
+
t.string "dept_no", null: false
|
88
|
+
t.integer "emp_no", null: false
|
89
|
+
t.date "from_date", null: false
|
90
|
+
t.date "to_date", null: false
|
91
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
92
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
101
93
|
end
|
102
94
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
108
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
95
|
+
create_table "employee_clubs", force: :cascade do |t|
|
96
|
+
t.integer "emp_no", null: false
|
97
|
+
t.integer "club_id", null: false
|
98
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
109
99
|
end
|
110
100
|
|
111
|
-
|
112
|
-
|
113
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
114
|
-
t.date "birth_date", null: false
|
101
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
102
|
+
t.date "birth_date", null: false
|
115
103
|
t.string "first_name", limit: 14, null: false
|
116
|
-
t.string "last_name",
|
117
|
-
t.string "gender",
|
118
|
-
t.date "hire_date",
|
104
|
+
t.string "last_name", limit: 16, null: false
|
105
|
+
t.string "gender", limit: 1, null: false
|
106
|
+
t.date "hire_date", null: false
|
119
107
|
end
|
120
108
|
|
121
109
|
create_table "salaries", id: false, force: :cascade do |t|
|
122
|
-
t.integer "emp_no",
|
123
|
-
t.integer "salary",
|
124
|
-
t.date "from_date",
|
125
|
-
t.date "to_date",
|
110
|
+
t.integer "emp_no", null: false
|
111
|
+
t.integer "salary", null: false
|
112
|
+
t.date "from_date", null: false
|
113
|
+
t.date "to_date", null: false
|
114
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
126
115
|
end
|
127
116
|
|
128
|
-
<%= add_index "salaries", ["from_date"], name: "emp_no", using: :btree %>
|
129
|
-
|
130
117
|
create_table "titles", id: false, force: :cascade do |t|
|
131
|
-
t.integer "emp_no",
|
132
|
-
t.string "title",
|
133
|
-
t.date "from_date",
|
118
|
+
t.integer "emp_no", null: false
|
119
|
+
t.string "title", limit: 50, null: false
|
120
|
+
t.date "from_date", null: false
|
134
121
|
t.date "to_date"
|
122
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
135
123
|
end
|
136
|
-
|
137
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
138
124
|
EOS
|
139
125
|
}
|
140
126
|
|
141
127
|
let(:expected_dsl_using_t_index) {
|
142
128
|
erbh(<<-EOS)
|
143
|
-
create_table "clubs",
|
144
|
-
t.string "name",
|
145
|
-
t.index "name", name: "idx_name", unique: true, using: :btree
|
129
|
+
create_table "clubs", force: :cascade do |t|
|
130
|
+
t.string "name", default: "", null: false
|
131
|
+
t.index "name", name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
146
132
|
end
|
147
133
|
|
148
|
-
create_table "departments", primary_key: "dept_no",
|
134
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
149
135
|
t.string "dept_name", limit: 40, null: false
|
150
|
-
t.index ["dept_name"], name: "dept_name", unique: true, using: :btree
|
136
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
151
137
|
end
|
152
138
|
|
153
139
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
154
|
-
t.integer "emp_no",
|
155
|
-
t.string "dept_no",
|
156
|
-
t.date "from_date",
|
157
|
-
t.date "to_date",
|
158
|
-
t.index "dept_no", name: "dept_no", using: :btree
|
159
|
-
t.index ["from_date"], name: "emp_no", using: :btree
|
140
|
+
t.integer "emp_no", null: false
|
141
|
+
t.string "dept_no", null: false
|
142
|
+
t.date "from_date", null: false
|
143
|
+
t.date "to_date", null: false
|
144
|
+
t.index "dept_no", name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
145
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
160
146
|
end
|
161
147
|
|
162
148
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
163
|
-
t.string "dept_no",
|
164
|
-
t.integer "emp_no",
|
165
|
-
t.date "from_date",
|
166
|
-
t.date "to_date",
|
167
|
-
t.index "dept_no", name: "dept_no", using: :btree
|
168
|
-
t.index ["from_date"], name: "emp_no", using: :btree
|
149
|
+
t.string "dept_no", null: false
|
150
|
+
t.integer "emp_no", null: false
|
151
|
+
t.date "from_date", null: false
|
152
|
+
t.date "to_date", null: false
|
153
|
+
t.index "dept_no", name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
154
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
169
155
|
end
|
170
156
|
|
171
|
-
create_table "employee_clubs",
|
172
|
-
t.integer "emp_no",
|
173
|
-
t.integer "club_id",
|
174
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
157
|
+
create_table "employee_clubs", force: :cascade do |t|
|
158
|
+
t.integer "emp_no", null: false
|
159
|
+
t.integer "club_id", null: false
|
160
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
175
161
|
end
|
176
162
|
|
177
|
-
create_table "employees", primary_key: "emp_no",
|
178
|
-
t.date "birth_date",
|
163
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
164
|
+
t.date "birth_date", null: false
|
179
165
|
t.string "first_name", limit: 14, null: false
|
180
|
-
t.string "last_name",
|
181
|
-
t.string "gender",
|
182
|
-
t.date "hire_date",
|
166
|
+
t.string "last_name", limit: 16, null: false
|
167
|
+
t.string "gender", limit: 1, null: false
|
168
|
+
t.date "hire_date", null: false
|
183
169
|
end
|
184
170
|
|
185
171
|
create_table "salaries", id: false, force: :cascade do |t|
|
186
|
-
t.integer "emp_no",
|
187
|
-
t.integer "salary",
|
188
|
-
t.date "from_date",
|
189
|
-
t.date "to_date",
|
190
|
-
t.index "from_date", name: "emp_no", using: :btree
|
172
|
+
t.integer "emp_no", null: false
|
173
|
+
t.integer "salary", null: false
|
174
|
+
t.date "from_date", null: false
|
175
|
+
t.date "to_date", null: false
|
176
|
+
t.index "from_date", name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
191
177
|
end
|
192
178
|
|
193
179
|
create_table "titles", id: false, force: :cascade do |t|
|
194
|
-
t.integer "emp_no",
|
195
|
-
t.string "title",
|
196
|
-
t.date "from_date",
|
180
|
+
t.integer "emp_no", null: false
|
181
|
+
t.string "title", limit: 50, null: false
|
182
|
+
t.date "from_date", null: false
|
197
183
|
t.date "to_date"
|
198
|
-
t.index ["emp_no"], name: "emp_no", using: :btree
|
184
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
199
185
|
end
|
200
186
|
EOS
|
201
187
|
}
|
@@ -2,29 +2,27 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change index (length is Numeric) / No update' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "employees", primary_key: "emp_no",
|
6
|
-
t.date "birth_date",
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
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
|
+
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: { first_name: 10, last_name: 10 }, <%= i cond(5.0, using: :btree) %>
|
11
12
|
end
|
12
|
-
|
13
|
-
<%= add_index "employees", ["first_name", "last_name"], name: "idx_first_name_last_name", length: {"first_name"=>10, "last_name"=>10}, using: :btree %>
|
14
13
|
EOS
|
15
14
|
}
|
16
15
|
|
17
16
|
let(:expected_dsl) {
|
18
17
|
erbh(<<-EOS)
|
19
|
-
create_table "employees", primary_key: "emp_no",
|
20
|
-
t.date "birth_date",
|
18
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
19
|
+
t.date "birth_date", null: false
|
21
20
|
t.string "first_name", limit: 14, null: false
|
22
|
-
t.string "last_name",
|
23
|
-
t.string "gender",
|
24
|
-
t.date "hire_date",
|
21
|
+
t.string "last_name", limit: 16, null: false
|
22
|
+
t.string "gender", limit: 1, null: false
|
23
|
+
t.date "hire_date", null: false
|
24
|
+
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: 10, <%= i cond(5.0, using: :btree) %>
|
25
25
|
end
|
26
|
-
|
27
|
-
<%= add_index "employees", ["first_name", "last_name"], name: "idx_first_name_last_name", length: 10, using: :btree %>
|
28
26
|
EOS
|
29
27
|
}
|
30
28
|
|
@@ -40,35 +38,34 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
40
38
|
|
41
39
|
context 'when change index (length is Numeric) / Update' do
|
42
40
|
let(:actual_dsl) {
|
43
|
-
|
44
|
-
create_table "employees", primary_key: "emp_no",
|
45
|
-
t.date "birth_date",
|
41
|
+
<<-EOS
|
42
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
43
|
+
t.date "birth_date", null: false
|
46
44
|
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name",
|
48
|
-
t.string "gender",
|
49
|
-
t.date "hire_date",
|
45
|
+
t.string "last_name", limit: 16, null: false
|
46
|
+
t.string "gender", limit: 1, null: false
|
47
|
+
t.date "hire_date", null: false
|
50
48
|
end
|
51
49
|
EOS
|
52
50
|
}
|
53
51
|
|
54
52
|
let(:expected_dsl) {
|
55
53
|
erbh(<<-EOS)
|
56
|
-
create_table "employees", primary_key: "emp_no",
|
57
|
-
t.date "birth_date",
|
54
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
55
|
+
t.date "birth_date", null: false
|
58
56
|
t.string "first_name", limit: 14, null: false
|
59
|
-
t.string "last_name",
|
60
|
-
t.string "gender",
|
61
|
-
t.date "hire_date",
|
57
|
+
t.string "last_name", limit: 16, null: false
|
58
|
+
t.string "gender", limit: 1, null: false
|
59
|
+
t.date "hire_date", null: false
|
60
|
+
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: 10, <%= i cond(5.0, using: :btree) %>
|
62
61
|
end
|
63
|
-
|
64
|
-
<%= add_index "employees", ["first_name", "last_name"], name: "idx_first_name_last_name", length: 10, using: :btree %>
|
65
62
|
EOS
|
66
63
|
}
|
67
64
|
|
68
65
|
let(:actual_dsl_plus_index) {
|
69
|
-
erbh(<<-EOS)
|
70
|
-
|
71
|
-
|
66
|
+
actual_dsl.sub(/\bend\b/, erbh(<<-EOS))
|
67
|
+
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: { first_name: 10, last_name: 10 }, <%= i cond(5.0, using: :btree) %>
|
68
|
+
end
|
72
69
|
EOS
|
73
70
|
}
|
74
71
|
|
@@ -4,206 +4,185 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
6
|
t.string "name", default: "", null: false
|
7
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
7
8
|
end
|
8
9
|
|
9
|
-
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
10
|
-
|
11
10
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
12
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
16
|
-
|
17
15
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no",
|
19
|
-
t.string "dept_no",
|
20
|
-
t.date "from_date",
|
21
|
-
t.date "to_date",
|
16
|
+
t.integer "emp_no", null: false
|
17
|
+
t.string "dept_no", null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
26
|
-
|
27
24
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
|
-
t.string "dept_no",
|
29
|
-
t.integer "emp_no",
|
30
|
-
t.date "from_date",
|
31
|
-
t.date "to_date",
|
25
|
+
t.string "dept_no", null: false
|
26
|
+
t.integer "emp_no", null: false
|
27
|
+
t.date "from_date", null: false
|
28
|
+
t.date "to_date", null: false
|
29
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
35
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
36
|
-
|
37
33
|
create_table "employee_clubs", force: :cascade do |t|
|
38
|
-
t.integer "emp_no",
|
39
|
-
t.integer "club_id",
|
34
|
+
t.integer "emp_no", null: false
|
35
|
+
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
40
37
|
end
|
41
38
|
|
42
|
-
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
43
|
-
|
44
39
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
45
|
-
t.date "birth_date",
|
40
|
+
t.date "birth_date", null: false
|
46
41
|
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name",
|
48
|
-
t.string "gender",
|
49
|
-
t.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.string "gender", limit: 1, null: false
|
44
|
+
t.date "hire_date", null: false
|
50
45
|
end
|
51
46
|
|
52
47
|
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
-
t.integer "emp_no",
|
54
|
-
t.integer "salary",
|
48
|
+
t.integer "emp_no", null: false
|
49
|
+
t.integer "salary", null: false
|
55
50
|
t.date "from_date", null: false
|
56
|
-
t.date "to_date",
|
51
|
+
t.date "to_date", null: false
|
52
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
57
53
|
end
|
58
54
|
|
59
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
60
|
-
|
61
55
|
create_table "titles", id: false, force: :cascade do |t|
|
62
|
-
t.integer "emp_no",
|
63
|
-
t.string "title",
|
64
|
-
t.date "from_date",
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.string "title", limit: 50, null: false
|
58
|
+
t.date "from_date", null: false
|
65
59
|
t.date "to_date"
|
60
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
66
61
|
end
|
67
|
-
|
68
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
69
62
|
EOS
|
70
63
|
}
|
71
64
|
|
72
65
|
let(:actual_dsl) {
|
73
66
|
erbh(<<-EOS)
|
74
|
-
create_table "clubs",
|
75
|
-
t.string "name",
|
67
|
+
create_table "clubs", force: :cascade do |t|
|
68
|
+
t.string "name", default: "", null: false
|
69
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
76
70
|
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
72
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
81
73
|
t.string "dept_name", limit: 40, null: false
|
74
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
82
75
|
end
|
83
76
|
|
84
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
85
|
-
|
86
77
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
-
t.integer "emp_no",
|
88
|
-
t.string "dept_no",
|
89
|
-
t.date "from_date",
|
90
|
-
t.date "to_date",
|
78
|
+
t.integer "emp_no", null: false
|
79
|
+
t.string "dept_no", null: false
|
80
|
+
t.date "from_date", null: false
|
81
|
+
t.date "to_date", null: false
|
82
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
83
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
91
84
|
end
|
92
85
|
|
93
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
94
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
95
|
-
|
96
86
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
|
-
t.string "dept_no",
|
98
|
-
t.integer "emp_no",
|
99
|
-
t.date "from_date",
|
100
|
-
t.date "to_date",
|
87
|
+
t.string "dept_no", null: false
|
88
|
+
t.integer "emp_no", null: false
|
89
|
+
t.date "from_date", null: false
|
90
|
+
t.date "to_date", null: false
|
91
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
92
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
101
93
|
end
|
102
94
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
108
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
95
|
+
create_table "employee_clubs", force: :cascade do |t|
|
96
|
+
t.integer "emp_no", null: false
|
97
|
+
t.integer "club_id", null: false
|
98
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
109
99
|
end
|
110
100
|
|
111
|
-
|
112
|
-
|
113
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
114
|
-
t.date "birth_date", null: false
|
101
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
102
|
+
t.date "birth_date", null: false
|
115
103
|
t.string "first_name", limit: 14, null: false
|
116
|
-
t.string "last_name",
|
117
|
-
t.string "gender",
|
118
|
-
t.date "hire_date",
|
104
|
+
t.string "last_name", limit: 16, null: false
|
105
|
+
t.string "gender", limit: 1, null: false
|
106
|
+
t.date "hire_date", null: false
|
119
107
|
end
|
120
108
|
|
121
109
|
create_table "salaries", id: false, force: :cascade do |t|
|
122
|
-
t.integer "emp_no",
|
123
|
-
t.integer "salary",
|
124
|
-
t.date "from_date",
|
125
|
-
t.date "to_date",
|
110
|
+
t.integer "emp_no", null: false
|
111
|
+
t.integer "salary", null: false
|
112
|
+
t.date "from_date", null: false
|
113
|
+
t.date "to_date", null: false
|
114
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
126
115
|
end
|
127
116
|
|
128
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
129
|
-
|
130
117
|
create_table "titles", id: false, force: :cascade do |t|
|
131
|
-
t.integer "emp_no",
|
132
|
-
t.string "title",
|
133
|
-
t.date "from_date",
|
118
|
+
t.integer "emp_no", null: false
|
119
|
+
t.string "title", limit: 50, null: false
|
120
|
+
t.date "from_date", null: false
|
134
121
|
t.date "to_date"
|
122
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
135
123
|
end
|
136
|
-
|
137
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
138
124
|
EOS
|
139
125
|
}
|
140
126
|
|
141
127
|
let(:expected_dsl) {
|
142
128
|
erbh(<<-EOS)
|
143
|
-
create_table "clubs",
|
144
|
-
t.string "name",
|
129
|
+
create_table "clubs", force: :cascade do |t|
|
130
|
+
t.string "name", default: "", null: false
|
131
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
145
132
|
end
|
146
133
|
|
147
|
-
|
148
|
-
|
149
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
134
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
150
135
|
t.string "dept_name", limit: 40, null: false
|
136
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
151
137
|
end
|
152
138
|
|
153
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
154
|
-
|
155
139
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
156
|
-
t.integer "emp_no",
|
157
|
-
t.string "dept_no",
|
158
|
-
t.date "from_date",
|
159
|
-
t.date "to_date",
|
140
|
+
t.integer "emp_no", null: false
|
141
|
+
t.string "dept_no", null: false
|
142
|
+
t.date "from_date", null: false
|
143
|
+
t.date "to_date", null: false
|
144
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
145
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
160
146
|
end
|
161
147
|
|
162
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
163
|
-
<%= add_index "dept_emp", ["from_date"], name: "emp_no", using: :btree %>
|
164
|
-
|
165
148
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
166
|
-
t.string "dept_no",
|
167
|
-
t.integer "emp_no",
|
168
|
-
t.date "from_date",
|
169
|
-
t.date "to_date",
|
149
|
+
t.string "dept_no", null: false
|
150
|
+
t.integer "emp_no", null: false
|
151
|
+
t.date "from_date", null: false
|
152
|
+
t.date "to_date", null: false
|
153
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
154
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
170
155
|
end
|
171
156
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
177
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
157
|
+
create_table "employee_clubs", force: :cascade do |t|
|
158
|
+
t.integer "emp_no", null: false
|
159
|
+
t.integer "club_id", null: false
|
160
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
178
161
|
end
|
179
162
|
|
180
|
-
|
181
|
-
|
182
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
183
|
-
t.date "birth_date", null: false
|
163
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
164
|
+
t.date "birth_date", null: false
|
184
165
|
t.string "first_name", limit: 14, null: false
|
185
|
-
t.string "last_name",
|
186
|
-
t.string "gender",
|
187
|
-
t.date "hire_date",
|
166
|
+
t.string "last_name", limit: 16, null: false
|
167
|
+
t.string "gender", limit: 1, null: false
|
168
|
+
t.date "hire_date", null: false
|
188
169
|
end
|
189
170
|
|
190
171
|
create_table "salaries", id: false, force: :cascade do |t|
|
191
|
-
t.integer "emp_no",
|
192
|
-
t.integer "salary",
|
193
|
-
t.date "from_date",
|
194
|
-
t.date "to_date",
|
172
|
+
t.integer "emp_no", null: false
|
173
|
+
t.integer "salary", null: false
|
174
|
+
t.date "from_date", null: false
|
175
|
+
t.date "to_date", null: false
|
176
|
+
t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
195
177
|
end
|
196
178
|
|
197
|
-
<%= add_index "salaries", ["from_date"], name: "emp_no", using: :btree %>
|
198
|
-
|
199
179
|
create_table "titles", id: false, force: :cascade do |t|
|
200
|
-
t.integer "emp_no",
|
201
|
-
t.string "title",
|
202
|
-
t.date "from_date",
|
180
|
+
t.integer "emp_no", null: false
|
181
|
+
t.string "title", limit: 50, null: false
|
182
|
+
t.date "from_date", null: false
|
203
183
|
t.date "to_date"
|
184
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
204
185
|
end
|
205
|
-
|
206
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
207
186
|
EOS
|
208
187
|
}
|
209
188
|
|