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,241 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when add column after id (pk: normal)' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "employees", 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.datetime "created_at", null: false
|
14
|
-
t.datetime "updated_at", null: false
|
15
|
-
t.binary "registered_name"
|
16
|
-
end
|
17
|
-
ERB
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:expected_dsl) do
|
21
|
-
erbh(<<-ERB)
|
22
|
-
create_table "employees", force: :cascade do |t|
|
23
|
-
t.string "ext_column", null: false
|
24
|
-
t.date "birth_date", null: false
|
25
|
-
t.string "first_name", limit: 14, null: false
|
26
|
-
t.string "last_name", limit: 16, null: false
|
27
|
-
t.string "gender", limit: 1, null: false
|
28
|
-
t.date "hire_date", null: false
|
29
|
-
t.datetime "created_at", null: false
|
30
|
-
t.datetime "updated_at", null: false
|
31
|
-
t.binary "registered_name", limit: 255
|
32
|
-
end
|
33
|
-
ERB
|
34
|
-
end
|
35
|
-
|
36
|
-
before { subject.diff(actual_dsl).migrate }
|
37
|
-
subject { client }
|
38
|
-
|
39
|
-
it {
|
40
|
-
delta = subject.diff(expected_dsl)
|
41
|
-
expect(delta.differ?).to be_truthy
|
42
|
-
expect(subject.dump).to match_ruby actual_dsl
|
43
|
-
delta.migrate
|
44
|
-
expect(subject.dump).to match_ruby expected_dsl
|
45
|
-
|
46
|
-
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
47
|
-
CREATE TABLE `employees` (
|
48
|
-
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
49
|
-
`ext_column` varchar(255) NOT NULL,
|
50
|
-
`birth_date` date NOT NULL,
|
51
|
-
`first_name` varchar(14) NOT NULL,
|
52
|
-
`last_name` varchar(16) NOT NULL,
|
53
|
-
`gender` varchar(1) NOT NULL,
|
54
|
-
`hire_date` date NOT NULL,
|
55
|
-
`created_at` datetime NOT NULL,
|
56
|
-
`updated_at` datetime NOT NULL,
|
57
|
-
`registered_name` varbinary(255) DEFAULT NULL,
|
58
|
-
PRIMARY KEY (`id`)
|
59
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
60
|
-
ERB
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when add column after id (pk: emp_id)' do
|
65
|
-
let(:actual_dsl) do
|
66
|
-
erbh(<<-ERB)
|
67
|
-
create_table "employees", primary_key: "emp_id", force: :cascade do |t|
|
68
|
-
t.date "birth_date", null: false
|
69
|
-
t.string "first_name", limit: 14, null: false
|
70
|
-
t.string "last_name", limit: 16, null: false
|
71
|
-
t.string "gender", limit: 1, null: false
|
72
|
-
t.date "hire_date", null: false
|
73
|
-
t.datetime "created_at", null: false
|
74
|
-
t.datetime "updated_at", null: false
|
75
|
-
t.binary "registered_name"
|
76
|
-
end
|
77
|
-
ERB
|
78
|
-
end
|
79
|
-
|
80
|
-
let(:expected_dsl) do
|
81
|
-
erbh(<<-ERB)
|
82
|
-
create_table "employees", primary_key: "emp_id", force: :cascade do |t|
|
83
|
-
t.string "ext_column", null: false
|
84
|
-
t.date "birth_date", null: false
|
85
|
-
t.string "first_name", limit: 14, null: false
|
86
|
-
t.string "last_name", limit: 16, null: false
|
87
|
-
t.string "gender", limit: 1, null: false
|
88
|
-
t.date "hire_date", null: false
|
89
|
-
t.datetime "created_at", null: false
|
90
|
-
t.datetime "updated_at", null: false
|
91
|
-
t.binary "registered_name", limit: 255
|
92
|
-
end
|
93
|
-
ERB
|
94
|
-
end
|
95
|
-
|
96
|
-
before { subject.diff(actual_dsl).migrate }
|
97
|
-
subject { client }
|
98
|
-
|
99
|
-
it {
|
100
|
-
delta = subject.diff(expected_dsl)
|
101
|
-
expect(delta.differ?).to be_truthy
|
102
|
-
expect(subject.dump).to match_ruby actual_dsl
|
103
|
-
delta.migrate
|
104
|
-
expect(subject.dump).to match_ruby expected_dsl
|
105
|
-
|
106
|
-
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
107
|
-
CREATE TABLE `employees` (
|
108
|
-
`emp_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
109
|
-
`ext_column` varchar(255) NOT NULL,
|
110
|
-
`birth_date` date NOT NULL,
|
111
|
-
`first_name` varchar(14) NOT NULL,
|
112
|
-
`last_name` varchar(16) NOT NULL,
|
113
|
-
`gender` varchar(1) NOT NULL,
|
114
|
-
`hire_date` date NOT NULL,
|
115
|
-
`created_at` datetime NOT NULL,
|
116
|
-
`updated_at` datetime NOT NULL,
|
117
|
-
`registered_name` varbinary(255) DEFAULT NULL,
|
118
|
-
PRIMARY KEY (`emp_id`)
|
119
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
120
|
-
ERB
|
121
|
-
}
|
122
|
-
end
|
123
|
-
|
124
|
-
context 'when add column after id (pk: no pk)' do
|
125
|
-
let(:actual_dsl) do
|
126
|
-
erbh(<<-ERB)
|
127
|
-
create_table "employees", id: false, force: :cascade do |t|
|
128
|
-
t.date "birth_date", null: false
|
129
|
-
t.string "first_name", limit: 14, null: false
|
130
|
-
t.string "last_name", limit: 16, null: false
|
131
|
-
t.string "gender", limit: 1, null: false
|
132
|
-
t.date "hire_date", null: false
|
133
|
-
t.datetime "created_at", null: false
|
134
|
-
t.datetime "updated_at", null: false
|
135
|
-
t.binary "registered_name"
|
136
|
-
end
|
137
|
-
ERB
|
138
|
-
end
|
139
|
-
|
140
|
-
let(:expected_dsl) do
|
141
|
-
erbh(<<-ERB)
|
142
|
-
create_table "employees", id: false, force: :cascade do |t|
|
143
|
-
t.string "ext_column", null: false
|
144
|
-
t.date "birth_date", null: false
|
145
|
-
t.string "first_name", limit: 14, null: false
|
146
|
-
t.string "last_name", limit: 16, null: false
|
147
|
-
t.string "gender", limit: 1, null: false
|
148
|
-
t.date "hire_date", null: false
|
149
|
-
t.datetime "created_at", null: false
|
150
|
-
t.datetime "updated_at", null: false
|
151
|
-
t.binary "registered_name", limit: 255
|
152
|
-
end
|
153
|
-
ERB
|
154
|
-
end
|
155
|
-
|
156
|
-
before { subject.diff(actual_dsl).migrate }
|
157
|
-
subject { client }
|
158
|
-
|
159
|
-
it {
|
160
|
-
delta = subject.diff(expected_dsl)
|
161
|
-
expect(delta.differ?).to be_truthy
|
162
|
-
expect(subject.dump).to match_ruby actual_dsl
|
163
|
-
delta.migrate
|
164
|
-
expect(subject.dump).to match_ruby expected_dsl
|
165
|
-
|
166
|
-
expect(show_create_table_mysql('employees')).to match_fuzzy <<-SQL
|
167
|
-
CREATE TABLE `employees` (
|
168
|
-
`ext_column` varchar(255) NOT NULL,
|
169
|
-
`birth_date` date NOT NULL,
|
170
|
-
`first_name` varchar(14) NOT NULL,
|
171
|
-
`last_name` varchar(16) NOT NULL,
|
172
|
-
`gender` varchar(1) NOT NULL,
|
173
|
-
`hire_date` date NOT NULL,
|
174
|
-
`created_at` datetime NOT NULL,
|
175
|
-
`updated_at` datetime NOT NULL,
|
176
|
-
`registered_name` varbinary(255) DEFAULT NULL
|
177
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
178
|
-
SQL
|
179
|
-
}
|
180
|
-
end
|
181
|
-
|
182
|
-
context 'when add column after id (pk: with pk delta)' do
|
183
|
-
let(:actual_dsl) do
|
184
|
-
erbh(<<-ERB)
|
185
|
-
create_table "employees", force: :cascade do |t|
|
186
|
-
t.date "birth_date", null: false
|
187
|
-
t.string "first_name", limit: 14, null: false
|
188
|
-
t.string "last_name", limit: 16, null: false
|
189
|
-
t.string "gender", limit: 1, null: false
|
190
|
-
t.date "hire_date", null: false
|
191
|
-
t.datetime "created_at", null: false
|
192
|
-
t.datetime "updated_at", null: false
|
193
|
-
t.binary "registered_name"
|
194
|
-
end
|
195
|
-
ERB
|
196
|
-
end
|
197
|
-
|
198
|
-
let(:expected_dsl) do
|
199
|
-
erbh(<<-ERB)
|
200
|
-
create_table "employees", primary_key: "emp_id", force: :cascade do |t|
|
201
|
-
t.string "ext_column", null: false
|
202
|
-
t.date "birth_date", null: false
|
203
|
-
t.string "first_name", limit: 14, null: false
|
204
|
-
t.string "last_name", limit: 16, null: false
|
205
|
-
t.string "gender", limit: 1, null: false
|
206
|
-
t.date "hire_date", null: false
|
207
|
-
t.datetime "created_at", null: false
|
208
|
-
t.datetime "updated_at", null: false
|
209
|
-
t.binary "registered_name", limit: 255
|
210
|
-
end
|
211
|
-
ERB
|
212
|
-
end
|
213
|
-
|
214
|
-
before { subject.diff(actual_dsl).migrate }
|
215
|
-
subject { client }
|
216
|
-
|
217
|
-
it {
|
218
|
-
delta = subject.diff(expected_dsl)
|
219
|
-
expect(delta.differ?).to be_truthy
|
220
|
-
expect(subject.dump).to match_ruby actual_dsl
|
221
|
-
delta.migrate
|
222
|
-
expect(subject.dump).to match_ruby expected_dsl.sub(/, *primary_key: *"emp_id"/, '')
|
223
|
-
|
224
|
-
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
225
|
-
CREATE TABLE `employees` (
|
226
|
-
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
227
|
-
`ext_column` varchar(255) NOT NULL,
|
228
|
-
`birth_date` date NOT NULL,
|
229
|
-
`first_name` varchar(14) NOT NULL,
|
230
|
-
`last_name` varchar(16) NOT NULL,
|
231
|
-
`gender` varchar(1) NOT NULL,
|
232
|
-
`hire_date` date NOT NULL,
|
233
|
-
`created_at` datetime NOT NULL,
|
234
|
-
`updated_at` datetime NOT NULL,
|
235
|
-
`registered_name` varbinary(255) DEFAULT NULL,
|
236
|
-
PRIMARY KEY (`id`)
|
237
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
238
|
-
ERB
|
239
|
-
}
|
240
|
-
end
|
241
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'integer/limit:8 = bigint' do
|
5
|
-
let(:dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
8
|
-
t.integer "emp_no_int", limit: 4, null: false
|
9
|
-
t.integer "emp_no_bigint5", limit: 5, null: false
|
10
|
-
t.integer "emp_no_bigint6", limit: 6, null: false
|
11
|
-
t.integer "emp_no_bigint7", limit: 7, null: false
|
12
|
-
t.integer "emp_no_bigint8", limit: 8, null: false
|
13
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
14
|
-
t.date "from_date", null: false
|
15
|
-
t.date "to_date", null: false
|
16
|
-
end
|
17
|
-
ERB
|
18
|
-
end
|
19
|
-
|
20
|
-
before { subject.diff(dsl).migrate }
|
21
|
-
subject { client }
|
22
|
-
|
23
|
-
it {
|
24
|
-
expect(subject.dump).to match_ruby dsl
|
25
|
-
.sub(/t.integer "emp_no_int", limit: 4/, 't.integer "emp_no_int"')
|
26
|
-
.sub(/t.integer "emp_no_bigint5", limit: 5/, 't.bigint "emp_no_bigint5"')
|
27
|
-
.sub(/t.integer "emp_no_bigint6", limit: 6/, 't.bigint "emp_no_bigint6"')
|
28
|
-
.sub(/t.integer "emp_no_bigint7", limit: 7/, 't.bigint "emp_no_bigint7"')
|
29
|
-
.sub(/t.integer "emp_no_bigint8", limit: 8/, 't.bigint "emp_no_bigint8"')
|
30
|
-
delta = subject.diff(dsl)
|
31
|
-
expect(delta.differ?).to be_falsey
|
32
|
-
}
|
33
|
-
end
|
34
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
before { subject.diff(actual_dsl).migrate }
|
5
|
-
subject { client(table_options: table_options, table_hash_options: table_hash_options, dump_without_table_options: dump_without_table_options) }
|
6
|
-
|
7
|
-
let(:warning_regexp) { /Table option changes are ignored/ }
|
8
|
-
let(:dump_without_table_options) { false }
|
9
|
-
let(:table_options) { nil }
|
10
|
-
let(:table_hash_options) { {} }
|
11
|
-
|
12
|
-
let(:actual_dsl) do
|
13
|
-
erbh(<<-ERB)
|
14
|
-
create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond('>= 6.1', { charset: 'utf8' }, { options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' }) %> do |t|
|
15
|
-
end
|
16
|
-
ERB
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:expected_dsl) do
|
20
|
-
erbh(<<-ERB)
|
21
|
-
create_table :employees, primary_key: :emp_no, force: :cascade do |t|
|
22
|
-
end
|
23
|
-
ERB
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when change options (no change)', condition: '< 6.1' do
|
27
|
-
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8' }
|
28
|
-
|
29
|
-
it {
|
30
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn).with(warning_regexp)
|
31
|
-
delta = subject.diff(expected_dsl)
|
32
|
-
expect(delta.differ?).to be_falsey
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when change options (change)', condition: '< 6.1' do
|
37
|
-
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }
|
38
|
-
|
39
|
-
it {
|
40
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(warning_regexp)
|
41
|
-
delta = subject.diff(expected_dsl)
|
42
|
-
expect(delta.differ?).to be_falsey
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when dump_without_table_options => true', condition: '< 6.1' do
|
47
|
-
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }
|
48
|
-
let(:dump_without_table_options) { true }
|
49
|
-
|
50
|
-
it {
|
51
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
52
|
-
delta = subject.diff(expected_dsl)
|
53
|
-
expect(delta.differ?).to be_falsey
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'when change options (no change)', condition: '>= 6.1' do
|
58
|
-
let(:table_hash_options) { { charset: 'utf8' } }
|
59
|
-
|
60
|
-
it {
|
61
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn).with(warning_regexp)
|
62
|
-
delta = subject.diff(expected_dsl)
|
63
|
-
expect(delta.differ?).to be_falsey
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when change options (change)', condition: '>= 6.1' do
|
68
|
-
let(:table_hash_options) { { charset: 'utf8mb4' } }
|
69
|
-
|
70
|
-
it {
|
71
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(warning_regexp)
|
72
|
-
delta = subject.diff(expected_dsl)
|
73
|
-
expect(delta.differ?).to be_falsey
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when dump_without_table_options => true', condition: '>= 6.1' do
|
78
|
-
let(:table_hash_options) { { charset: 'utf8mb4' } }
|
79
|
-
let(:dump_without_table_options) { true }
|
80
|
-
|
81
|
-
it {
|
82
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
83
|
-
delta = subject.diff(expected_dsl)
|
84
|
-
expect(delta.differ?).to be_falsey
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when default:0 -> (emply)' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
8
|
-
t.integer "emp_no", default: 0, null: false
|
9
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
10
|
-
t.date "from_date", null: false
|
11
|
-
t.date "to_date", null: false
|
12
|
-
end
|
13
|
-
ERB
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:expected_dsl) do
|
17
|
-
erbh(<<-ERB)
|
18
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
19
|
-
t.integer "emp_no", limit: 4, null: true
|
20
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
21
|
-
t.date "from_date", null: false
|
22
|
-
t.date "to_date", null: false
|
23
|
-
end
|
24
|
-
ERB
|
25
|
-
end
|
26
|
-
|
27
|
-
let(:result_dsl) do
|
28
|
-
erbh(<<-ERB)
|
29
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
30
|
-
t.integer "emp_no"
|
31
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
32
|
-
t.date "from_date", null: false
|
33
|
-
t.date "to_date", null: false
|
34
|
-
end
|
35
|
-
ERB
|
36
|
-
end
|
37
|
-
|
38
|
-
before { subject.diff(actual_dsl).migrate }
|
39
|
-
subject { client }
|
40
|
-
|
41
|
-
it {
|
42
|
-
delta = subject.diff(expected_dsl)
|
43
|
-
expect(delta.differ?).to be_truthy
|
44
|
-
expect(subject.dump).to match_ruby actual_dsl
|
45
|
-
delta.migrate
|
46
|
-
expect(subject.dump).to match_fuzzy result_dsl
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when default:0 -> (emply with null:false)' do
|
51
|
-
let(:actual_dsl) do
|
52
|
-
erbh(<<-ERB)
|
53
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
54
|
-
t.integer "emp_no", default: 0, null: false
|
55
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
56
|
-
t.date "from_date", null: false
|
57
|
-
t.date "to_date", null: false
|
58
|
-
end
|
59
|
-
ERB
|
60
|
-
end
|
61
|
-
|
62
|
-
let(:expected_dsl) do
|
63
|
-
erbh(<<-ERB)
|
64
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
65
|
-
t.integer "emp_no", null: false
|
66
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
67
|
-
t.date "from_date", null: false
|
68
|
-
t.date "to_date", null: false
|
69
|
-
end
|
70
|
-
ERB
|
71
|
-
end
|
72
|
-
|
73
|
-
before { subject.diff(actual_dsl).migrate }
|
74
|
-
subject { client }
|
75
|
-
|
76
|
-
it {
|
77
|
-
delta = subject.diff(expected_dsl)
|
78
|
-
expect(delta.differ?).to be_truthy
|
79
|
-
expect(subject.dump).to match_ruby actual_dsl
|
80
|
-
delta.migrate
|
81
|
-
expect(subject.dump).to match_ruby expected_dsl
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when default:0 -> default:0' do
|
86
|
-
let(:actual_dsl) do
|
87
|
-
erbh(<<-ERB)
|
88
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
89
|
-
t.integer "emp_no", default: 0, null: false
|
90
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
91
|
-
t.date "from_date", null: false
|
92
|
-
t.date "to_date", null: false
|
93
|
-
end
|
94
|
-
ERB
|
95
|
-
end
|
96
|
-
|
97
|
-
before { subject.diff(actual_dsl).migrate }
|
98
|
-
subject { client }
|
99
|
-
|
100
|
-
it {
|
101
|
-
delta = subject.diff(actual_dsl)
|
102
|
-
expect(delta.differ?).to be_falsey
|
103
|
-
}
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'when default:0 -> default:0/null:true' do
|
107
|
-
let(:actual_dsl) do
|
108
|
-
erbh(<<-ERB)
|
109
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
110
|
-
t.integer "emp_no", default: 0, null: false
|
111
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
112
|
-
t.date "from_date", null: false
|
113
|
-
t.date "to_date", null: false
|
114
|
-
end
|
115
|
-
ERB
|
116
|
-
end
|
117
|
-
|
118
|
-
let(:expected_dsl) do
|
119
|
-
erbh(<<-ERB)
|
120
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
121
|
-
t.integer "emp_no", limit: 4, default: 0, null: true
|
122
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
123
|
-
t.date "from_date", null: false
|
124
|
-
t.date "to_date", null: false
|
125
|
-
end
|
126
|
-
ERB
|
127
|
-
end
|
128
|
-
|
129
|
-
let(:result_dsl) do
|
130
|
-
erbh(<<-ERB)
|
131
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
132
|
-
t.integer "emp_no", default: 0
|
133
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
134
|
-
t.date "from_date", null: false
|
135
|
-
t.date "to_date", null: false
|
136
|
-
end
|
137
|
-
ERB
|
138
|
-
end
|
139
|
-
|
140
|
-
before { subject.diff(actual_dsl).migrate }
|
141
|
-
subject { client }
|
142
|
-
|
143
|
-
it {
|
144
|
-
delta = subject.diff(expected_dsl)
|
145
|
-
expect(delta.differ?).to be_truthy
|
146
|
-
expect(subject.dump).to match_ruby actual_dsl
|
147
|
-
delta.migrate
|
148
|
-
expect(subject.dump).to match_fuzzy result_dsl
|
149
|
-
}
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when default:0/null:true -> default:nil/null:false' do
|
153
|
-
let(:actual_dsl) do
|
154
|
-
erbh(<<-ERB)
|
155
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
156
|
-
t.integer "emp_no", default: 0
|
157
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
158
|
-
t.date "from_date", null: false
|
159
|
-
t.date "to_date", null: false
|
160
|
-
end
|
161
|
-
ERB
|
162
|
-
end
|
163
|
-
|
164
|
-
let(:expected_dsl) do
|
165
|
-
erbh(<<-ERB)
|
166
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
167
|
-
t.integer "emp_no", null: false
|
168
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
169
|
-
t.date "from_date", null: false
|
170
|
-
t.date "to_date", null: false
|
171
|
-
end
|
172
|
-
ERB
|
173
|
-
end
|
174
|
-
|
175
|
-
let(:result_dsl) do
|
176
|
-
erbh(<<-ERB)
|
177
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
178
|
-
t.integer "emp_no", null: false
|
179
|
-
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
180
|
-
t.date "from_date", null: false
|
181
|
-
t.date "to_date", null: false
|
182
|
-
end
|
183
|
-
ERB
|
184
|
-
end
|
185
|
-
|
186
|
-
before { subject.diff(actual_dsl).migrate }
|
187
|
-
subject { client }
|
188
|
-
|
189
|
-
it {
|
190
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
191
|
-
|
192
|
-
delta = subject.diff(expected_dsl)
|
193
|
-
expect(delta.differ?).to be_truthy
|
194
|
-
expect(subject.dump).to match_ruby actual_dsl
|
195
|
-
delta.migrate
|
196
|
-
expect(subject.dump).to match_fuzzy result_dsl
|
197
|
-
}
|
198
|
-
end
|
199
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change float column' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
8
|
-
t.integer "emp_no", null: false
|
9
|
-
t.float "salary", limit: 24, null: false
|
10
|
-
t.date "from_date", null: false
|
11
|
-
t.date "to_date", null: false
|
12
|
-
end
|
13
|
-
ERB
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:expected_dsl) do
|
17
|
-
<<-RUBY
|
18
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
19
|
-
t.integer "emp_no", null: false
|
20
|
-
t.float "salary", null: false
|
21
|
-
t.date "from_date", null: false
|
22
|
-
t.date "to_date", null: false
|
23
|
-
end
|
24
|
-
RUBY
|
25
|
-
end
|
26
|
-
|
27
|
-
before { subject.diff(actual_dsl).migrate }
|
28
|
-
subject { client(default_float_limit: 0) }
|
29
|
-
|
30
|
-
it {
|
31
|
-
delta = subject.diff(expected_dsl)
|
32
|
-
|
33
|
-
if condition('< 5.2.0.beta2')
|
34
|
-
expect(delta.differ?).to be_truthy
|
35
|
-
expect(subject.dump).to match_ruby actual_dsl
|
36
|
-
delta.migrate
|
37
|
-
expect(subject.dump).to match_ruby actual_dsl
|
38
|
-
else
|
39
|
-
expect(delta.differ?).to be_falsy
|
40
|
-
end
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when change float column (no change)' do
|
45
|
-
let(:actual_dsl) do
|
46
|
-
<<-RUBY
|
47
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
48
|
-
t.integer "emp_no", null: false
|
49
|
-
t.float "salary", limit: 24, null: false
|
50
|
-
t.date "from_date", null: false
|
51
|
-
t.date "to_date", null: false
|
52
|
-
end
|
53
|
-
RUBY
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:expected_dsl) do
|
57
|
-
<<-RUBY
|
58
|
-
create_table "salaries", id: false, force: :cascade do |t|
|
59
|
-
t.integer "emp_no", null: false
|
60
|
-
t.float "salary", null: false
|
61
|
-
t.date "from_date", null: false
|
62
|
-
t.date "to_date", null: false
|
63
|
-
end
|
64
|
-
RUBY
|
65
|
-
end
|
66
|
-
|
67
|
-
before { subject.diff(actual_dsl).migrate }
|
68
|
-
subject { client }
|
69
|
-
|
70
|
-
it {
|
71
|
-
delta = subject.diff(expected_dsl)
|
72
|
-
expect(delta.differ?).to be_falsey
|
73
|
-
}
|
74
|
-
end
|
75
|
-
end
|