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
@@ -4,67 +4,60 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
6
|
t.string "name", limit: 255, 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: "idx_dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "idx_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", limit: 4, null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "idx_dept_emp_dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "idx_dept_emp_emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_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", limit: 4, 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: "idx_dept_manager_dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "idx_dept_manager_emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
<%= add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree %>
|
35
|
-
<%= add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree %>
|
36
|
-
|
37
33
|
create_table "employee_clubs", force: :cascade do |t|
|
38
|
-
t.integer "emp_no",
|
34
|
+
t.integer "emp_no", null: false
|
39
35
|
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_employee_clubs_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_employee_clubs_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.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.date "hire_date", null: false
|
49
44
|
end
|
50
45
|
|
51
46
|
create_table "salaries", id: false, force: :cascade do |t|
|
52
|
-
t.integer "emp_no",
|
53
|
-
t.integer "salary",
|
47
|
+
t.integer "emp_no", null: false
|
48
|
+
t.integer "salary", null: false
|
54
49
|
t.date "from_date", null: false
|
55
|
-
t.date "to_date",
|
50
|
+
t.date "to_date", null: false
|
51
|
+
t.index ["emp_no"], name: "idx_salaries_emp_no", <%= i cond(5.0, using: :btree) %>
|
56
52
|
end
|
57
53
|
|
58
|
-
<%= add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree %>
|
59
|
-
|
60
54
|
create_table "titles", id: false, force: :cascade do |t|
|
61
|
-
t.integer "emp_no",
|
62
|
-
t.string "title",
|
63
|
-
t.date "from_date",
|
55
|
+
t.integer "emp_no", null: false
|
56
|
+
t.string "title", limit: 50, null: false
|
57
|
+
t.date "from_date", null: false
|
64
58
|
t.date "to_date"
|
59
|
+
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
65
60
|
end
|
66
|
-
|
67
|
-
<%= add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree %>
|
68
61
|
EOS
|
69
62
|
}
|
70
63
|
|
@@ -72,67 +65,60 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
72
65
|
erbh(<<-EOS)
|
73
66
|
create_table "clubs", force: :cascade do |t|
|
74
67
|
t.string "name", limit: 255, default: "", null: false
|
68
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
75
69
|
end
|
76
70
|
|
77
|
-
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
78
|
-
|
79
71
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
80
72
|
t.string "dept_name", limit: 40, null: false
|
73
|
+
t.index ["dept_name"], name: "idx_dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
81
74
|
end
|
82
75
|
|
83
|
-
<%= add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree %>
|
84
|
-
|
85
76
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
86
|
-
t.integer "emp_no",
|
87
|
-
t.string "dept_no",
|
88
|
-
t.date "from_date",
|
89
|
-
t.date "to_date",
|
77
|
+
t.integer "emp_no", null: false
|
78
|
+
t.string "dept_no", limit: 4, null: false
|
79
|
+
t.date "from_date", null: false
|
80
|
+
t.date "to_date", null: false
|
81
|
+
t.index ["dept_no"], name: "idx_dept_emp_dept_no", <%= i cond(5.0, using: :btree) %>
|
82
|
+
t.index ["emp_no"], name: "idx_dept_emp_emp_no", <%= i cond(5.0, using: :btree) %>
|
90
83
|
end
|
91
84
|
|
92
|
-
<%= add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree %>
|
93
|
-
<%= add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree %>
|
94
|
-
|
95
85
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
96
|
-
t.string "dept_no",
|
97
|
-
t.integer "emp_no",
|
98
|
-
t.date "from_date",
|
99
|
-
t.date "to_date",
|
86
|
+
t.string "dept_no", limit: 4, null: false
|
87
|
+
t.integer "emp_no", null: false
|
88
|
+
t.date "from_date", null: false
|
89
|
+
t.date "to_date", null: false
|
90
|
+
t.index ["dept_no"], name: "idx_dept_manager_dept_no", <%= i cond(5.0, using: :btree) %>
|
91
|
+
t.index ["emp_no"], name: "idx_dept_manager_emp_no", <%= i cond(5.0, using: :btree) %>
|
100
92
|
end
|
101
93
|
|
102
|
-
<%= add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree %>
|
103
|
-
<%= add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree %>
|
104
|
-
|
105
94
|
create_table "employee_clubs", force: :cascade do |t|
|
106
|
-
t.integer "emp_no",
|
95
|
+
t.integer "emp_no", null: false
|
107
96
|
t.integer "club_id", null: false
|
97
|
+
t.index ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
108
98
|
end
|
109
99
|
|
110
|
-
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_employee_clubs_emp_no_club_id", using: :btree %>
|
111
|
-
|
112
100
|
create_table "employees2", primary_key: "emp_no", force: :cascade, renamed_from: 'employees' do |t|
|
113
|
-
t.date "birth_date",
|
101
|
+
t.date "birth_date", null: false
|
114
102
|
t.string "first_name", limit: 14, null: false
|
115
|
-
t.string "last_name",
|
116
|
-
t.date "hire_date",
|
103
|
+
t.string "last_name", limit: 16, null: false
|
104
|
+
t.date "hire_date", null: false
|
117
105
|
end
|
118
106
|
|
119
107
|
create_table "salaries", id: false, force: :cascade do |t|
|
120
|
-
t.integer "emp_no",
|
121
|
-
t.integer "salary",
|
108
|
+
t.integer "emp_no", null: false
|
109
|
+
t.integer "salary", null: false
|
122
110
|
t.date "from_date", null: false
|
123
|
-
t.date "to_date",
|
111
|
+
t.date "to_date", null: false
|
112
|
+
t.index ["emp_no"], name: "idx_salaries_emp_no", <%= i cond(5.0, using: :btree) %>
|
124
113
|
end
|
125
114
|
|
126
|
-
<%= add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree %>
|
127
|
-
|
128
115
|
create_table "titles", id: false, force: :cascade do |t|
|
129
|
-
t.integer "emp_no",
|
130
|
-
t.string "title",
|
131
|
-
t.date "from_date",
|
116
|
+
t.integer "emp_no", null: false
|
117
|
+
t.string "title", limit: 50, null: false
|
118
|
+
t.date "from_date", null: false
|
132
119
|
t.date "to_date"
|
120
|
+
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
133
121
|
end
|
134
|
-
|
135
|
-
<%= add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree %>
|
136
122
|
EOS
|
137
123
|
}
|
138
124
|
|
@@ -160,26 +146,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
160
146
|
let(:actual_dsl) {
|
161
147
|
erbh(<<-EOS)
|
162
148
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
163
|
-
t.date "birth_date",
|
149
|
+
t.date "birth_date", null: false
|
164
150
|
t.string "first_name", limit: 14, null: false
|
165
|
-
t.string "last_name",
|
166
|
-
t.date "hire_date",
|
151
|
+
t.string "last_name", limit: 16, null: false
|
152
|
+
t.date "hire_date", null: false
|
153
|
+
t.index ["first_name"], name: "first_name", <%= i cond(5.0, using: :btree) %>
|
167
154
|
end
|
168
|
-
|
169
|
-
<%= add_index "employees", ["first_name"], name: "first_name", using: :btree %>
|
170
155
|
EOS
|
171
156
|
}
|
172
157
|
|
173
158
|
let(:expected_dsl) {
|
174
159
|
erbh(<<-EOS)
|
175
160
|
create_table "employees2", primary_key: "emp_no", force: :cascade, renamed_from: 'employees' do |t|
|
176
|
-
t.date "birth_date",
|
161
|
+
t.date "birth_date", null: false
|
177
162
|
t.string "first_name", limit: 14, null: false
|
178
|
-
t.string "last_name",
|
179
|
-
t.date "hire_date",
|
163
|
+
t.string "last_name", limit: 16, null: false
|
164
|
+
t.date "hire_date", null: false
|
165
|
+
t.index ["first_name"], name: "first_name", <%= i cond(5.0, using: :btree) %>
|
180
166
|
end
|
181
|
-
|
182
|
-
<%= add_index "employees2", ["first_name"], name: "first_name", using: :btree %>
|
183
167
|
EOS
|
184
168
|
}
|
185
169
|
|
@@ -4,67 +4,60 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "clubs", <%= i cond(5.1, id: :serial) + {force: :cascade} %> do |t|
|
6
6
|
t.string "name", limit: 255, 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", id: :string, limit: 4, force: :cascade do |t|
|
12
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "idx_dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "idx_dept_name", unique: true, using: :btree %>
|
16
|
-
|
17
15
|
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], 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", limit: 4, null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "idx_dept_emp_dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "idx_dept_emp_emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "idx_dept_emp_dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "idx_dept_emp_emp_no", using: :btree %>
|
26
|
-
|
27
24
|
create_table "dept_manager", primary_key: ["emp_no", "dept_no"], 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", limit: 4, 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: "idx_dept_manager_dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "idx_dept_manager_emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
<%= add_index "dept_manager", ["dept_no"], name: "idx_dept_manager_dept_no", using: :btree %>
|
35
|
-
<%= add_index "dept_manager", ["emp_no"], name: "idx_dept_manager_emp_no", using: :btree %>
|
36
|
-
|
37
33
|
create_table "employee_clubs", <%= i cond(5.1, id: :serial) + {force: :cascade} %> do |t|
|
38
|
-
t.integer "emp_no",
|
34
|
+
t.integer "emp_no", null: false
|
39
35
|
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_employee_clubs_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_employee_clubs_emp_no_club_id", using: :btree %>
|
43
|
-
|
44
39
|
create_table "employees", primary_key: "emp_no", <%= i({id: :integer} + cond(5.1, default: nil) + {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.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.date "hire_date", null: false
|
49
44
|
end
|
50
45
|
|
51
46
|
create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
|
52
|
-
t.integer "emp_no",
|
53
|
-
t.integer "salary",
|
47
|
+
t.integer "emp_no", null: false
|
48
|
+
t.integer "salary", null: false
|
54
49
|
t.date "from_date", null: false
|
55
|
-
t.date "to_date",
|
50
|
+
t.date "to_date", null: false
|
51
|
+
t.index ["emp_no"], name: "idx_salaries_emp_no", <%= i cond(5.0, using: :btree) %>
|
56
52
|
end
|
57
53
|
|
58
|
-
<%= add_index "salaries", ["emp_no"], name: "idx_salaries_emp_no", using: :btree %>
|
59
|
-
|
60
54
|
create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
|
61
|
-
t.integer "emp_no",
|
62
|
-
t.string "title",
|
63
|
-
t.date "from_date",
|
55
|
+
t.integer "emp_no", null: false
|
56
|
+
t.string "title", limit: 50, null: false
|
57
|
+
t.date "from_date", null: false
|
64
58
|
t.date "to_date"
|
59
|
+
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
65
60
|
end
|
66
|
-
|
67
|
-
<%= add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree %>
|
68
61
|
EOS
|
69
62
|
}
|
70
63
|
|
@@ -2,46 +2,43 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change fk' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "parent", force: :cascade do |t|
|
6
|
-
end
|
7
|
-
|
8
|
-
create_table "child", force: :cascade do |t|
|
9
|
-
t.integer "parent_id"
|
10
|
-
end
|
5
|
+
create_table "parent", force: :cascade do |t|
|
6
|
+
end
|
11
7
|
|
12
|
-
|
8
|
+
create_table "child", force: :cascade do |t|
|
9
|
+
t.integer "parent_id"
|
10
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
11
|
+
end
|
13
12
|
|
14
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
13
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
15
14
|
EOS
|
16
15
|
}
|
17
16
|
|
18
17
|
let(:sorted_actual_dsl) {
|
19
18
|
erbh(<<-EOS)
|
20
|
-
create_table "child", force: :cascade do |t|
|
21
|
-
|
22
|
-
|
19
|
+
create_table "child", force: :cascade do |t|
|
20
|
+
t.integer "parent_id"
|
21
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
22
|
+
end
|
23
23
|
|
24
|
-
|
24
|
+
create_table "parent", force: :cascade do |t|
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
27
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
30
28
|
EOS
|
31
29
|
}
|
32
30
|
|
33
31
|
let(:expected_dsl) {
|
34
32
|
erbh(<<-EOS)
|
35
|
-
create_table "child", force: :cascade do |t|
|
36
|
-
|
37
|
-
|
33
|
+
create_table "child", force: :cascade do |t|
|
34
|
+
t.integer "parent_id"
|
35
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
create_table "parent", force: :cascade do |t|
|
42
|
-
end
|
38
|
+
create_table "parent", force: :cascade do |t|
|
39
|
+
end
|
43
40
|
|
44
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
41
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
45
42
|
EOS
|
46
43
|
}
|
47
44
|
|
@@ -2,21 +2,19 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when create fk' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "child", force: :cascade do |t|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
|
5
|
+
create_table "child", force: :cascade do |t|
|
6
|
+
t.integer "parent_id"
|
7
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
8
|
+
end
|
10
9
|
|
11
|
-
create_table "parent", force: :cascade do |t|
|
12
|
-
end
|
10
|
+
create_table "parent", force: :cascade do |t|
|
11
|
+
end
|
13
12
|
EOS
|
14
13
|
}
|
15
14
|
|
16
15
|
let(:expected_dsl) {
|
17
16
|
actual_dsl + (<<-EOS)
|
18
|
-
|
19
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
17
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
20
18
|
EOS
|
21
19
|
}
|
22
20
|
|
@@ -54,32 +52,30 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
|
54
52
|
context 'when create fk when create table' do
|
55
53
|
let(:dsl) {
|
56
54
|
erbh(<<-EOS)
|
57
|
-
# Define parent before child
|
58
|
-
create_table "parent", force: :cascade do |t|
|
59
|
-
end
|
60
|
-
|
61
|
-
create_table "child", force: :cascade do |t|
|
62
|
-
t.integer "parent_id", unsigned: true
|
63
|
-
end
|
55
|
+
# Define parent before child
|
56
|
+
create_table "parent", force: :cascade do |t|
|
57
|
+
end
|
64
58
|
|
65
|
-
|
59
|
+
create_table "child", force: :cascade do |t|
|
60
|
+
t.integer "parent_id", unsigned: true
|
61
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
62
|
+
end
|
66
63
|
|
67
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
64
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
68
65
|
EOS
|
69
66
|
}
|
70
67
|
|
71
68
|
let(:sorted_dsl) {
|
72
69
|
erbh(<<-EOS)
|
73
|
-
create_table "child", force: :cascade do |t|
|
74
|
-
|
75
|
-
|
70
|
+
create_table "child", force: :cascade do |t|
|
71
|
+
t.integer "parent_id"
|
72
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
73
|
+
end
|
76
74
|
|
77
|
-
|
75
|
+
create_table "parent", force: :cascade do |t|
|
76
|
+
end
|
78
77
|
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
78
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
83
79
|
EOS
|
84
80
|
}
|
85
81
|
|
@@ -98,19 +94,18 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
|
98
94
|
context 'already defined' do
|
99
95
|
let(:dsl) {
|
100
96
|
erbh(<<-EOS)
|
101
|
-
# Define parent before child
|
102
|
-
create_table "parent", force: :cascade do |t|
|
103
|
-
end
|
104
|
-
|
105
|
-
create_table "child", force: :cascade do |t|
|
106
|
-
t.integer "parent_id", unsigned: true
|
107
|
-
end
|
97
|
+
# Define parent before child
|
98
|
+
create_table "parent", force: :cascade do |t|
|
99
|
+
end
|
108
100
|
|
109
|
-
|
101
|
+
create_table "child", force: :cascade do |t|
|
102
|
+
t.integer "parent_id", unsigned: true
|
103
|
+
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
104
|
+
end
|
110
105
|
|
111
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
106
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
112
107
|
|
113
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
108
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
114
109
|
EOS
|
115
110
|
}
|
116
111
|
|
@@ -123,40 +118,14 @@ add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
|
123
118
|
}
|
124
119
|
end
|
125
120
|
|
126
|
-
context 'no name' do
|
127
|
-
let(:dsl) {
|
128
|
-
erbh(<<-EOS)
|
129
|
-
# Define parent before child
|
130
|
-
create_table "parent", force: :cascade do |t|
|
131
|
-
end
|
132
|
-
|
133
|
-
create_table "child", force: :cascade do |t|
|
134
|
-
t.integer "parent_id", unsigned: true
|
135
|
-
end
|
136
|
-
|
137
|
-
<%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>
|
138
|
-
|
139
|
-
add_foreign_key "child", "parent"
|
140
|
-
EOS
|
141
|
-
}
|
142
|
-
|
143
|
-
subject { client(dump_with_default_fk_name: true) }
|
144
|
-
|
145
|
-
it {
|
146
|
-
expect {
|
147
|
-
subject.diff(dsl)
|
148
|
-
}.to raise_error('Foreign key name in `child` is undefined')
|
149
|
-
}
|
150
|
-
end
|
151
|
-
|
152
121
|
context 'orphan fk' do
|
153
122
|
let(:dsl) {
|
154
123
|
erbh(<<-EOS)
|
155
|
-
# Define parent before child
|
156
|
-
create_table "parent", force: :cascade do |t|
|
157
|
-
end
|
124
|
+
# Define parent before child
|
125
|
+
create_table "parent", force: :cascade do |t|
|
126
|
+
end
|
158
127
|
|
159
|
-
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
128
|
+
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
160
129
|
EOS
|
161
130
|
}
|
162
131
|
|