ridgepole 0.9.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +4 -0
- data/CHANGELOG.md +238 -0
- data/README.md +12 -142
- data/bin/ridgepole +1 -1
- data/docker-compose.yml +26 -18
- data/gemfiles/activerecord_7.0.gemfile +7 -0
- data/lib/ridgepole/delta.rb +1 -1
- data/lib/ridgepole/diff.rb +4 -1
- data/lib/ridgepole/execute_expander.rb +5 -2
- data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +8 -5
- metadata +10 -284
- 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 -231
- 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,220 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when create 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
|
-
end
|
72
|
-
|
73
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
74
|
-
t.string "dept_name", limit: 40, null: false
|
75
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
76
|
-
end
|
77
|
-
|
78
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
79
|
-
t.integer "emp_no", null: false
|
80
|
-
t.string "dept_no", null: false
|
81
|
-
t.date "from_date", null: false
|
82
|
-
t.date "to_date", null: false
|
83
|
-
t.index ["dept_no"], name: "dept_no"
|
84
|
-
t.index ["emp_no"], name: "emp_no"
|
85
|
-
end
|
86
|
-
|
87
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
88
|
-
t.string "dept_no", null: false
|
89
|
-
t.integer "emp_no", null: false
|
90
|
-
t.date "from_date", null: false
|
91
|
-
t.date "to_date", null: false
|
92
|
-
t.index ["dept_no"], name: "dept_no"
|
93
|
-
t.index ["emp_no"], name: "emp_no"
|
94
|
-
end
|
95
|
-
|
96
|
-
create_table "employee_clubs", force: :cascade do |t|
|
97
|
-
t.integer "emp_no", null: false
|
98
|
-
t.integer "club_id", null: false
|
99
|
-
end
|
100
|
-
|
101
|
-
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
102
|
-
t.date "birth_date", null: false
|
103
|
-
t.string "first_name", limit: 14, null: false
|
104
|
-
t.string "last_name", limit: 16, null: false
|
105
|
-
t.string "gender", limit: 1, null: false
|
106
|
-
t.date "hire_date", null: false
|
107
|
-
end
|
108
|
-
|
109
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
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"
|
115
|
-
end
|
116
|
-
|
117
|
-
create_table "titles", id: false, force: :cascade do |t|
|
118
|
-
t.integer "emp_no", null: false
|
119
|
-
t.string "title", limit: 50, null: false
|
120
|
-
t.date "from_date", null: false
|
121
|
-
t.date "to_date"
|
122
|
-
end
|
123
|
-
ERB
|
124
|
-
end
|
125
|
-
|
126
|
-
let(:expected_dsl) { dsl }
|
127
|
-
|
128
|
-
before { subject.diff(actual_dsl).migrate }
|
129
|
-
subject { client }
|
130
|
-
|
131
|
-
it {
|
132
|
-
delta = subject.diff(expected_dsl)
|
133
|
-
expect(delta.differ?).to be_truthy
|
134
|
-
expect(subject.dump).to match_ruby actual_dsl
|
135
|
-
delta.migrate
|
136
|
-
expect(subject.dump).to match_ruby expected_dsl
|
137
|
-
}
|
138
|
-
|
139
|
-
it {
|
140
|
-
delta = client(bulk_change: true).diff(expected_dsl)
|
141
|
-
expect(delta.differ?).to be_truthy
|
142
|
-
expect(subject.dump).to match_ruby actual_dsl
|
143
|
-
expect(delta.script).to match_fuzzy erbh(<<-ERB)
|
144
|
-
change_table("clubs", bulk: true) do |t|
|
145
|
-
t.index(["name"], **{:name=>"idx_name", :unique=>true})
|
146
|
-
end
|
147
|
-
|
148
|
-
change_table("employee_clubs", bulk: true) do |t|
|
149
|
-
t.index(["emp_no", "club_id"], **{:name=>"idx_emp_no_club_id"})
|
150
|
-
end
|
151
|
-
|
152
|
-
change_table("titles", bulk: true) do |t|
|
153
|
-
t.index(["emp_no"], **{:name=>"emp_no"})
|
154
|
-
end
|
155
|
-
ERB
|
156
|
-
delta.migrate
|
157
|
-
expect(subject.dump).to match_ruby expected_dsl
|
158
|
-
}
|
159
|
-
end
|
160
|
-
|
161
|
-
context 'when using index option' do
|
162
|
-
let(:dsl) do
|
163
|
-
erbh(<<-ERB)
|
164
|
-
create_table "clubs", force: :cascade do |t|
|
165
|
-
t.string "name", default: "", null: false, index: { unique: true }
|
166
|
-
end
|
167
|
-
|
168
|
-
create_table "titles", id: false, force: :cascade do |t|
|
169
|
-
t.integer "emp_no", null: false, index: { name: "emp_no" }
|
170
|
-
t.string "title", limit: 50, null: false
|
171
|
-
t.date "from_date", null: false
|
172
|
-
t.date "to_date"
|
173
|
-
end
|
174
|
-
ERB
|
175
|
-
end
|
176
|
-
|
177
|
-
let(:actual_dsl) do
|
178
|
-
erbh(<<-ERB)
|
179
|
-
create_table "clubs", force: :cascade do |t|
|
180
|
-
t.string "name", default: "", null: false
|
181
|
-
end
|
182
|
-
|
183
|
-
create_table "titles", id: false, force: :cascade do |t|
|
184
|
-
t.integer "emp_no", null: false
|
185
|
-
t.string "title", limit: 50, null: false
|
186
|
-
t.date "from_date", null: false
|
187
|
-
t.date "to_date"
|
188
|
-
end
|
189
|
-
ERB
|
190
|
-
end
|
191
|
-
|
192
|
-
let(:expected_dsl) do
|
193
|
-
erbh(<<-ERB)
|
194
|
-
create_table "clubs", force: :cascade do |t|
|
195
|
-
t.string "name", default: "", null: false
|
196
|
-
t.index ["name"], name: "index_clubs_on_name", unique: true
|
197
|
-
end
|
198
|
-
|
199
|
-
create_table "titles", id: false, force: :cascade do |t|
|
200
|
-
t.integer "emp_no", null: false
|
201
|
-
t.string "title", limit: 50, null: false
|
202
|
-
t.date "from_date", null: false
|
203
|
-
t.date "to_date"
|
204
|
-
t.index ["emp_no"], name: "emp_no"
|
205
|
-
end
|
206
|
-
ERB
|
207
|
-
end
|
208
|
-
|
209
|
-
before { subject.diff(actual_dsl).migrate }
|
210
|
-
subject { client }
|
211
|
-
|
212
|
-
it {
|
213
|
-
delta = subject.diff(dsl)
|
214
|
-
expect(delta.differ?).to be_truthy
|
215
|
-
expect(subject.dump).to match_ruby actual_dsl
|
216
|
-
delta.migrate
|
217
|
-
expect(subject.dump).to match_ruby expected_dsl
|
218
|
-
}
|
219
|
-
end
|
220
|
-
end
|
@@ -1,123 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when create table' 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", primary_key: ["emp_no", "dept_no"], 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", primary_key: ["emp_no", "dept_no"], 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", primary_key: ["emp_no", "from_date"], 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", primary_key: ["emp_no", "title", "from_date"], 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 "departments", primary_key: "dept_no", force: :cascade do |t|
|
70
|
-
t.string "dept_name", limit: 40, null: false
|
71
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
72
|
-
end
|
73
|
-
|
74
|
-
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
75
|
-
t.integer "emp_no", null: false
|
76
|
-
t.string "dept_no", null: false
|
77
|
-
t.date "from_date", null: false
|
78
|
-
t.date "to_date", null: false
|
79
|
-
t.index ["dept_no"], name: "dept_no"
|
80
|
-
t.index ["emp_no"], name: "emp_no"
|
81
|
-
end
|
82
|
-
|
83
|
-
create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
84
|
-
t.string "dept_no", null: false
|
85
|
-
t.integer "emp_no", null: false
|
86
|
-
t.date "from_date", null: false
|
87
|
-
t.date "to_date", null: false
|
88
|
-
t.index ["dept_no"], name: "dept_no"
|
89
|
-
t.index ["emp_no"], name: "emp_no"
|
90
|
-
end
|
91
|
-
|
92
|
-
create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
|
93
|
-
t.integer "emp_no", null: false
|
94
|
-
t.integer "salary", null: false
|
95
|
-
t.date "from_date", null: false
|
96
|
-
t.date "to_date", null: false
|
97
|
-
t.index ["emp_no"], name: "emp_no"
|
98
|
-
end
|
99
|
-
|
100
|
-
create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
|
101
|
-
t.integer "emp_no", null: false
|
102
|
-
t.string "title", limit: 50, null: false
|
103
|
-
t.date "from_date", null: false
|
104
|
-
t.date "to_date"
|
105
|
-
t.index ["emp_no"], name: "emp_no"
|
106
|
-
end
|
107
|
-
ERB
|
108
|
-
end
|
109
|
-
|
110
|
-
let(:expected_dsl) { dsl }
|
111
|
-
|
112
|
-
before { subject.diff(actual_dsl).migrate }
|
113
|
-
subject { client }
|
114
|
-
|
115
|
-
it {
|
116
|
-
delta = subject.diff(expected_dsl)
|
117
|
-
expect(delta.differ?).to be_truthy
|
118
|
-
expect(subject.dump).to match_ruby actual_dsl
|
119
|
-
delta.migrate
|
120
|
-
expect(subject.dump).to match_ruby expected_dsl
|
121
|
-
}
|
122
|
-
end
|
123
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when create table with ignore:true' do
|
5
|
-
let(:dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
8
|
-
t.string "dept_name", limit: 40, null: false
|
9
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
10
|
-
end
|
11
|
-
|
12
|
-
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
13
|
-
t.integer "emp_no", null: false
|
14
|
-
t.string "dept_no", null: false
|
15
|
-
t.date "from_date", null: false, ignore: true
|
16
|
-
t.date "to_date", null: false
|
17
|
-
t.index ["dept_no"], name: "dept_no", ignore: true
|
18
|
-
t.index ["emp_no"], name: "emp_no"
|
19
|
-
end
|
20
|
-
ERB
|
21
|
-
end
|
22
|
-
|
23
|
-
let(:actual_dsl) do
|
24
|
-
erbh(<<-ERB)
|
25
|
-
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
26
|
-
t.string "dept_name", limit: 40, null: false
|
27
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
28
|
-
end
|
29
|
-
ERB
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:expected_dsl) { dsl.each_line.reject { |l| l =~ /ignore/ }.join }
|
33
|
-
|
34
|
-
before { subject.diff(actual_dsl).migrate }
|
35
|
-
subject { client }
|
36
|
-
|
37
|
-
it {
|
38
|
-
delta = subject.diff(expected_dsl)
|
39
|
-
expect(delta.differ?).to be_truthy
|
40
|
-
expect(subject.dump).to match_ruby actual_dsl
|
41
|
-
delta.migrate
|
42
|
-
expect(subject.dump).to match_ruby expected_dsl
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate (with index)' do
|
4
|
-
context 'when create table' do
|
5
|
-
let(:actual_dsl) { '' }
|
6
|
-
|
7
|
-
let(:expected_dsl) do
|
8
|
-
erbh(<<-ERB)
|
9
|
-
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
10
|
-
t.integer "emp_no", null: false
|
11
|
-
t.string "dept_no", null: false
|
12
|
-
t.date "from_date", null: false
|
13
|
-
t.date "to_date", null: false
|
14
|
-
t.index ["dept_no"], name: "dept_no"
|
15
|
-
t.index ["emp_no"], name: "emp_no"
|
16
|
-
end
|
17
|
-
ERB
|
18
|
-
end
|
19
|
-
|
20
|
-
before { subject.diff(actual_dsl).migrate }
|
21
|
-
subject { client(create_table_with_index: true) }
|
22
|
-
|
23
|
-
it {
|
24
|
-
delta = subject.diff(expected_dsl)
|
25
|
-
expect(delta.differ?).to be_truthy
|
26
|
-
|
27
|
-
expect(delta.script).to match_fuzzy erbh(<<-ERB)
|
28
|
-
create_table("dept_emp", **{:primary_key=>["emp_no", "dept_no"]}) do |t|
|
29
|
-
t.column("emp_no", :"integer", **{:null=>false, :limit=>4})
|
30
|
-
t.column("dept_no", :"string", **{:null=>false, :limit=>255})
|
31
|
-
t.column("from_date", :"date", **{:null=>false})
|
32
|
-
t.column("to_date", :"date", **{:null=>false})
|
33
|
-
t.index(["dept_no"], **{:name=>"dept_no"})
|
34
|
-
t.index(["emp_no"], **{:name=>"emp_no"})
|
35
|
-
end
|
36
|
-
ERB
|
37
|
-
|
38
|
-
expect(subject.dump).to match_ruby actual_dsl
|
39
|
-
delta.migrate
|
40
|
-
expect(subject.dump).to match_ruby expected_dsl
|
41
|
-
}
|
42
|
-
end
|
43
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when create table' do
|
5
|
-
let(:expected_dsl) do
|
6
|
-
<<-RUBY
|
7
|
-
create_table "employee_clubs", force: :cascade do |t|
|
8
|
-
t.integer "emp_no", null: false, unsigned: true
|
9
|
-
t.integer "club_id", null: false, unsigned: true
|
10
|
-
end
|
11
|
-
|
12
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
13
|
-
RUBY
|
14
|
-
end
|
15
|
-
|
16
|
-
subject { client(table_options: 'ENGINE=MyISAM CHARSET=utf8') }
|
17
|
-
|
18
|
-
it {
|
19
|
-
delta = subject.diff(expected_dsl)
|
20
|
-
expect(delta.differ?).to be_truthy
|
21
|
-
|
22
|
-
expect(delta.script).to match_fuzzy <<-RUBY
|
23
|
-
create_table("employee_clubs", **{:options=>"ENGINE=MyISAM CHARSET=utf8"}) do |t|
|
24
|
-
t.column("emp_no", :"integer", **{:null=>false, :unsigned=>true, :limit=>4})
|
25
|
-
t.column("club_id", :"integer", **{:null=>false, :unsigned=>true, :limit=>4})
|
26
|
-
end
|
27
|
-
add_index("employee_clubs", ["emp_no", "club_id"], **{:name=>"idx_emp_no_club_id", :using=>:btree})
|
28
|
-
RUBY
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when create table (table definition options takes precedence)' do
|
33
|
-
let(:expected_dsl) do
|
34
|
-
<<-RUBY
|
35
|
-
create_table "employee_clubs", force: :cascade, options: "ENGINE=InnoDB CHARSET=utf8mb4" do |t|
|
36
|
-
t.integer "emp_no", null: false, unsigned: true
|
37
|
-
t.integer "club_id", null: false, unsigned: true
|
38
|
-
end
|
39
|
-
|
40
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
41
|
-
RUBY
|
42
|
-
end
|
43
|
-
|
44
|
-
subject { client(table_options: 'ENGINE=MyISAM CHARSET=utf8') }
|
45
|
-
|
46
|
-
it {
|
47
|
-
delta = subject.diff(expected_dsl)
|
48
|
-
expect(delta.differ?).to be_truthy
|
49
|
-
|
50
|
-
expect(delta.script).to match_fuzzy <<-RUBY
|
51
|
-
create_table("employee_clubs", **{:options=>"ENGINE=InnoDB CHARSET=utf8mb4"}) do |t|
|
52
|
-
t.column("emp_no", :"integer", **{:null=>false, :unsigned=>true, :limit=>4})
|
53
|
-
t.column("club_id", :"integer", **{:null=>false, :unsigned=>true, :limit=>4})
|
54
|
-
end
|
55
|
-
add_index("employee_clubs", ["emp_no", "club_id"], **{:name=>"idx_emp_no_club_id", :using=>:btree})
|
56
|
-
RUBY
|
57
|
-
}
|
58
|
-
end
|
59
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when create table' 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 "departments", primary_key: "dept_no", force: :cascade do |t|
|
70
|
-
t.string "dept_name", limit: 40, null: false
|
71
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
72
|
-
end
|
73
|
-
|
74
|
-
create_table "dept_emp", id: false, force: :cascade do |t|
|
75
|
-
t.integer "emp_no", null: false
|
76
|
-
t.string "dept_no", null: false
|
77
|
-
t.date "from_date", null: false
|
78
|
-
t.date "to_date", null: false
|
79
|
-
t.index ["dept_no"], name: "dept_no"
|
80
|
-
t.index ["emp_no"], name: "emp_no"
|
81
|
-
end
|
82
|
-
|
83
|
-
create_table "dept_manager", id: false, force: :cascade do |t|
|
84
|
-
t.string "dept_no", null: false
|
85
|
-
t.integer "emp_no", null: false
|
86
|
-
t.date "from_date", null: false
|
87
|
-
t.date "to_date", null: false
|
88
|
-
t.index ["dept_no"], name: "dept_no"
|
89
|
-
t.index ["emp_no"], name: "emp_no"
|
90
|
-
end
|
91
|
-
|
92
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
93
|
-
t.integer "emp_no", null: false
|
94
|
-
t.integer "salary", null: false
|
95
|
-
t.date "from_date", null: false
|
96
|
-
t.date "to_date", null: false
|
97
|
-
t.index ["emp_no"], name: "emp_no"
|
98
|
-
end
|
99
|
-
|
100
|
-
create_table "titles", id: false, force: :cascade do |t|
|
101
|
-
t.integer "emp_no", null: false
|
102
|
-
t.string "title", limit: 50, null: false
|
103
|
-
t.date "from_date", null: false
|
104
|
-
t.date "to_date"
|
105
|
-
t.index ["emp_no"], name: "emp_no"
|
106
|
-
end
|
107
|
-
ERB
|
108
|
-
end
|
109
|
-
|
110
|
-
let(:expected_dsl) { dsl }
|
111
|
-
|
112
|
-
before { subject.diff(actual_dsl).migrate }
|
113
|
-
subject { client }
|
114
|
-
|
115
|
-
it {
|
116
|
-
delta = subject.diff(expected_dsl)
|
117
|
-
expect(delta.differ?).to be_truthy
|
118
|
-
expect(subject.dump).to match_ruby actual_dsl
|
119
|
-
|
120
|
-
script = <<-SHELL
|
121
|
-
echo "$1" | #{MYSQL_CLI} #{TEST_SCHEMA}
|
122
|
-
SHELL
|
123
|
-
|
124
|
-
tempfile(File.basename(__FILE__), script) do |path|
|
125
|
-
FileUtils.chmod(0o755, path)
|
126
|
-
delta.migrate(external_script: path)
|
127
|
-
end
|
128
|
-
|
129
|
-
expect(subject.dump).to match_ruby expected_dsl
|
130
|
-
}
|
131
|
-
end
|
132
|
-
end
|