ridgepole 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +4 -0
  3. data/CHANGELOG.md +238 -0
  4. data/README.md +12 -142
  5. data/bin/ridgepole +1 -1
  6. data/docker-compose.yml +26 -18
  7. data/gemfiles/activerecord_7.0.gemfile +7 -0
  8. data/lib/ridgepole/delta.rb +1 -1
  9. data/lib/ridgepole/diff.rb +4 -1
  10. data/lib/ridgepole/execute_expander.rb +5 -2
  11. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
  12. data/lib/ridgepole/version.rb +1 -1
  13. data/ridgepole.gemspec +8 -5
  14. metadata +10 -284
  15. data/.github/workflows/test.yml +0 -70
  16. data/.gitignore +0 -25
  17. data/spec/cli_helper.rb +0 -65
  18. data/spec/dsl_parser/context_spec.rb +0 -16
  19. data/spec/erb_helper.rb +0 -26
  20. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  21. data/spec/hide_pending_formatter.rb +0 -9
  22. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  23. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  24. data/spec/mysql/cli/config_spec.rb +0 -210
  25. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  26. data/spec/mysql/collation/collation_spec.rb +0 -153
  27. data/spec/mysql/comment/comment_spec.rb +0 -179
  28. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  29. data/spec/mysql/diff/diff2_spec.rb +0 -189
  30. data/spec/mysql/diff/diff_spec.rb +0 -168
  31. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  32. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  33. data/spec/mysql/dump/dump_spec.rb +0 -74
  34. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  35. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  36. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  37. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  38. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  39. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  40. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  41. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  42. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  43. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  44. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  45. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  46. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -231
  47. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  48. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  49. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  50. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  51. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  52. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  53. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
  54. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  55. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  56. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  57. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  58. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  59. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  60. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  61. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  62. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  63. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  64. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  65. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  66. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  67. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  68. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  69. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  70. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  71. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  72. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  73. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  74. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  75. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  76. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  77. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  78. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  79. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  80. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  81. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  82. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  83. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  84. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  85. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  86. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  87. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  88. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  89. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  90. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  91. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  92. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  93. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  94. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  95. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  96. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  97. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  98. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  99. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  100. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  101. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  102. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  103. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  104. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  105. data/spec/mysql/ridgepole_test_database.sql +0 -2
  106. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  107. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  108. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  109. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  110. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  111. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  112. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  113. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  114. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  115. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  116. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  117. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  118. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  119. data/spec/postgresql/diff/diff_spec.rb +0 -216
  120. data/spec/postgresql/dump/dump_spec.rb +0 -69
  121. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  122. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  123. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  124. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  125. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  126. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  127. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  128. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  129. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  130. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  131. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  132. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  133. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  134. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  135. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  136. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  137. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  138. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  139. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  140. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  141. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  142. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  143. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  144. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  145. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  146. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  147. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  148. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  149. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  150. data/spec/processing_for_ci.rb +0 -13
  151. data/spec/spec_condition.rb +0 -58
  152. data/spec/spec_const.rb +0 -20
  153. data/spec/spec_helper.rb +0 -173
@@ -1,307 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when with ignore tables option (same)' do
5
- let(:current_schema) do
6
- <<-RUBY
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
- end
14
-
15
- create_table "salaries", id: false, force: :cascade do |t|
16
- t.integer "emp_no", null: false
17
- t.integer "salary", null: false
18
- t.date "from_date", null: false
19
- t.date "to_date", null: false
20
- end
21
-
22
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
23
- RUBY
24
- end
25
-
26
- let(:dsl) do
27
- <<-RUBY
28
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
29
- t.date "birth_date", null: false
30
- t.string "first_name", limit: 14, null: false
31
- t.string "last_name", limit: 16, null: false
32
- t.string "gender", limit: 1, null: false
33
- t.date "hire_date", null: false
34
- end
35
-
36
- create_table "salaries", id: false, force: :cascade do |t|
37
- t.integer "emp_no", null: false
38
- t.integer "salary", null: false
39
- t.date "from_date", null: false
40
- t.date "to_date", null: false
41
- end
42
-
43
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
44
- RUBY
45
- end
46
-
47
- let(:expected_dsl) do
48
- <<-RUBY
49
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
50
- t.date "birth_date", null: false
51
- t.string "first_name", limit: 14, null: false
52
- t.string "last_name", limit: 16, null: false
53
- t.string "gender", limit: 1, null: false
54
- t.date "hire_date", null: false
55
- end
56
- RUBY
57
- end
58
-
59
- before { subject.diff(current_schema).migrate }
60
- subject { client(ignore_tables: [/^salaries$/]) }
61
-
62
- it {
63
- delta = subject.diff(dsl)
64
- expect(delta.differ?).to be_falsey
65
- expect(subject.dump).to match_ruby expected_dsl
66
- delta.migrate
67
- expect(subject.dump).to match_ruby expected_dsl
68
- }
69
- end
70
-
71
- context 'when with ignore tables option (differ)' do
72
- let(:current_schema) do
73
- <<-RUBY
74
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
75
- t.date "birth_date", null: false
76
- t.string "first_name", limit: 14, null: false
77
- t.string "last_name", limit: 16, null: false
78
- t.string "gender", limit: 1, null: false
79
- t.date "hire_date", null: false
80
- end
81
-
82
- create_table "salaries", id: false, force: :cascade do |t|
83
- t.integer "emp_no", null: false
84
- t.integer "salary", null: false
85
- t.date "from_date", null: false
86
- t.date "to_date", null: false
87
- end
88
-
89
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
90
- RUBY
91
- end
92
-
93
- let(:dsl) do
94
- <<-RUBY
95
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
96
- t.date "birth_date", null: false
97
- t.string "first_name", limit: 15, null: false
98
- t.string "last_name", limit: 16, null: false
99
- t.string "gender", limit: 1, null: false
100
- t.date "hire_date", null: false
101
- end
102
-
103
- create_table "salaries", id: false, force: :cascade do |t|
104
- t.integer "emp_no", null: false
105
- t.integer "salary", null: false
106
- t.date "from_date", null: false
107
- t.date "to_date", null: false
108
- end
109
-
110
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
111
- RUBY
112
- end
113
-
114
- let(:before_dsl) do
115
- <<-RUBY
116
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
117
- t.date "birth_date", null: false
118
- t.string "first_name", limit: 14, null: false
119
- t.string "last_name", limit: 16, null: false
120
- t.string "gender", limit: 1, null: false
121
- t.date "hire_date", null: false
122
- end
123
- RUBY
124
- end
125
-
126
- let(:after_dsl) do
127
- <<-RUBY
128
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
129
- t.date "birth_date", null: false
130
- t.string "first_name", limit: 15, null: false
131
- t.string "last_name", limit: 16, null: false
132
- t.string "gender", limit: 1, null: false
133
- t.date "hire_date", null: false
134
- end
135
- RUBY
136
- end
137
-
138
- before { subject.diff(current_schema).migrate }
139
- subject { client(ignore_tables: [/^salaries$/]) }
140
-
141
- it {
142
- delta = subject.diff(dsl)
143
- expect(delta.differ?).to be_truthy
144
- expect(subject.dump).to match_fuzzy before_dsl
145
- delta.migrate
146
- expect(subject.dump).to match_fuzzy after_dsl
147
- }
148
- end
149
-
150
- context 'when with ignore tables option (target and ignore)' do
151
- let(:current_schema) do
152
- <<-RUBY
153
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
154
- t.date "birth_date", null: false
155
- t.string "first_name", limit: 14, null: false
156
- t.string "last_name", limit: 16, null: false
157
- t.string "gender", limit: 1, null: false
158
- t.date "hire_date", null: false
159
- end
160
-
161
- create_table "salaries", id: false, force: :cascade do |t|
162
- t.integer "emp_no", null: false
163
- t.integer "salary", null: false
164
- t.date "from_date", null: false
165
- t.date "to_date", null: false
166
- end
167
-
168
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
169
- RUBY
170
- end
171
-
172
- let(:dsl) do
173
- <<-RUBY
174
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
175
- t.date "birth_date", null: false
176
- t.string "first_name", limit: 15, null: false
177
- t.string "last_name", limit: 16, null: false
178
- t.string "gender", limit: 1, null: false
179
- t.date "hire_date", null: false
180
- end
181
-
182
- create_table "salaries", id: false, force: :cascade do |t|
183
- t.integer "emp_no", null: false
184
- t.integer "salary", null: false
185
- t.date "from_date", null: false
186
- t.date "to_date", null: false
187
- end
188
-
189
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
190
- RUBY
191
- end
192
-
193
- let(:before_dsl) do
194
- <<-RUBY
195
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
196
- t.date "birth_date", null: false
197
- t.string "first_name", limit: 14, null: false
198
- t.string "last_name", limit: 16, null: false
199
- t.string "gender", limit: 1, null: false
200
- t.date "hire_date", null: false
201
- end
202
- RUBY
203
- end
204
-
205
- let(:after_dsl) do
206
- <<-RUBY
207
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
208
- t.date "birth_date", null: false
209
- t.string "first_name", limit: 15, null: false
210
- t.string "last_name", limit: 16, null: false
211
- t.string "gender", limit: 1, null: false
212
- t.date "hire_date", null: false
213
- end
214
- RUBY
215
- end
216
-
217
- before { subject.diff(current_schema).migrate }
218
- subject { client(tables: ['employees'], ignore_tables: [/^.+$/]) }
219
-
220
- it {
221
- delta = subject.diff(dsl)
222
- expect(delta.differ?).to be_truthy
223
- expect(subject.dump).to match_fuzzy before_dsl
224
- delta.migrate
225
- expect(subject.dump).to match_fuzzy after_dsl
226
- }
227
- end
228
-
229
- context 'when with ignore tables option (target)' do
230
- let(:current_schema) do
231
- <<-RUBY
232
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
233
- t.date "birth_date", null: false
234
- t.string "first_name", limit: 14, null: false
235
- t.string "last_name", limit: 16, null: false
236
- t.string "gender", limit: 1, null: false
237
- t.date "hire_date", null: false
238
- end
239
-
240
- create_table "salaries", id: false, force: :cascade do |t|
241
- t.integer "emp_no", null: false
242
- t.integer "salary", null: false
243
- t.date "from_date", null: false
244
- t.date "to_date", null: false
245
- end
246
-
247
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
248
- RUBY
249
- end
250
-
251
- let(:dsl) do
252
- <<-RUBY
253
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
254
- t.date "birth_date", null: false
255
- t.string "first_name", limit: 15, null: false
256
- t.string "last_name", limit: 16, null: false
257
- t.string "gender", limit: 1, null: false
258
- t.date "hire_date", null: false
259
- end
260
-
261
- create_table "salaries", id: false, force: :cascade do |t|
262
- t.integer "emp_no", null: false
263
- t.integer "salary", null: false
264
- t.date "from_date", null: false
265
- t.date "to_date", null: false
266
- end
267
-
268
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
269
- RUBY
270
- end
271
-
272
- let(:before_dsl) do
273
- <<-RUBY
274
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
275
- t.date "birth_date", null: false
276
- t.string "first_name", limit: 14, null: false
277
- t.string "last_name", limit: 16, null: false
278
- t.string "gender", limit: 1, null: false
279
- t.date "hire_date", null: false
280
- end
281
- RUBY
282
- end
283
-
284
- let(:after_dsl) do
285
- <<-RUBY
286
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
287
- t.date "birth_date", null: false
288
- t.string "first_name", limit: 15, null: false
289
- t.string "last_name", limit: 16, null: false
290
- t.string "gender", limit: 1, null: false
291
- t.date "hire_date", null: false
292
- end
293
- RUBY
294
- end
295
-
296
- before { subject.diff(current_schema).migrate }
297
- subject { client(tables: ['employees']) }
298
-
299
- it {
300
- delta = subject.diff(dsl)
301
- expect(delta.differ?).to be_truthy
302
- expect(subject.dump).to match_fuzzy before_dsl
303
- delta.migrate
304
- expect(subject.dump).to match_fuzzy after_dsl
305
- }
306
- end
307
- end
@@ -1,153 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'migrate with pre/post query' do
5
- let(:actual_dsl) { '' }
6
- let(:dsl) do
7
- erbh(<<-ERB)
8
- create_table "clubs", force: :cascade do |t|
9
- t.string "name", default: "", null: false
10
- t.index ["name"], name: "idx_name", unique: true
11
- end
12
-
13
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
14
- t.string "dept_name", limit: 40, null: false
15
- t.index ["dept_name"], name: "dept_name", unique: true
16
- end
17
-
18
- create_table "dept_emp", id: false, force: :cascade do |t|
19
- t.integer "emp_no", null: false
20
- t.string "dept_no", null: false
21
- t.date "from_date", null: false
22
- t.date "to_date", null: false
23
- t.index ["dept_no"], name: "dept_no"
24
- t.index ["emp_no"], name: "emp_no"
25
- end
26
-
27
- create_table "dept_manager", id: false, force: :cascade do |t|
28
- t.string "dept_no", null: false
29
- t.integer "emp_no", null: false
30
- t.date "from_date", null: false
31
- t.date "to_date", null: false
32
- t.index ["dept_no"], name: "dept_no"
33
- t.index ["emp_no"], name: "emp_no"
34
- end
35
-
36
- create_table "employee_clubs", force: :cascade do |t|
37
- t.integer "emp_no", null: false
38
- t.integer "club_id", null: false
39
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
40
- end
41
-
42
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
43
- t.date "birth_date", null: false
44
- t.string "first_name", limit: 14, null: false
45
- t.string "last_name", limit: 16, null: false
46
- t.string "gender", limit: 1, null: false
47
- t.date "hire_date", null: false
48
- end
49
-
50
- create_table "salaries", id: false, force: :cascade do |t|
51
- t.integer "emp_no", null: false
52
- t.integer "salary", null: false
53
- t.date "from_date", null: false
54
- t.date "to_date", null: false
55
- t.index ["emp_no"], name: "emp_no"
56
- end
57
-
58
- create_table "titles", id: false, force: :cascade do |t|
59
- t.integer "emp_no", null: false
60
- t.string "title", limit: 50, null: false
61
- t.date "from_date", null: false
62
- t.date "to_date"
63
- t.index ["emp_no"], name: "emp_no"
64
- end
65
- ERB
66
- end
67
-
68
- let(:expected_dsl) do
69
- erbh(<<-ERB)
70
- create_table "clubs", force: :cascade do |t|
71
- t.string "name", default: "", null: false
72
- t.index ["name"], name: "idx_name", unique: true
73
- end
74
-
75
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
76
- t.string "dept_name", limit: 40, null: false
77
- t.index ["dept_name"], name: "dept_name", unique: true
78
- end
79
-
80
- create_table "dept_emp", id: false, force: :cascade do |t|
81
- t.integer "emp_no", null: false
82
- t.string "dept_no", null: false
83
- t.date "from_date", null: false
84
- t.date "to_date", null: false
85
- t.index ["dept_no"], name: "dept_no"
86
- t.index ["emp_no"], name: "emp_no"
87
- end
88
-
89
- create_table "dept_manager", id: false, force: :cascade do |t|
90
- t.string "dept_no", null: false
91
- t.integer "emp_no", null: false
92
- t.date "from_date", null: false
93
- t.date "to_date", null: false
94
- t.index ["dept_no"], name: "dept_no"
95
- t.index ["emp_no"], name: "emp_no"
96
- end
97
-
98
- create_table "employee_clubs", force: :cascade do |t|
99
- t.integer "emp_no", null: false
100
- t.integer "club_id", null: false
101
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
102
- end
103
-
104
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
105
- t.date "birth_date", null: false
106
- t.string "first_name", limit: 14, null: false
107
- t.string "last_name", limit: 16, null: false
108
- t.string "gender", limit: 1, null: false
109
- t.date "hire_date", null: false
110
- end
111
-
112
- create_table "post", id: false, force: :cascade do |t|
113
- t.integer "id"
114
- end
115
-
116
- create_table "pre", id: false, force: :cascade do |t|
117
- t.integer "id"
118
- end
119
-
120
- create_table "salaries", id: false, force: :cascade do |t|
121
- t.integer "emp_no", null: false
122
- t.integer "salary", null: false
123
- t.date "from_date", null: false
124
- t.date "to_date", null: false
125
- t.index ["emp_no"], name: "emp_no"
126
- end
127
-
128
- create_table "titles", id: false, force: :cascade do |t|
129
- t.integer "emp_no", null: false
130
- t.string "title", limit: 50, null: false
131
- t.date "from_date", null: false
132
- t.date "to_date"
133
- t.index ["emp_no"], name: "emp_no"
134
- end
135
- ERB
136
- end
137
-
138
- subject do
139
- client(
140
- pre_query: 'create table pre (id int)',
141
- post_query: 'create table post (id int)'
142
- )
143
- end
144
-
145
- it {
146
- delta = subject.diff(dsl)
147
- expect(delta.differ?).to be_truthy
148
- expect(subject.dump).to match_ruby actual_dsl
149
- delta.migrate
150
- expect(subject.dump).to match_ruby expected_dsl
151
- }
152
- end
153
- end
@@ -1,149 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when with tables option (same)' do
5
- let(:current_schema) do
6
- <<-RUBY
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
- end
14
-
15
- create_table "salaries", id: false, force: :cascade do |t|
16
- t.integer "emp_no", null: false
17
- t.integer "salary", null: false
18
- t.date "from_date", null: false
19
- t.date "to_date", null: false
20
- end
21
-
22
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
23
- RUBY
24
- end
25
-
26
- let(:dsl) do
27
- <<-RUBY
28
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
29
- t.date "birth_date", null: false
30
- t.string "first_name", limit: 14, null: false
31
- t.string "last_name", limit: 16, null: false
32
- t.string "gender", limit: 1, null: false
33
- t.date "hire_date", null: false
34
- end
35
-
36
- create_table "salaries", id: false, force: :cascade do |t|
37
- t.integer "emp_no", null: false
38
- t.integer "salary", null: false
39
- t.date "from_date", null: false
40
- t.date "to_date", null: false
41
- end
42
-
43
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
44
- RUBY
45
- end
46
-
47
- let(:expected_dsl) do
48
- <<-RUBY
49
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
50
- t.date "birth_date", null: false
51
- t.string "first_name", limit: 14, null: false
52
- t.string "last_name", limit: 16, null: false
53
- t.string "gender", limit: 1, null: false
54
- t.date "hire_date", null: false
55
- end
56
- RUBY
57
- end
58
-
59
- before { subject.diff(current_schema).migrate }
60
- subject { client(tables: ['employees']) }
61
-
62
- it {
63
- delta = subject.diff(dsl)
64
- expect(delta.differ?).to be_falsey
65
- expect(subject.dump).to match_ruby expected_dsl
66
- delta.migrate
67
- expect(subject.dump).to match_ruby expected_dsl
68
- }
69
- end
70
-
71
- context 'when with tables option (differ)' do
72
- let(:current_schema) do
73
- <<-RUBY
74
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
75
- t.date "birth_date", null: false
76
- t.string "first_name", limit: 14, null: false
77
- t.string "last_name", limit: 16, null: false
78
- t.string "gender", limit: 1, null: false
79
- t.date "hire_date", null: false
80
- end
81
-
82
- create_table "salaries", id: false, force: :cascade do |t|
83
- t.integer "emp_no", null: false
84
- t.integer "salary", null: false
85
- t.date "from_date", null: false
86
- t.date "to_date", null: false
87
- end
88
-
89
- add_index "salaries", ["salary"], name: "emp_no", using: :btree
90
- RUBY
91
- end
92
-
93
- let(:dsl) do
94
- <<-RUBY
95
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
96
- t.date "birth_date", null: false
97
- t.string "first_name", limit: 15, null: false
98
- t.string "last_name", limit: 16, null: false
99
- t.string "gender", limit: 1, null: false
100
- t.date "hire_date", null: false
101
- end
102
-
103
- create_table "salaries", id: false, force: :cascade do |t|
104
- t.integer "emp_no", null: false
105
- t.integer "salary", null: false
106
- t.date "from_date", null: false
107
- t.date "to_date", null: false
108
- end
109
-
110
- add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
111
- RUBY
112
- end
113
-
114
- let(:before_dsl) do
115
- <<-RUBY
116
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
117
- t.date "birth_date", null: false
118
- t.string "first_name", limit: 14, null: false
119
- t.string "last_name", limit: 16, null: false
120
- t.string "gender", limit: 1, null: false
121
- t.date "hire_date", null: false
122
- end
123
- RUBY
124
- end
125
-
126
- let(:after_dsl) do
127
- <<-RUBY
128
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
129
- t.date "birth_date", null: false
130
- t.string "first_name", limit: 15, null: false
131
- t.string "last_name", limit: 16, null: false
132
- t.string "gender", limit: 1, null: false
133
- t.date "hire_date", null: false
134
- end
135
- RUBY
136
- end
137
-
138
- before { subject.diff(current_schema).migrate }
139
- subject { client(tables: ['employees']) }
140
-
141
- it {
142
- delta = subject.diff(dsl)
143
- expect(delta.differ?).to be_truthy
144
- expect(subject.dump).to match_fuzzy before_dsl
145
- delta.migrate
146
- expect(subject.dump).to match_fuzzy after_dsl
147
- }
148
- end
149
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'with verbose log' 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
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
20
- t.date "birth_date", null: false
21
- t.string "first_name", limit: 14, null: false
22
- t.string "last_name", limit: 16, null: false
23
- t.string "gender2", limit: 1, null: false
24
- t.date "hire_date", null: false
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- verbose_infos = []
34
- allow(Ridgepole::Logger.instance).to receive(:verbose_info) { |m| verbose_infos << m }
35
-
36
- Ridgepole::Logger.verbose = true
37
- delta = subject.diff(expected_dsl)
38
- expect(delta.differ?).to be_truthy
39
- expect(subject.dump).to match_ruby actual_dsl
40
- delta.migrate
41
- expect(subject.dump).to match_ruby expected_dsl
42
- Ridgepole::Logger.verbose = false
43
-
44
- expected_verbose_infos = [
45
- '# Parse DSL',
46
- '# Load tables',
47
- '# employees',
48
- '# Compare definitions',
49
- '# employees',
50
- " {:definition=>\n {\"birth_date\"=>{:options=>{:null=>false}, :type=>:date},\n \"first_name\"=>{:options=>{:limit=>14, :null=>false}, :type=>:string},\n- \"gender\"=>{:options=>{:limit=>1, :null=>false}, :type=>:string},\n+ \"gender2\"=>{:options=>{:limit=>1, :null=>false}, :type=>:string},\n \"hire_date\"=>{:options=>{:null=>false}, :type=>:date},\n \"last_name\"=>{:options=>{:limit=>16, :null=>false}, :type=>:string}},\n :options=>{:primary_key=>\"emp_no\"}}",
51
- '# Load tables',
52
- '# employees',
53
- '# Load tables',
54
- '# employees'
55
- ]
56
-
57
- expect(verbose_infos).to match_array expected_verbose_infos
58
- }
59
- end
60
- end
@@ -1,2 +0,0 @@
1
- DROP DATABASE IF EXISTS `ridgepole_test`;
2
- CREATE DATABASE `ridgepole_test` DEFAULT CHARACTER SET utf8;