ridgepole 0.9.2 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/lib/ridgepole/delta.rb +1 -1
  4. data/lib/ridgepole/diff.rb +7 -3
  5. data/lib/ridgepole/execute_expander.rb +1 -1
  6. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
  7. data/lib/ridgepole/version.rb +1 -1
  8. data/ridgepole.gemspec +7 -4
  9. metadata +6 -282
  10. data/.github/workflows/test.yml +0 -70
  11. data/.gitignore +0 -25
  12. data/spec/cli_helper.rb +0 -65
  13. data/spec/dsl_parser/context_spec.rb +0 -16
  14. data/spec/erb_helper.rb +0 -26
  15. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  16. data/spec/hide_pending_formatter.rb +0 -9
  17. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  18. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  19. data/spec/mysql/cli/config_spec.rb +0 -210
  20. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  21. data/spec/mysql/collation/collation_spec.rb +0 -153
  22. data/spec/mysql/comment/comment_spec.rb +0 -179
  23. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  24. data/spec/mysql/diff/diff2_spec.rb +0 -189
  25. data/spec/mysql/diff/diff_spec.rb +0 -168
  26. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  27. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  28. data/spec/mysql/dump/dump_spec.rb +0 -74
  29. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  30. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  31. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  32. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  33. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  34. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  35. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  36. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  37. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  38. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  39. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  40. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  41. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -231
  42. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  43. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  44. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  45. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  46. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  47. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  48. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -25
  49. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  50. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  51. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  52. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  53. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  54. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  55. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  56. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  57. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  58. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  59. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  60. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  61. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  62. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  63. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  64. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  65. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  66. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  67. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  68. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  69. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  70. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  71. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  72. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  73. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  74. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  75. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  76. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  77. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  78. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  79. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  80. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  81. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  82. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  83. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  84. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  85. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  86. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  87. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  88. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  89. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  90. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  91. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  92. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  93. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  94. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  95. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  96. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  97. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  98. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  99. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  100. data/spec/mysql/ridgepole_test_database.sql +0 -2
  101. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  102. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  103. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  104. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  105. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  106. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  107. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  108. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  109. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  110. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  111. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  112. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  113. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  114. data/spec/postgresql/diff/diff_spec.rb +0 -216
  115. data/spec/postgresql/dump/dump_spec.rb +0 -69
  116. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  117. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  118. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  119. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  120. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  121. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  122. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  123. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  124. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  125. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  126. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  127. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  128. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  129. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  130. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  131. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  132. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  133. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  134. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  135. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  136. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  137. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  138. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  139. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  140. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  141. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  142. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  143. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  144. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  145. data/spec/processing_for_ci.rb +0 -13
  146. data/spec/spec_condition.rb +0 -58
  147. data/spec/spec_const.rb +0 -20
  148. data/spec/spec_helper.rb +0 -173
@@ -1,447 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'ridgepole' do
4
- let(:differ) { false }
5
- let(:conf) { "'" + JSON.dump(conn_spec) + "'" }
6
-
7
- def conn_spec_str(database)
8
- ActiveSupport::HashWithIndifferentAccess.new(conn_spec(database: database)).inspect
9
- end
10
-
11
- context 'when help' do
12
- specify do
13
- out, status = run_cli(args: ['-h'])
14
- out = out.gsub(/Usage: .*\n/, '')
15
-
16
- expect(status.success?).to be_truthy
17
- expect(out).to match_fuzzy <<-MSG
18
- -c, --config CONF_OR_FILE
19
- -E, --env ENVIRONMENT
20
- -s, --spec-name SPEC_NAME
21
- -a, --apply
22
- -m, --merge
23
- -f, --file SCHEMAFILE
24
- --dry-run
25
- --table-options OPTIONS
26
- --table-hash-options OPTIONS
27
- --alter-extra ALTER_SPEC
28
- --external-script SCRIPT
29
- --bulk-change
30
- --default-bool-limit LIMIT
31
- --default-int-limit LIMIT
32
- --default-bigint-limit LIMIT
33
- --default-float-limit LIMIT
34
- --default-string-limit LIMIT
35
- --default-text-limit LIMIT
36
- --default-binary-limit LIMIT
37
- --pre-query QUERY
38
- --post-query QUERY
39
- -e, --export
40
- --split
41
- --split-with-dir
42
- -d, --diff DSL1 DSL2
43
- --with-apply
44
- -o, --output SCHEMAFILE
45
- -t, --tables TABLES
46
- --ignore-tables REGEX_LIST
47
- --dump-without-table-options
48
- --dump-with-default-fk-name
49
- --index-removed-drop-column
50
- --skip-drop-table
51
- --mysql-change-table-options
52
- --mysql-change-table-comment
53
- --check-relation-type DEF_PK
54
- --ignore-table-comment
55
- --skip-column-comment-change
56
- --allow-pk-change
57
- --create-table-with-index
58
- --mysql-dump-auto-increment
59
- -r, --require LIBS
60
- --log-file LOG_FILE
61
- --verbose
62
- --debug
63
- --[no-]color
64
- -v, --version
65
- MSG
66
- end
67
- end
68
-
69
- context 'when export' do
70
- specify 'not split' do
71
- out, status = run_cli(args: ['-c', conf, '-e', conf, conf])
72
-
73
- expect(status.success?).to be_truthy
74
- expect(out).to match_fuzzy <<-MSG
75
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
76
- # Export Schema
77
- Ridgepole::Client#dump
78
- MSG
79
- end
80
-
81
- specify 'not split with outfile' do
82
- Tempfile.open("#{File.basename __FILE__}.#{$PROCESS_ID}") do |f|
83
- out, status = run_cli(args: ['-c', conf, '-e', '-o', f.path])
84
-
85
- expect(status.success?).to be_truthy
86
- expect(out).to match_fuzzy <<-MSG
87
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
88
- Export Schema to `#{f.path}`
89
- Ridgepole::Client#dump
90
- MSG
91
- end
92
- end
93
-
94
- specify 'not split with output stdout' do
95
- out, status = run_cli(args: ['-c', conf, '-e', '-o', '-'])
96
-
97
- expect(status.success?).to be_truthy
98
- expect(out).to match_fuzzy <<-MSG
99
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
100
- # Export Schema
101
- Ridgepole::Client#dump
102
- MSG
103
- end
104
-
105
- specify 'split' do
106
- out, status = run_cli(args: ['-c', conf, '-e', '--split'])
107
-
108
- expect(status.success?).to be_truthy
109
- expect(out).to match_fuzzy <<-MSG
110
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
111
- Export Schema
112
- Ridgepole::Client#dump
113
- write `Schemafile`
114
- MSG
115
- end
116
-
117
- specify 'split with outdir' do
118
- Tempfile.open("#{File.basename __FILE__}.#{$PROCESS_ID}") do |f|
119
- out, status = run_cli(args: ['-c', conf, '-e', '--split', '-o', f.path, conf, conf])
120
-
121
- expect(status.success?).to be_truthy
122
- expect(out).to match_fuzzy <<-MSG
123
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
124
- Export Schema
125
- Ridgepole::Client#dump
126
- write `#{f.path}`
127
- MSG
128
- end
129
- end
130
- end
131
-
132
- context 'when apply' do
133
- specify 'apply' do
134
- out, status = run_cli(args: ['-c', conf, '-a'])
135
-
136
- expect(status.success?).to be_truthy
137
- expect(out).to match_fuzzy <<-MSG
138
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
139
- Apply `Schemafile`
140
- Ridgepole::Client#diff
141
- Ridgepole::Delta#differ?
142
- Ridgepole::Delta#migrate
143
- No change
144
- MSG
145
- end
146
-
147
- specify 'apply with conf file' do
148
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
149
- conf_file.puts <<-YAML
150
- adapter: mysql2
151
- database: ridgepole_test_for_conf_file
152
- YAML
153
- conf_file.flush
154
-
155
- out, status = run_cli(args: ['-c', conf_file.path, '-a', '--debug'])
156
-
157
- expect(status.success?).to be_truthy
158
- expect(out).to match_fuzzy <<-MSG
159
- Ridgepole::Client#initialize([{"adapter"=>"mysql2", "database"=>"ridgepole_test_for_conf_file"}, {:dry_run=>false, :debug=>true, :color=>false}])
160
- Apply `Schemafile`
161
- Ridgepole::Client#diff
162
- Ridgepole::Delta#differ?
163
- Ridgepole::Delta#migrate
164
- No change
165
- MSG
166
- end
167
- end
168
-
169
- specify 'apply with conf file (production)' do
170
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
171
- conf_file.puts <<-YAML
172
- development:
173
- adapter: mysql2
174
- database: ridgepole_development
175
- production:
176
- adapter: mysql2
177
- database: ridgepole_production
178
- YAML
179
- conf_file.flush
180
-
181
- out, status = run_cli(args: ['-c', conf_file.path, '-a', '--debug'])
182
-
183
- expect(status.success?).to be_truthy
184
- expect(out).to match_fuzzy <<-MSG
185
- Ridgepole::Client#initialize([{"adapter"=>"mysql2", "database"=>"ridgepole_development"}, {:dry_run=>false, :debug=>true, :color=>false}])
186
- Apply `Schemafile`
187
- Ridgepole::Client#diff
188
- Ridgepole::Delta#differ?
189
- Ridgepole::Delta#migrate
190
- No change
191
- MSG
192
- end
193
- end
194
-
195
- context 'apply with --table-hash-options' do
196
- context 'given flatten json' do
197
- it 'parses string to hash' do
198
- out, status = run_cli(args: ['-c', conf, '-a', '--table-hash-options', %('{ id: "bigint", unsigned: true }')])
199
-
200
- expect(status.success?).to be_truthy
201
- expect(out).to match_fuzzy <<-MSG
202
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false, :table_hash_options=>{:id=>:bigint, :unsigned=>true}}])
203
- Apply `Schemafile`
204
- Ridgepole::Client#diff
205
- Ridgepole::Delta#differ?
206
- Ridgepole::Delta#migrate
207
- No change
208
- MSG
209
- end
210
- end
211
-
212
- context 'given nested json' do
213
- it 'parses string to nested hash' do
214
- out, status = run_cli(args: ['-c', conf, '-a', '--table-hash-options', %('id: { type: "bigint", unsigned: true }')])
215
-
216
- expect(status.success?).to be_truthy
217
- expect(out).to match_fuzzy <<-MSG
218
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false, :table_hash_options=>{:id=>{:type=>:bigint, :unsigned=>true}}}])
219
- Apply `Schemafile`
220
- Ridgepole::Client#diff
221
- Ridgepole::Delta#differ?
222
- Ridgepole::Delta#migrate
223
- No change
224
- MSG
225
- end
226
- end
227
- end
228
-
229
- specify 'dry-run' do
230
- out, status = run_cli(args: ['-c', conf, '-a', '--dry-run'])
231
-
232
- expect(status.success?).to be_truthy
233
- expect(out).to match_fuzzy <<-MSG
234
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>true, :debug=>false, :color=>false}])
235
- Apply `Schemafile` (dry-run)
236
- Ridgepole::Client#diff
237
- Ridgepole::Delta#differ?
238
- No change
239
- MSG
240
- end
241
-
242
- context 'when differ true' do
243
- let(:differ) { true }
244
-
245
- specify 'apply' do
246
- out, status = run_cli(args: ['-c', conf, '-a'])
247
-
248
- expect(status.success?).to be_truthy
249
- expect(out).to match_fuzzy <<-MSG
250
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
251
- Apply `Schemafile`
252
- Ridgepole::Client#diff
253
- Ridgepole::Delta#differ?
254
- Ridgepole::Delta#migrate
255
- MSG
256
- end
257
-
258
- specify 'dry-run' do
259
- out, status = run_cli(args: ['-c', conf, '-a', '--dry-run'])
260
-
261
- expect(status.success?).to be_truthy
262
- expect(out).to match_fuzzy <<-MSG
263
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>true, :debug=>false, :color=>false}])
264
- Apply `Schemafile` (dry-run)
265
- Ridgepole::Client#diff
266
- Ridgepole::Delta#differ?
267
- Ridgepole::Delta#script
268
- Ridgepole::Delta#script
269
- create_table :table do
270
- end
271
-
272
- Ridgepole::Delta#migrate
273
- # create_table :table do
274
- # end
275
- MSG
276
- end
277
- end
278
- end
279
-
280
- context 'when diff' do
281
- specify do
282
- out, status = run_cli(args: ['-c', conf, '-d', conf, conf])
283
-
284
- expect(status.success?).to be_truthy
285
- expect(out).to match_fuzzy <<-MSG
286
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
287
- Ridgepole::Client.diff([#{conn_spec_str('ridgepole_test')}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
288
- Ridgepole::Delta#differ?
289
- MSG
290
- end
291
-
292
- context 'when differ true' do
293
- let(:differ) { true }
294
-
295
- specify do
296
- out, status = run_cli(args: ['-c', conf, '-d', conf, conf])
297
-
298
- # Exit code 1 if there is a difference
299
- expect(status.success?).to be_falsey
300
-
301
- expect(out).to match_fuzzy <<-MSG
302
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
303
- Ridgepole::Client.diff([#{conn_spec_str('ridgepole_test')}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
304
- Ridgepole::Delta#differ?
305
- Ridgepole::Delta#script
306
- Ridgepole::Delta#script
307
- create_table :table do
308
- end
309
-
310
- Ridgepole::Delta#migrate
311
- # create_table :table do
312
- # end
313
- MSG
314
- end
315
- end
316
-
317
- context 'when config file' do
318
- specify '.yml' do
319
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
320
- conf_file.puts <<-YAML
321
- adapter: mysql2
322
- database: ridgepole_test_for_conf_file
323
- YAML
324
- conf_file.flush
325
-
326
- out, status = run_cli(args: ['-c', conf, '-d', conf_file.path, conf])
327
-
328
- expect(status.success?).to be_truthy
329
-
330
- expect(out).to match_fuzzy <<-MSG
331
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
332
- Ridgepole::Client.diff([{"adapter"=>"mysql2", "database"=>"ridgepole_test_for_conf_file"}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
333
- Ridgepole::Delta#differ?
334
- MSG
335
- end
336
- end
337
-
338
- specify '.yml (file2)' do
339
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
340
- conf_file.puts <<-YAML
341
- adapter: mysql2
342
- database: ridgepole_test_for_conf_file
343
- YAML
344
- conf_file.flush
345
-
346
- out, status = run_cli(args: ['-c', conf, '-d', conf, conf_file.path])
347
-
348
- expect(status.success?).to be_truthy
349
-
350
- expect(out).to match_fuzzy <<-MSG
351
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
352
- Ridgepole::Client.diff([#{conn_spec_str('ridgepole_test')}, {"adapter"=>"mysql2", "database"=>"ridgepole_test_for_conf_file"}, {:dry_run=>false, :debug=>false, :color=>false}])
353
- Ridgepole::Delta#differ?
354
- MSG
355
- end
356
- end
357
-
358
- specify '.yml (development)' do
359
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
360
- conf_file.puts <<-YAML
361
- development:
362
- adapter: mysql2
363
- database: ridgepole_development
364
- production:
365
- adapter: mysql2
366
- database: ridgepole_production
367
- YAML
368
- conf_file.flush
369
-
370
- out, status = run_cli(args: ['-c', conf, '-d', conf_file.path, conf])
371
-
372
- expect(status.success?).to be_truthy
373
-
374
- expect(out).to match_fuzzy <<-MSG
375
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
376
- Ridgepole::Client.diff([{"adapter"=>"mysql2", "database"=>"ridgepole_development"}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
377
- Ridgepole::Delta#differ?
378
- MSG
379
- end
380
- end
381
-
382
- specify '.yml (production)' do
383
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yml']) do |conf_file|
384
- conf_file.puts <<-YAML
385
- development:
386
- adapter: mysql2
387
- database: ridgepole_development
388
- production:
389
- adapter: mysql2
390
- database: ridgepole_production
391
- YAML
392
- conf_file.flush
393
-
394
- out, status = run_cli(args: ['-c', conf, '-d', conf_file.path, conf, '-E', :production])
395
-
396
- expect(status.success?).to be_truthy
397
-
398
- expect(out).to match_fuzzy <<-MSG
399
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
400
- Ridgepole::Client.diff([{"adapter"=>"mysql2", "database"=>"ridgepole_production"}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
401
- Ridgepole::Delta#differ?
402
- MSG
403
- end
404
- end
405
-
406
- specify '.yaml' do
407
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.yaml']) do |conf_file|
408
- conf_file.puts <<-YAML
409
- adapter: mysql2
410
- database: ridgepole_test_for_conf_file
411
- YAML
412
- conf_file.flush
413
-
414
- out, status = run_cli(args: ['-c', conf, '-d', conf_file.path, conf])
415
-
416
- expect(status.success?).to be_truthy
417
-
418
- expect(out).to match_fuzzy <<-MSG
419
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
420
- Ridgepole::Client.diff([{"adapter"=>"mysql2", "database"=>"ridgepole_test_for_conf_file"}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
421
- Ridgepole::Delta#differ?
422
- MSG
423
- end
424
- end
425
-
426
- specify '.rb' do
427
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.rb']) do |conf_file|
428
- conf_file.puts <<-RUBY
429
- create_table :table do
430
- end
431
- RUBY
432
- conf_file.flush
433
-
434
- out, status = run_cli(args: ['-c', conf, '-d', conf_file.path, conf])
435
-
436
- expect(status.success?).to be_truthy
437
-
438
- expect(out).to match_fuzzy <<-MSG
439
- Ridgepole::Client#initialize([#{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
440
- Ridgepole::Client.diff([#{conf_file.path}, #{conn_spec_str('ridgepole_test')}, {:dry_run=>false, :debug=>false, :color=>false}])
441
- Ridgepole::Delta#differ?
442
- MSG
443
- end
444
- end
445
- end
446
- end
447
- end
@@ -1,153 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change column (add collation)' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
8
- t.integer "emp_no", null: false
9
- t.integer "club_id", null: false, unsigned: true
10
- t.string "string", null: false, collation: "ascii_bin"
11
- t.text "text", null: false
12
- end
13
- ERB
14
- end
15
-
16
- let(:expected_dsl) do
17
- erbh(<<-ERB)
18
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
19
- t.integer "emp_no", null: false
20
- t.integer "club_id", null: false, unsigned: true
21
- t.string "string", null: false, collation: "ascii_bin"
22
- t.text "text", null: false, collation: "utf8mb4_bin"
23
- end
24
- ERB
25
- end
26
-
27
- before { subject.diff(actual_dsl).migrate }
28
- subject { client }
29
-
30
- specify do
31
- delta = subject.diff(expected_dsl)
32
- expect(delta.differ?).to be_truthy
33
- expect(subject.dump).to match_ruby actual_dsl
34
- delta.migrate
35
- expect(subject.dump).to match_ruby expected_dsl
36
- end
37
- end
38
-
39
- context 'when change column (delete collation)' do
40
- let(:actual_dsl) do
41
- erbh(<<-ERB)
42
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
43
- t.integer "emp_no", null: false
44
- t.integer "club_id", null: false, unsigned: true
45
- t.string "string", null: false, collation: "ascii_bin"
46
- t.text "text", null: false, collation: "utf8mb4_bin"
47
- end
48
- ERB
49
- end
50
-
51
- let(:expected_dsl) do
52
- erbh(<<-ERB)
53
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "club_id", null: false, unsigned: true
56
- t.string "string", null: false, collation: "ascii_bin"
57
- t.text "text", null: false
58
- end
59
- ERB
60
- end
61
-
62
- before { subject.diff(actual_dsl).migrate }
63
- subject { client }
64
-
65
- specify do
66
- delta = subject.diff(expected_dsl)
67
- expect(delta.differ?).to be_truthy
68
- expect(subject.dump).to match_ruby actual_dsl
69
- delta.migrate
70
- expect(subject.dump).to match_ruby expected_dsl
71
- end
72
- end
73
-
74
- context 'when change column (change collation)' do
75
- let(:actual_dsl) do
76
- erbh(<<-ERB)
77
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
78
- t.integer "emp_no", null: false
79
- t.integer "club_id", null: false, unsigned: true
80
- t.string "string", null: false, collation: "ascii_bin"
81
- t.text "text", null: false, collation: "utf8mb4_bin"
82
- end
83
- ERB
84
- end
85
-
86
- let(:expected_dsl) do
87
- erbh(<<-ERB)
88
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
89
- t.integer "emp_no", null: false
90
- t.integer "club_id", null: false, unsigned: true
91
- t.string "string", null: false, collation: "utf8mb4_bin"
92
- t.text "text", null: false, collation: "ascii_bin"
93
- end
94
- ERB
95
- end
96
-
97
- before { subject.diff(actual_dsl).migrate }
98
- subject { client }
99
-
100
- specify do
101
- delta = subject.diff(expected_dsl)
102
- expect(delta.differ?).to be_truthy
103
- expect(subject.dump).to match_ruby actual_dsl
104
- delta.migrate
105
- expect(subject.dump).to match_ruby expected_dsl
106
- end
107
- end
108
-
109
- context 'when change column (no change collation)' do
110
- let(:actual_dsl) do
111
- erbh(<<-ERB)
112
- create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
113
- t.integer "emp_no", null: false
114
- t.integer "club_id", null: false, unsigned: true
115
- t.string "string", null: false, collation: "ascii_bin"
116
- t.text "text", null: false, collation: "utf8mb4_bin"
117
- end
118
- ERB
119
- end
120
-
121
- before { subject.diff(actual_dsl).migrate }
122
- subject { client }
123
-
124
- specify do
125
- delta = subject.diff(actual_dsl)
126
- expect(delta.differ?).to be_falsey
127
- expect(subject.dump).to match_ruby actual_dsl
128
- delta.migrate
129
- expect(subject.dump).to match_ruby actual_dsl
130
- end
131
-
132
- describe '#diff' do
133
- specify do
134
- Tempfile.open("#{File.basename __FILE__}.#{$PROCESS_ID}") do |f|
135
- f.puts(actual_dsl)
136
- f.flush
137
-
138
- opts = ['--dump-without-table-options']
139
- out, status = run_ridgepole('--diff', "'#{JSON.dump(conn_spec)}'", f.path, *opts)
140
-
141
- # v6.0.3 is the oldest version that doesn't produce any kwargs warnings with Ruby 2.7
142
- if condition('< 6.0.3')
143
- # https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
144
- out = out.lines.grep_v(/: warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z/).join
145
- end
146
-
147
- expect(out).to be_empty
148
- expect(status.success?).to be_truthy
149
- end
150
- end
151
- end
152
- end
153
- end