ridgepole 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ridgepole/delta.rb +1 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +5 -2
- metadata +3 -279
- data/.github/workflows/test.yml +0 -70
- data/.gitignore +0 -25
- data/spec/cli_helper.rb +0 -65
- data/spec/dsl_parser/context_spec.rb +0 -16
- data/spec/erb_helper.rb +0 -26
- data/spec/fixtures/for_require_relative_spec.rb +0 -3
- data/spec/hide_pending_formatter.rb +0 -9
- data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
- data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
- data/spec/mysql/cli/config_spec.rb +0 -210
- data/spec/mysql/cli/ridgepole_spec.rb +0 -447
- data/spec/mysql/collation/collation_spec.rb +0 -153
- data/spec/mysql/comment/comment_spec.rb +0 -179
- data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
- data/spec/mysql/diff/diff2_spec.rb +0 -189
- data/spec/mysql/diff/diff_spec.rb +0 -168
- data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
- data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
- data/spec/mysql/dump/dump_spec.rb +0 -74
- data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
- data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
- data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
- data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
- data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
- data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
- data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
- data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
- data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -276
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
- data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
- data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
- data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
- data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
- data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
- data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
- data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
- data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
- data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
- data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
- data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
- data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
- data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
- data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
- data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
- data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
- data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
- data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
- data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
- data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
- data/spec/mysql/ridgepole_test_database.sql +0 -2
- data/spec/mysql/ridgepole_test_tables.sql +0 -79
- data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
- data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
- data/spec/mysql57/json/add_json_column_spec.rb +0 -35
- data/spec/mysql57/json/change_json_column_spec.rb +0 -102
- data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
- data/spec/postgresql/diff/diff_spec.rb +0 -216
- data/spec/postgresql/dump/dump_spec.rb +0 -69
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
- data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
- data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
- data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
- data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
- data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
- data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
- data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
- data/spec/postgresql/ridgepole_test_database.sql +0 -16
- data/spec/postgresql/ridgepole_test_tables.sql +0 -75
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
- data/spec/processing_for_ci.rb +0 -13
- data/spec/spec_condition.rb +0 -58
- data/spec/spec_const.rb +0 -20
- data/spec/spec_helper.rb +0 -173
@@ -1,202 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change index (use t.index)' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "clubs", force: :cascade do |t|
|
8
|
-
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
10
|
-
end
|
11
|
-
|
12
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
|
-
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
15
|
-
end
|
16
|
-
|
17
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no", null: false
|
19
|
-
t.string "dept_no", null: false
|
20
|
-
t.date "from_date", null: false
|
21
|
-
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
24
|
-
end
|
25
|
-
|
26
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
27
|
-
t.string "dept_no", null: false
|
28
|
-
t.integer "emp_no", null: false
|
29
|
-
t.date "from_date", null: false
|
30
|
-
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
33
|
-
end
|
34
|
-
|
35
|
-
create_table "employee_clubs", force: :cascade do |t|
|
36
|
-
t.integer "emp_no", null: false
|
37
|
-
t.integer "club_id", null: false
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
|
-
end
|
40
|
-
|
41
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
42
|
-
t.date "birth_date", null: false
|
43
|
-
t.string "first_name", limit: 14, null: false
|
44
|
-
t.string "last_name", limit: 16, null: false
|
45
|
-
t.string "gender", limit: 1, null: false
|
46
|
-
t.date "hire_date", null: false
|
47
|
-
end
|
48
|
-
|
49
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
50
|
-
t.integer "emp_no", null: false
|
51
|
-
t.integer "salary", null: false
|
52
|
-
t.date "from_date", null: false
|
53
|
-
t.date "to_date", null: false
|
54
|
-
t.index ["emp_no"], name: "emp_no"
|
55
|
-
end
|
56
|
-
|
57
|
-
create_table "titles", id: false, force: :cascade do |t|
|
58
|
-
t.integer "emp_no", null: false
|
59
|
-
t.string "title", limit: 50, null: false
|
60
|
-
t.date "from_date", null: false
|
61
|
-
t.date "to_date"
|
62
|
-
t.index ["emp_no"], name: "emp_no"
|
63
|
-
end
|
64
|
-
ERB
|
65
|
-
end
|
66
|
-
|
67
|
-
let(:expected_dsl) do
|
68
|
-
erbh(<<-ERB)
|
69
|
-
create_table "clubs", force: :cascade do |t|
|
70
|
-
t.string "name", default: "", null: false
|
71
|
-
t.index ["name"], name: "idx_name", unique: true
|
72
|
-
end
|
73
|
-
|
74
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
|
-
t.string "dept_name", limit: 40, null: false
|
76
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
77
|
-
end
|
78
|
-
|
79
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
80
|
-
t.integer "emp_no", null: false
|
81
|
-
t.string "dept_no", null: false
|
82
|
-
t.date "from_date", null: false
|
83
|
-
t.date "to_date", null: false
|
84
|
-
t.index ["dept_no"], name: "dept_no"
|
85
|
-
t.index ["from_date"], name: "emp_no"
|
86
|
-
end
|
87
|
-
|
88
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
89
|
-
t.string "dept_no", null: false
|
90
|
-
t.integer "emp_no", null: false
|
91
|
-
t.date "from_date", null: false
|
92
|
-
t.date "to_date", null: false
|
93
|
-
t.index ["dept_no"], name: "dept_no"
|
94
|
-
t.index ["from_date"], name: "emp_no"
|
95
|
-
end
|
96
|
-
|
97
|
-
create_table "employee_clubs", force: :cascade do |t|
|
98
|
-
t.integer "emp_no", null: false
|
99
|
-
t.integer "club_id", null: false
|
100
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
101
|
-
end
|
102
|
-
|
103
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
104
|
-
t.date "birth_date", null: false
|
105
|
-
t.string "first_name", limit: 14, null: false
|
106
|
-
t.string "last_name", limit: 16, null: false
|
107
|
-
t.string "gender", limit: 1, null: false
|
108
|
-
t.date "hire_date", null: false
|
109
|
-
end
|
110
|
-
|
111
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
112
|
-
t.integer "emp_no", null: false
|
113
|
-
t.integer "salary", null: false
|
114
|
-
t.date "from_date", null: false
|
115
|
-
t.date "to_date", null: false
|
116
|
-
t.index ["from_date"], name: "emp_no"
|
117
|
-
end
|
118
|
-
|
119
|
-
create_table "titles", id: false, force: :cascade do |t|
|
120
|
-
t.integer "emp_no", null: false
|
121
|
-
t.string "title", limit: 50, null: false
|
122
|
-
t.date "from_date", null: false
|
123
|
-
t.date "to_date"
|
124
|
-
t.index ["emp_no"], name: "emp_no"
|
125
|
-
end
|
126
|
-
ERB
|
127
|
-
end
|
128
|
-
|
129
|
-
let(:expected_dsl_using_t_index) do
|
130
|
-
erbh(<<-ERB)
|
131
|
-
create_table "clubs", force: :cascade do |t|
|
132
|
-
t.string "name", default: "", null: false
|
133
|
-
t.index "name", name: "idx_name", unique: true
|
134
|
-
end
|
135
|
-
|
136
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
137
|
-
t.string "dept_name", limit: 40, null: false
|
138
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
139
|
-
end
|
140
|
-
|
141
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
142
|
-
t.integer "emp_no", null: false
|
143
|
-
t.string "dept_no", null: false
|
144
|
-
t.date "from_date", null: false
|
145
|
-
t.date "to_date", null: false
|
146
|
-
t.index "dept_no", name: "dept_no"
|
147
|
-
t.index ["from_date"], name: "emp_no"
|
148
|
-
end
|
149
|
-
|
150
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
151
|
-
t.string "dept_no", null: false
|
152
|
-
t.integer "emp_no", null: false
|
153
|
-
t.date "from_date", null: false
|
154
|
-
t.date "to_date", null: false
|
155
|
-
t.index "dept_no", name: "dept_no"
|
156
|
-
t.index ["from_date"], name: "emp_no"
|
157
|
-
end
|
158
|
-
|
159
|
-
create_table "employee_clubs", force: :cascade do |t|
|
160
|
-
t.integer "emp_no", null: false
|
161
|
-
t.integer "club_id", null: false
|
162
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
163
|
-
end
|
164
|
-
|
165
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
166
|
-
t.date "birth_date", null: false
|
167
|
-
t.string "first_name", limit: 14, null: false
|
168
|
-
t.string "last_name", limit: 16, null: false
|
169
|
-
t.string "gender", limit: 1, null: false
|
170
|
-
t.date "hire_date", null: false
|
171
|
-
end
|
172
|
-
|
173
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
174
|
-
t.integer "emp_no", null: false
|
175
|
-
t.integer "salary", null: false
|
176
|
-
t.date "from_date", null: false
|
177
|
-
t.date "to_date", null: false
|
178
|
-
t.index "from_date", name: "emp_no"
|
179
|
-
end
|
180
|
-
|
181
|
-
create_table "titles", id: false, force: :cascade do |t|
|
182
|
-
t.integer "emp_no", null: false
|
183
|
-
t.string "title", limit: 50, null: false
|
184
|
-
t.date "from_date", null: false
|
185
|
-
t.date "to_date"
|
186
|
-
t.index ["emp_no"], name: "emp_no"
|
187
|
-
end
|
188
|
-
ERB
|
189
|
-
end
|
190
|
-
|
191
|
-
before { subject.diff(actual_dsl).migrate }
|
192
|
-
subject { client }
|
193
|
-
|
194
|
-
it {
|
195
|
-
delta = subject.diff(expected_dsl_using_t_index)
|
196
|
-
expect(delta.differ?).to be_truthy
|
197
|
-
expect(subject.dump).to match_ruby actual_dsl
|
198
|
-
delta.migrate
|
199
|
-
expect(subject.dump).to match_ruby expected_dsl
|
200
|
-
}
|
201
|
-
end
|
202
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change index (length is Numeric) / No update' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
8
|
-
t.date "birth_date", null: false
|
9
|
-
t.string "first_name", limit: 14, null: false
|
10
|
-
t.string "last_name", limit: 16, null: false
|
11
|
-
t.string "gender", limit: 1, null: false
|
12
|
-
t.date "hire_date", null: false
|
13
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
|
14
|
-
end
|
15
|
-
ERB
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:expected_dsl) do
|
19
|
-
erbh(<<-ERB)
|
20
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
21
|
-
t.date "birth_date", null: false
|
22
|
-
t.string "first_name", limit: 14, null: false
|
23
|
-
t.string "last_name", limit: 16, null: false
|
24
|
-
t.string "gender", limit: 1, null: false
|
25
|
-
t.date "hire_date", null: false
|
26
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>
|
27
|
-
end
|
28
|
-
ERB
|
29
|
-
end
|
30
|
-
|
31
|
-
before { subject.diff(actual_dsl).migrate }
|
32
|
-
subject { client }
|
33
|
-
|
34
|
-
it {
|
35
|
-
delta = subject.diff(expected_dsl)
|
36
|
-
expect(delta.differ?).to be_falsy
|
37
|
-
expect(subject.dump).to match_ruby actual_dsl
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when change index (length is Numeric) / Update' do
|
42
|
-
let(:actual_dsl) do
|
43
|
-
<<-RUBY
|
44
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
45
|
-
t.date "birth_date", null: false
|
46
|
-
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name", limit: 16, null: false
|
48
|
-
t.string "gender", limit: 1, null: false
|
49
|
-
t.date "hire_date", null: false
|
50
|
-
end
|
51
|
-
RUBY
|
52
|
-
end
|
53
|
-
|
54
|
-
let(:expected_dsl) do
|
55
|
-
erbh(<<-ERB)
|
56
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
57
|
-
t.date "birth_date", null: false
|
58
|
-
t.string "first_name", limit: 14, null: false
|
59
|
-
t.string "last_name", limit: 16, null: false
|
60
|
-
t.string "gender", limit: 1, null: false
|
61
|
-
t.date "hire_date", null: false
|
62
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>
|
63
|
-
end
|
64
|
-
ERB
|
65
|
-
end
|
66
|
-
|
67
|
-
let(:actual_dsl_plus_index) do
|
68
|
-
actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
|
69
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
|
70
|
-
end
|
71
|
-
ERB
|
72
|
-
end
|
73
|
-
|
74
|
-
before { subject.diff(actual_dsl).migrate }
|
75
|
-
subject { client }
|
76
|
-
|
77
|
-
it {
|
78
|
-
delta = subject.diff(expected_dsl)
|
79
|
-
expect(delta.differ?).to be_truthy
|
80
|
-
expect(subject.dump).to match_ruby actual_dsl
|
81
|
-
delta.migrate
|
82
|
-
expect(subject.dump).to match_ruby actual_dsl_plus_index
|
83
|
-
}
|
84
|
-
end
|
85
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change index (length has string keys) / No update' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
8
|
-
t.date "birth_date", null: false
|
9
|
-
t.string "first_name", limit: 14, null: false
|
10
|
-
t.string "last_name", limit: 16, null: false
|
11
|
-
t.string "gender", limit: 1, null: false
|
12
|
-
t.date "hire_date", null: false
|
13
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
|
14
|
-
end
|
15
|
-
ERB
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:expected_dsl) do
|
19
|
-
erbh(<<-ERB)
|
20
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
21
|
-
t.date "birth_date", null: false
|
22
|
-
t.string "first_name", limit: 14, null: false
|
23
|
-
t.string "last_name", limit: 16, null: false
|
24
|
-
t.string "gender", limit: 1, null: false
|
25
|
-
t.date "hire_date", null: false
|
26
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10, "foo" => nil }') %>
|
27
|
-
end
|
28
|
-
ERB
|
29
|
-
end
|
30
|
-
|
31
|
-
before { subject.diff(actual_dsl).migrate }
|
32
|
-
subject { client }
|
33
|
-
|
34
|
-
it {
|
35
|
-
delta = subject.diff(expected_dsl)
|
36
|
-
expect(delta.differ?).to be_falsy
|
37
|
-
expect(subject.dump).to match_ruby actual_dsl
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when change index (length has string keys) / Update' do
|
42
|
-
let(:actual_dsl) do
|
43
|
-
<<-RUBY
|
44
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
45
|
-
t.date "birth_date", null: false
|
46
|
-
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name", limit: 16, null: false
|
48
|
-
t.string "gender", limit: 1, null: false
|
49
|
-
t.date "hire_date", null: false
|
50
|
-
end
|
51
|
-
RUBY
|
52
|
-
end
|
53
|
-
|
54
|
-
let(:expected_dsl) do
|
55
|
-
erbh(<<-ERB)
|
56
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
57
|
-
t.date "birth_date", null: false
|
58
|
-
t.string "first_name", limit: 14, null: false
|
59
|
-
t.string "last_name", limit: 16, null: false
|
60
|
-
t.string "gender", limit: 1, null: false
|
61
|
-
t.date "hire_date", null: false
|
62
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10 }') %>
|
63
|
-
end
|
64
|
-
ERB
|
65
|
-
end
|
66
|
-
|
67
|
-
let(:actual_dsl_plus_index) do
|
68
|
-
actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
|
69
|
-
t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
|
70
|
-
end
|
71
|
-
ERB
|
72
|
-
end
|
73
|
-
|
74
|
-
before { subject.diff(actual_dsl).migrate }
|
75
|
-
subject { client }
|
76
|
-
|
77
|
-
it {
|
78
|
-
delta = subject.diff(expected_dsl)
|
79
|
-
expect(delta.differ?).to be_truthy
|
80
|
-
expect(subject.dump).to match_ruby actual_dsl
|
81
|
-
delta.migrate
|
82
|
-
expect(subject.dump).to match_ruby actual_dsl_plus_index
|
83
|
-
}
|
84
|
-
end
|
85
|
-
end
|
@@ -1,235 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change index' do
|
5
|
-
let(:dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "clubs", force: :cascade do |t|
|
8
|
-
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
10
|
-
end
|
11
|
-
|
12
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
|
-
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
15
|
-
end
|
16
|
-
|
17
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no", null: false
|
19
|
-
t.string "dept_no", null: false
|
20
|
-
t.date "from_date", null: false
|
21
|
-
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
24
|
-
end
|
25
|
-
|
26
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
27
|
-
t.string "dept_no", null: false
|
28
|
-
t.integer "emp_no", null: false
|
29
|
-
t.date "from_date", null: false
|
30
|
-
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
33
|
-
end
|
34
|
-
|
35
|
-
create_table "employee_clubs", force: :cascade do |t|
|
36
|
-
t.integer "emp_no", null: false
|
37
|
-
t.integer "club_id", null: false
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
|
-
end
|
40
|
-
|
41
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
42
|
-
t.date "birth_date", null: false
|
43
|
-
t.string "first_name", limit: 14, null: false
|
44
|
-
t.string "last_name", limit: 16, null: false
|
45
|
-
t.string "gender", limit: 1, null: false
|
46
|
-
t.date "hire_date", null: false
|
47
|
-
end
|
48
|
-
|
49
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
50
|
-
t.integer "emp_no", null: false
|
51
|
-
t.integer "salary", null: false
|
52
|
-
t.date "from_date", null: false
|
53
|
-
t.date "to_date", null: false
|
54
|
-
t.index ["emp_no"], name: "emp_no"
|
55
|
-
end
|
56
|
-
|
57
|
-
create_table "titles", id: false, force: :cascade do |t|
|
58
|
-
t.integer "emp_no", null: false
|
59
|
-
t.string "title", limit: 50, null: false
|
60
|
-
t.date "from_date", null: false
|
61
|
-
t.date "to_date"
|
62
|
-
t.index ["emp_no"], name: "emp_no"
|
63
|
-
end
|
64
|
-
ERB
|
65
|
-
end
|
66
|
-
|
67
|
-
let(:actual_dsl) do
|
68
|
-
erbh(<<-ERB)
|
69
|
-
create_table "clubs", force: :cascade do |t|
|
70
|
-
t.string "name", default: "", null: false
|
71
|
-
t.index ["name"], name: "idx_name", unique: true
|
72
|
-
end
|
73
|
-
|
74
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
|
-
t.string "dept_name", limit: 40, null: false
|
76
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
77
|
-
end
|
78
|
-
|
79
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
80
|
-
t.integer "emp_no", null: false
|
81
|
-
t.string "dept_no", null: false
|
82
|
-
t.date "from_date", null: false
|
83
|
-
t.date "to_date", null: false
|
84
|
-
t.index ["dept_no"], name: "dept_no"
|
85
|
-
t.index ["emp_no"], name: "emp_no"
|
86
|
-
end
|
87
|
-
|
88
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
89
|
-
t.string "dept_no", null: false
|
90
|
-
t.integer "emp_no", null: false
|
91
|
-
t.date "from_date", null: false
|
92
|
-
t.date "to_date", null: false
|
93
|
-
t.index ["dept_no"], name: "dept_no"
|
94
|
-
t.index ["emp_no"], name: "emp_no"
|
95
|
-
end
|
96
|
-
|
97
|
-
create_table "employee_clubs", force: :cascade do |t|
|
98
|
-
t.integer "emp_no", null: false
|
99
|
-
t.integer "club_id", null: false
|
100
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
101
|
-
end
|
102
|
-
|
103
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
104
|
-
t.date "birth_date", null: false
|
105
|
-
t.string "first_name", limit: 14, null: false
|
106
|
-
t.string "last_name", limit: 16, null: false
|
107
|
-
t.string "gender", limit: 1, null: false
|
108
|
-
t.date "hire_date", null: false
|
109
|
-
end
|
110
|
-
|
111
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
112
|
-
t.integer "emp_no", null: false
|
113
|
-
t.integer "salary", null: false
|
114
|
-
t.date "from_date", null: false
|
115
|
-
t.date "to_date", null: false
|
116
|
-
t.index ["emp_no"], name: "emp_no"
|
117
|
-
end
|
118
|
-
|
119
|
-
create_table "titles", id: false, force: :cascade do |t|
|
120
|
-
t.integer "emp_no", null: false
|
121
|
-
t.string "title", limit: 50, null: false
|
122
|
-
t.date "from_date", null: false
|
123
|
-
t.date "to_date"
|
124
|
-
t.index ["emp_no"], name: "emp_no"
|
125
|
-
end
|
126
|
-
ERB
|
127
|
-
end
|
128
|
-
|
129
|
-
let(:expected_dsl) do
|
130
|
-
erbh(<<-ERB)
|
131
|
-
create_table "clubs", force: :cascade do |t|
|
132
|
-
t.string "name", default: "", null: false
|
133
|
-
t.index ["name"], name: "idx_name", unique: true
|
134
|
-
end
|
135
|
-
|
136
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
137
|
-
t.string "dept_name", limit: 40, null: false
|
138
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
139
|
-
end
|
140
|
-
|
141
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
142
|
-
t.integer "emp_no", null: false
|
143
|
-
t.string "dept_no", null: false
|
144
|
-
t.date "from_date", null: false
|
145
|
-
t.date "to_date", null: false
|
146
|
-
t.index ["dept_no"], name: "dept_no"
|
147
|
-
t.index ["from_date"], name: "emp_no"
|
148
|
-
end
|
149
|
-
|
150
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
151
|
-
t.string "dept_no", null: false
|
152
|
-
t.integer "emp_no", null: false
|
153
|
-
t.date "from_date", null: false
|
154
|
-
t.date "to_date", null: false
|
155
|
-
t.index ["dept_no"], name: "dept_no"
|
156
|
-
t.index ["from_date"], name: "emp_no"
|
157
|
-
end
|
158
|
-
|
159
|
-
create_table "employee_clubs", force: :cascade do |t|
|
160
|
-
t.integer "emp_no", null: false
|
161
|
-
t.integer "club_id", null: false
|
162
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
163
|
-
end
|
164
|
-
|
165
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
166
|
-
t.date "birth_date", null: false
|
167
|
-
t.string "first_name", limit: 14, null: false
|
168
|
-
t.string "last_name", limit: 16, null: false
|
169
|
-
t.string "gender", limit: 1, null: false
|
170
|
-
t.date "hire_date", null: false
|
171
|
-
end
|
172
|
-
|
173
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
174
|
-
t.integer "emp_no", null: false
|
175
|
-
t.integer "salary", null: false
|
176
|
-
t.date "from_date", null: false
|
177
|
-
t.date "to_date", null: false
|
178
|
-
t.index ["from_date"], name: "emp_no"
|
179
|
-
end
|
180
|
-
|
181
|
-
create_table "titles", id: false, force: :cascade do |t|
|
182
|
-
t.integer "emp_no", null: false
|
183
|
-
t.string "title", limit: 50, null: false
|
184
|
-
t.date "from_date", null: false
|
185
|
-
t.date "to_date"
|
186
|
-
t.index ["emp_no"], name: "emp_no"
|
187
|
-
end
|
188
|
-
ERB
|
189
|
-
end
|
190
|
-
|
191
|
-
before { subject.diff(actual_dsl).migrate }
|
192
|
-
subject { client }
|
193
|
-
|
194
|
-
it {
|
195
|
-
delta = subject.diff(expected_dsl)
|
196
|
-
expect(delta.differ?).to be_truthy
|
197
|
-
expect(subject.dump).to match_ruby actual_dsl
|
198
|
-
delta.migrate
|
199
|
-
expect(subject.dump).to match_ruby expected_dsl
|
200
|
-
}
|
201
|
-
|
202
|
-
it {
|
203
|
-
delta = client(bulk_change: true).diff(expected_dsl)
|
204
|
-
expect(delta.differ?).to be_truthy
|
205
|
-
expect(subject.dump).to match_ruby actual_dsl
|
206
|
-
expect(delta.script).to match_fuzzy <<-RUBY
|
207
|
-
change_table("dept_emp", bulk: true) do |t|
|
208
|
-
t.remove_index(name: "emp_no")
|
209
|
-
t.index(["from_date"], **{:name=>"emp_no", :using=>:btree, :unique=>false})
|
210
|
-
end
|
211
|
-
|
212
|
-
change_table("dept_manager", bulk: true) do |t|
|
213
|
-
t.remove_index(name: "emp_no")
|
214
|
-
t.index(["from_date"], **{:name=>"emp_no", :using=>:btree, :unique=>false})
|
215
|
-
end
|
216
|
-
|
217
|
-
change_table("salaries", bulk: true) do |t|
|
218
|
-
t.remove_index(name: "emp_no")
|
219
|
-
t.index(["from_date"], **{:name=>"emp_no", :using=>:btree, :unique=>false})
|
220
|
-
end
|
221
|
-
RUBY
|
222
|
-
}
|
223
|
-
|
224
|
-
# duplicated index checker is deleted in 6.1
|
225
|
-
# https://github.com/rails/rails/commit/edb23791d2ee9df89c5a4f24d72940ff8eaec8fc#diff-5a1c923abf3a794dbc133959167f794b2479ea8bcd0b1deda7766c22f05e8dfeL1198
|
226
|
-
it 'detects duplicated index', condition: '< 6.1' do
|
227
|
-
delta = client(bulk_change: true).diff(expected_dsl)
|
228
|
-
|
229
|
-
# XXX: Can not add an index of the same name
|
230
|
-
expect do
|
231
|
-
delta.migrate
|
232
|
-
end.to raise_error(/Index name 'emp_no' on table 'dept_emp' already exists/)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|