ridgepole 0.7.0.alpha → 0.7.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +7 -5
  5. data/bin/ridgepole +14 -14
  6. data/lib/ridgepole/cli/config.rb +1 -1
  7. data/lib/ridgepole/client.rb +0 -4
  8. data/lib/ridgepole/delta.rb +15 -9
  9. data/lib/ridgepole/diff.rb +13 -9
  10. data/lib/ridgepole/dsl_parser/context.rb +2 -6
  11. data/lib/ridgepole/version.rb +1 -1
  12. data/ridgepole.gemspec +3 -1
  13. data/spec/erb_helper.rb +0 -39
  14. data/spec/hide_pending_formatter.rb +6 -0
  15. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
  16. data/spec/mysql/bigint_pk/int_pk_spec.rb +9 -9
  17. data/spec/mysql/cli/ridgepole_spec.rb +2 -2
  18. data/spec/mysql/collation/collation_spec.rb +28 -28
  19. data/spec/mysql/comment/comment_spec.rb +36 -36
  20. data/spec/mysql/default_lambda/default_lambda_spec.rb +1 -1
  21. data/spec/mysql/diff/diff2_spec.rb +41 -41
  22. data/spec/mysql/diff/diff_spec.rb +41 -41
  23. data/spec/mysql/dump/dump_class_method_spec.rb +26 -33
  24. data/spec/mysql/dump/dump_some_tables_spec.rb +16 -18
  25. data/spec/mysql/dump/dump_spec.rb +27 -34
  26. data/spec/mysql/dump/dump_without_table_options_spec.rb +5 -5
  27. data/spec/mysql/fk/migrate_change_fk_spec.rb +76 -23
  28. data/spec/mysql/fk/migrate_create_fk_spec.rb +70 -50
  29. data/spec/mysql/fk/migrate_drop_fk_spec.rb +131 -32
  30. data/spec/mysql/migrate/check_orphan_index_spec.rb +19 -19
  31. data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -45
  32. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +47 -47
  33. data/spec/mysql/migrate/migrate_add_column_spec.rb +75 -89
  34. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +72 -86
  35. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +72 -86
  36. data/spec/mysql/migrate/migrate_change_column2_spec.rb +27 -32
  37. data/spec/mysql/migrate/migrate_change_column3_spec.rb +78 -78
  38. data/spec/mysql/migrate/migrate_change_column4_spec.rb +24 -24
  39. data/spec/mysql/migrate/migrate_change_column5_spec.rb +42 -42
  40. data/spec/mysql/migrate/migrate_change_column6_spec.rb +60 -60
  41. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +47 -47
  42. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
  43. data/spec/mysql/migrate/migrate_change_column_spec.rb +65 -79
  44. data/spec/mysql/migrate/migrate_change_index2_spec.rb +22 -27
  45. data/spec/mysql/migrate/migrate_change_index3_spec.rb +52 -62
  46. data/spec/mysql/migrate/migrate_change_index4_spec.rb +32 -38
  47. data/spec/mysql/migrate/migrate_change_index5_spec.rb +24 -28
  48. data/spec/mysql/migrate/migrate_change_index6_spec.rb +105 -119
  49. data/spec/mysql/migrate/migrate_change_index7_spec.rb +27 -30
  50. data/spec/mysql/migrate/migrate_change_index_spec.rb +99 -120
  51. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +14 -14
  52. data/spec/mysql/migrate/migrate_create_index2_spec.rb +101 -112
  53. data/spec/mysql/migrate/migrate_create_index_spec.rb +55 -66
  54. data/spec/mysql/migrate/migrate_create_table_spec.rb +68 -91
  55. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +1 -1
  56. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +58 -70
  57. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +62 -76
  58. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +58 -72
  59. data/spec/mysql/migrate/migrate_drop_column_spec.rb +63 -77
  60. data/spec/mysql/migrate/migrate_drop_index_spec.rb +55 -66
  61. data/spec/mysql/migrate/migrate_drop_table_spec.rb +51 -63
  62. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +3 -3
  63. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +12 -12
  64. data/spec/mysql/migrate/migrate_empty_spec.rb +35 -42
  65. data/spec/mysql/migrate/migrate_execute_spec.rb +16 -24
  66. data/spec/mysql/migrate/migrate_log_file_spec.rb +58 -70
  67. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +75 -99
  68. data/spec/mysql/migrate/migrate_noop_spec.rb +38 -38
  69. data/spec/mysql/migrate/migrate_rename_column_spec.rb +74 -88
  70. data/spec/mysql/migrate/migrate_rename_table_spec.rb +100 -97
  71. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +18 -18
  72. data/spec/mysql/migrate/migrate_same_spec.rb +29 -37
  73. data/spec/mysql/migrate/migrate_script_error_spec.rb +19 -19
  74. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +148 -0
  75. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +70 -84
  76. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +70 -84
  77. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +87 -87
  78. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +61 -75
  79. data/spec/mysql/migrate/migrate_with_tables_spec.rb +41 -41
  80. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +10 -10
  81. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +67 -78
  82. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +67 -78
  83. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +9 -9
  84. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
  85. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +35 -67
  86. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
  87. data/spec/postgresql/diff/diff_spec.rb +37 -37
  88. data/spec/postgresql/dump/dump_spec.rb +27 -34
  89. data/spec/postgresql/fk/migrate_change_fk_spec.rb +76 -23
  90. data/spec/postgresql/fk/migrate_create_fk_spec.rb +73 -54
  91. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +131 -32
  92. data/spec/postgresql/migrate/migrate_add_column_spec.rb +63 -75
  93. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
  94. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +7 -7
  95. data/spec/postgresql/migrate/migrate_change_column_spec.rb +53 -65
  96. data/spec/postgresql/migrate/migrate_change_index_spec.rb +54 -68
  97. data/spec/postgresql/migrate/migrate_create_table_spec.rb +56 -77
  98. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +46 -60
  99. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +41 -55
  100. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
  101. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +51 -62
  102. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +48 -60
  103. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -6
  104. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +54 -68
  105. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +62 -78
  106. data/spec/postgresql/migrate/migrate_same_spec.rb +27 -34
  107. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
  108. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +35 -66
  109. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
  110. data/spec/spec_helper.rb +1 -1
  111. metadata +9 -8
  112. data/ridgepole.iml +0 -9
  113. data/spec/string_ext.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c4e5ed48fbd6469287d34ef340f9a3693fc2470
4
- data.tar.gz: e9cc11808cd560064217cf5441a875df892ca207
3
+ metadata.gz: 062b636d39f10f64c5fc0b450021c914121982bc
4
+ data.tar.gz: 7948f752d4a6165ce5b95926ed910c47b32587af
5
5
  SHA512:
6
- metadata.gz: ad5e244204d6cad0ea31b7b330813f2086e49881e4773277748beaf5f36de9e2c7a927bad952acdaf87631a1f932aa97ca5c0eaeeafe16bd35b06c5e9604637c
7
- data.tar.gz: 4e6abdd8a8fd60bf425cf2431c693f140ddcf7836fd1b5f2353f31aa57f870def2d4c6442e0e144839010a3b8b4bd4d0927428cbb74bf23f821a68939c0fbe4b
6
+ metadata.gz: aeab93ec074378be562709f3984dee5716381c961aa04e845fe78646cc40ee47a1e57caaad5bed77fd11639c5d3d6ad4db4a7a5e1055e320906cb9d2168a9ea8
7
+ data.tar.gz: 9fabbad5e5158b4916d1772352ca735a82363a41f11eaadae7776e789644c844dbd87d5b48d8b036cfb9ceb5a08c9bb612171ce1e5af833d4424e7b79a0746a7
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --colour
2
2
  --require spec_helper
3
+ --format HidePendingFormatter
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  dist: trusty
2
2
  sudo: required
3
+ group: edge
3
4
  language: ruby
4
5
  cache:
5
6
  - bundler
data/README.md CHANGED
@@ -76,6 +76,9 @@ add_foreign_key :articles, :authors # without `name:`
76
76
  * `>= 0.7.0`
77
77
  * Remove Rails 4.x support
78
78
  * Add Rails 5.1 support
79
+ * Remove `--enable-mysql-awesome` option
80
+ * Add `--skip-drop-table` option
81
+ * Support foreign key without name
79
82
 
80
83
  ## Installation
81
84
 
@@ -120,12 +123,12 @@ Usage: ridgepole [options]
120
123
  --with-apply
121
124
  -o, --output SCHEMAFILE
122
125
  -t, --tables TABLES
123
- --ignore-tables TABLES
124
- --enable-mysql-awesome
126
+ --ignore-tables REGEX_LIST
125
127
  --mysql-use-alter
126
128
  --dump-without-table-options
127
129
  --dump-with-default-fk-name
128
130
  --index-removed-drop-column
131
+ --skip-drop-table
129
132
  -r, --require LIBS
130
133
  --log-file LOG_FILE
131
134
  --verbose
@@ -358,9 +361,8 @@ Apply `Schemafile`
358
361
  docker-compose up -d
359
362
  bundle install
360
363
  bundle exec appraisal install
361
- bundle exec appraisal activerecord-4.2 rake
362
- # ENABLE_MYSQL_AWESOME=1 bundle exec appraisal activerecord-4.2 rake
363
- # POSTGRESQL=1 bundle exec appraisal activerecord-4.2 rake
364
+ bundle exec appraisal activerecord-5.1 rake
365
+ # POSTGRESQL=1 bundle exec appraisal activerecord-5.1 rake
364
366
  ```
365
367
 
366
368
  **Notice:** mysql-client/postgresql-client is required.
data/bin/ridgepole CHANGED
@@ -104,20 +104,20 @@ ARGV.options do |opt|
104
104
  ARGV.shift
105
105
  diff_files = [diff_arg1, diff_arg2]
106
106
  }
107
- opt.on('', '--reverse') { options[:reverse] = true }
108
- opt.on('', '--with-apply') { diff_with_apply = true }
109
- opt.on('-o', '--output SCHEMAFILE') {|v| output_file = v }
110
- opt.on('-t', '--tables TABLES', Array) {|v| options[:tables] = v }
111
- opt.on('', '--ignore-tables TABLES', Array) {|v| options[:ignore_tables] = v.map {|i| Regexp.new(i) } }
112
- opt.on('', '--enable-mysql-awesome') { options[:enable_mysql_awesome] = true }
113
- opt.on('', '--mysql-use-alter') { options[:mysql_use_alter] = true }
114
- opt.on('', '--dump-without-table-options') { options[:dump_without_table_options] = true }
115
- opt.on('', '--dump-with-default-fk-name') { options[:dump_with_default_fk_name] = true }
116
- opt.on('', '--index-removed-drop-column') { options[:index_removed_drop_column] = true }
117
- opt.on('-r', '--require LIBS', Array) {|v| v.each {|i| require i } }
118
- opt.on('' , '--log-file LOG_FILE') {|v| options[:log_file] = v }
119
- opt.on('' , '--verbose') { Ridgepole::Logger.verbose = true }
120
- opt.on('' , '--debug') { options[:debug] = true }
107
+ opt.on('', '--reverse') { options[:reverse] = true }
108
+ opt.on('', '--with-apply') { diff_with_apply = true }
109
+ opt.on('-o', '--output SCHEMAFILE') {|v| output_file = v }
110
+ opt.on('-t', '--tables TABLES', Array) {|v| options[:tables] = v }
111
+ opt.on('', '--ignore-tables REGEX_LIST', Array) {|v| options[:ignore_tables] = v.map {|i| Regexp.new(i) } }
112
+ opt.on('', '--mysql-use-alter') { options[:mysql_use_alter] = true }
113
+ opt.on('', '--dump-without-table-options') { options[:dump_without_table_options] = true }
114
+ opt.on('', '--dump-with-default-fk-name') { options[:dump_with_default_fk_name] = true }
115
+ opt.on('', '--index-removed-drop-column') { options[:index_removed_drop_column] = true }
116
+ opt.on('', '--skip-drop-table') { options[:skip_drop_table] = true }
117
+ opt.on('-r', '--require LIBS', Array) {|v| v.each {|i| require i } }
118
+ opt.on('' , '--log-file LOG_FILE') {|v| options[:log_file] = v }
119
+ opt.on('' , '--verbose') { Ridgepole::Logger.verbose = true }
120
+ opt.on('' , '--debug') { options[:debug] = true }
121
121
 
122
122
  opt.on('-v', '--version') {
123
123
  puts opt.ver
@@ -33,7 +33,7 @@ class Ridgepole::Config
33
33
  def parse_database_url(config)
34
34
  uri = URI.parse(config)
35
35
 
36
- if [uri.scheme, uri.user, uri.password, uri.host, uri.path].any? {|i| i.nil? }
36
+ if [uri.scheme, uri.user, uri.host, uri.path].any? {|i| i.nil? }
37
37
  raise "Invalid config: #{config.inspect}"
38
38
  end
39
39
 
@@ -14,10 +14,6 @@ class Ridgepole::Client
14
14
  @parser = Ridgepole::DSLParser.new(@options)
15
15
  @diff = Ridgepole::Diff.new(@options)
16
16
 
17
- if @options[:enable_mysql_awesome]
18
- require 'activerecord/mysql/awesome/base'
19
- end
20
-
21
17
  if @options[:mysql_use_alter]
22
18
  require 'ridgepole/ext/abstract_mysql_adapter/use_alter_index'
23
19
  end
@@ -244,8 +244,8 @@ end
244
244
  end
245
245
 
246
246
  unless (foreign_keys = attrs[:foreign_keys] || {}).empty?
247
- foreign_keys.each do |foreign_key_name, foreign_key_attrs|
248
- append_add_foreign_key(table_name, foreign_key_name, foreign_key_attrs, buf_for_fk, @options)
247
+ foreign_keys.each do |_, foreign_key_attrs|
248
+ append_add_foreign_key(table_name, foreign_key_attrs, buf_for_fk, @options)
249
249
  end
250
250
  end
251
251
 
@@ -415,16 +415,16 @@ remove_index(#{table_name.inspect}, #{target.inspect})
415
415
  end
416
416
 
417
417
  def append_change_foreign_keys(table_name, delta, buf, options)
418
- (delta[:delete] || {}).each do |foreign_key_name, attrs|
419
- append_remove_foreign_key(table_name, foreign_key_name, attrs, buf, options)
418
+ (delta[:delete] || {}).each do |_, attrs|
419
+ append_remove_foreign_key(table_name, attrs, buf, options)
420
420
  end
421
421
 
422
- (delta[:add] || {}).each do |foreign_key_name, attrs|
423
- append_add_foreign_key(table_name, foreign_key_name, attrs, buf, options)
422
+ (delta[:add] || {}).each do |_, attrs|
423
+ append_add_foreign_key(table_name, attrs, buf, options)
424
424
  end
425
425
  end
426
426
 
427
- def append_add_foreign_key(table_name, foreign_key_name, attrs, buf, options)
427
+ def append_add_foreign_key(table_name, attrs, buf, options)
428
428
  to_table = attrs.fetch(:to_table)
429
429
  attrs_options = attrs[:options] || {}
430
430
 
@@ -433,9 +433,15 @@ add_foreign_key(#{table_name.inspect}, #{to_table.inspect}, #{attrs_options.insp
433
433
  EOS
434
434
  end
435
435
 
436
- def append_remove_foreign_key(table_name, foreign_key_name, attrs, buf, options)
436
+ def append_remove_foreign_key(table_name, attrs, buf, options)
437
437
  attrs_options = attrs[:options] || {}
438
- target = {:name => attrs_options.fetch(:name)}
438
+ fk_name = attrs_options[:name]
439
+
440
+ if fk_name
441
+ target = {:name => fk_name}
442
+ else
443
+ target = attrs.fetch(:to_table)
444
+ end
439
445
 
440
446
  buf.puts(<<-EOS)
441
447
  remove_foreign_key(#{table_name.inspect}, #{target.inspect})
@@ -34,7 +34,7 @@ class Ridgepole::Diff
34
34
  end
35
35
  end
36
36
 
37
- unless @options[:merge]
37
+ unless @options[:merge] or @options[:skip_drop_table]
38
38
  from.each do |table_name, from_attrs|
39
39
  next unless target?(table_name)
40
40
 
@@ -55,6 +55,8 @@ class Ridgepole::Diff
55
55
  next unless target?(table_name)
56
56
 
57
57
  if (from_table_name = (to_attrs[:options] || {}).delete(:renamed_from))
58
+ from_table_name = from_table_name.to_s if from_table_name
59
+
58
60
  # Already renamed
59
61
  next if from[table_name]
60
62
 
@@ -195,6 +197,8 @@ class Ridgepole::Diff
195
197
  def scan_column_rename(from, to, definition_delta)
196
198
  to.dup.each do |column_name, to_attrs|
197
199
  if (from_column_name = (to_attrs[:options] || {}).delete(:renamed_from))
200
+ from_column_name = from_column_name.to_s if from_column_name
201
+
198
202
  # Already renamed
199
203
  next if from[column_name]
200
204
 
@@ -291,7 +295,7 @@ class Ridgepole::Diff
291
295
  opts[:default] = nil
292
296
  end
293
297
 
294
- if @options[:enable_mysql_awesome]
298
+ if Ridgepole::ConnectionAdapters.mysql?
295
299
  opts[:unsigned] = false unless opts.has_key?(:unsigned)
296
300
  end
297
301
  end
@@ -319,29 +323,29 @@ class Ridgepole::Diff
319
323
  to = (to || {}).dup
320
324
  foreign_keys_delta = {}
321
325
 
322
- to.each do |foreign_key_name, to_attrs|
323
- from_attrs = from.delete(foreign_key_name)
326
+ to.each do |foreign_key_name_or_tables, to_attrs|
327
+ from_attrs = from.delete(foreign_key_name_or_tables)
324
328
 
325
329
  if from_attrs
326
330
  if from_attrs != to_attrs
327
331
  foreign_keys_delta[:add] ||= {}
328
- foreign_keys_delta[:add][foreign_key_name] = to_attrs
332
+ foreign_keys_delta[:add][foreign_key_name_or_tables] = to_attrs
329
333
 
330
334
  unless options[:merge]
331
335
  foreign_keys_delta[:delete] ||= {}
332
- foreign_keys_delta[:delete][foreign_key_name] = from_attrs
336
+ foreign_keys_delta[:delete][foreign_key_name_or_tables] = from_attrs
333
337
  end
334
338
  end
335
339
  else
336
340
  foreign_keys_delta[:add] ||= {}
337
- foreign_keys_delta[:add][foreign_key_name] = to_attrs
341
+ foreign_keys_delta[:add][foreign_key_name_or_tables] = to_attrs
338
342
  end
339
343
  end
340
344
 
341
345
  unless options[:merge]
342
- from.each do |foreign_key_name, from_attrs|
346
+ from.each do |foreign_key_name_or_tables, from_attrs|
343
347
  foreign_keys_delta[:delete] ||= {}
344
- foreign_keys_delta[:delete][foreign_key_name] = from_attrs
348
+ foreign_keys_delta[:delete][foreign_key_name_or_tables] = from_attrs
345
349
  end
346
350
  end
347
351
 
@@ -75,16 +75,12 @@ class Ridgepole::DSLParser
75
75
  end
76
76
 
77
77
  def add_foreign_key(from_table, to_table, options = {})
78
- unless options[:name]
79
- raise "Foreign key name in `#{from_table}` is undefined"
80
- end
81
-
82
78
  from_table = from_table.to_s
83
79
  to_table = to_table.to_s
84
- options[:name] = options[:name].to_s
80
+ options[:name] = options[:name].to_s if options[:name]
85
81
  @__definition[from_table] ||= {}
86
82
  @__definition[from_table][:foreign_keys] ||= {}
87
- idx = options[:name]
83
+ idx = options[:name] || [from_table, to_table]
88
84
 
89
85
  if @__definition[from_table][:foreign_keys][idx]
90
86
  raise "Foreign Key `#{from_table}(#{idx})` already defined"
@@ -1,3 +1,3 @@
1
1
  module Ridgepole
2
- VERSION = '0.7.0.alpha'
2
+ VERSION = '0.7.0.alpha2'
3
3
  end
data/ridgepole.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.2.7')
22
+
21
23
  spec.add_dependency 'activerecord', '>= 5.0.1', '< 6'
22
24
  spec.add_dependency 'diffy'
23
25
  spec.add_development_dependency 'bundler'
@@ -26,7 +28,7 @@ Gem::Specification.new do |spec|
26
28
  spec.add_development_dependency 'mysql2', '~> 0.3.20'
27
29
  spec.add_development_dependency 'pg'
28
30
  spec.add_development_dependency 'coveralls'
29
- spec.add_development_dependency 'appraisal'
31
+ spec.add_development_dependency 'appraisal', '>= 2.2.0'
30
32
  spec.add_development_dependency 'rspec-match_fuzzy', '>= 0.1.3'
31
33
  spec.add_development_dependency 'erbh', '>= 0.1.2'
32
34
  spec.add_development_dependency 'hash_modern_inspect', '>= 0.1.1'
data/spec/erb_helper.rb CHANGED
@@ -9,45 +9,6 @@ ERBh.define_method(:i) do |obj|
9
9
  end
10
10
  end
11
11
 
12
- ERBh.define_method(:add_index) do |table_name, column_name, options|
13
- if options[:length].is_a?(Hash)
14
- options[:length] = options[:length].symbolize_keys
15
- end
16
-
17
- @_erbout.sub!(/\bend\s*\z/, '')
18
-
19
- # XXX:
20
- if not condition('5.0') and options[:using] == :btree
21
- options.delete(:using)
22
- end
23
-
24
- # XXX:
25
- if options.has_key?(:force_using)
26
- options[:using] = options.delete(:force_using)
27
- end
28
-
29
- <<-EOS
30
- t.index #{column_name.inspect}, #{options.modern_inspect_without_brace}
31
- end
32
- EOS
33
- end
34
-
35
- ERBh.define_method(:unsigned) do |value, *conds|
36
- if condition(*conds)
37
- {unsigned: value}
38
- else
39
- {}
40
- end
41
- end
42
-
43
- ERBh.define_method(:limit) do |value, *conds|
44
- if condition(*conds)
45
- {limit: value}
46
- else
47
- {}
48
- end
49
- end
50
-
51
12
  ERBh.define_method(:cond) do |conds, m, e = nil|
52
13
  if condition(*Array(conds))
53
14
  m
@@ -0,0 +1,6 @@
1
+ class HidePendingFormatter < RSpec::Core::Formatters::ProgressFormatter
2
+ RSpec::Core::Formatters.register self, :example_pending
3
+ RSpec::Core::Formatters.register self, :dump_pending
4
+ def example_pending(notification); end
5
+ def dump_pending(notification); end
6
+ end
@@ -1,24 +1,24 @@
1
- describe 'Ridgepole::Client (with bigint pk)', condition: '5.0.' do
1
+ describe 'Ridgepole::Client (with bigint pk)', condition: 5.0 do
2
2
  let(:id_primary_key_create_table) {
3
- <<-RUBY
3
+ <<-EOS
4
4
  create_table "books", id: :primary_key, limit: 8, force: :cascade do |t|
5
- t.string "title", null: false
6
- t.integer "author_id", null: false
5
+ t.string "title", null: false
6
+ t.integer "author_id", null: false
7
7
  t.datetime "created_at"
8
8
  t.datetime "updated_at"
9
9
  end
10
- RUBY
10
+ EOS
11
11
  }
12
12
 
13
13
  let(:id_bigint_create_table) {
14
- <<-RUBY
14
+ <<-EOS
15
15
  create_table "books", id: :bigint, force: :cascade do |t|
16
- t.string "title", null: false
17
- t.integer "author_id", null: false
16
+ t.string "title", null: false
17
+ t.integer "author_id", null: false
18
18
  t.datetime "created_at"
19
19
  t.datetime "updated_at"
20
20
  end
21
- RUBY
21
+ EOS
22
22
  }
23
23
 
24
24
  context 'when with limit:8' do
@@ -1,14 +1,14 @@
1
- describe 'Ridgepole::Client (with integer pk)', condition: '5.1.' do
1
+ describe 'Ridgepole::Client (with integer pk)', condition: 5.1 do
2
2
  context 'when with id:integer' do
3
3
  let(:dsl) {
4
- <<-RUBY
4
+ <<-EOS
5
5
  create_table "books", id: :integer, force: :cascade do |t|
6
- t.string "title", null: false
7
- t.integer "author_id", null: false
6
+ t.string "title", null: false
7
+ t.integer "author_id", null: false
8
8
  t.datetime "created_at"
9
9
  t.datetime "updated_at"
10
10
  end
11
- RUBY
11
+ EOS
12
12
  }
13
13
 
14
14
  subject { client }
@@ -23,14 +23,14 @@ describe 'Ridgepole::Client (with integer pk)', condition: '5.1.' do
23
23
 
24
24
  context 'when without id:integer' do
25
25
  let(:dsl) {
26
- <<-RUBY
26
+ <<-EOS
27
27
  create_table "books", force: :cascade do |t|
28
- t.string "title", null: false
29
- t.integer "author_id", null: false
28
+ t.string "title", null: false
29
+ t.integer "author_id", null: false
30
30
  t.datetime "created_at"
31
31
  t.datetime "updated_at"
32
32
  end
33
- RUBY
33
+ EOS
34
34
  }
35
35
 
36
36
  subject { client }
@@ -39,12 +39,12 @@ describe 'ridgepole' do
39
39
  --with-apply
40
40
  -o, --output SCHEMAFILE
41
41
  -t, --tables TABLES
42
- --ignore-tables TABLES
43
- --enable-mysql-awesome
42
+ --ignore-tables REGEX_LIST
44
43
  --mysql-use-alter
45
44
  --dump-without-table-options
46
45
  --dump-with-default-fk-name
47
46
  --index-removed-drop-column
47
+ --skip-drop-table
48
48
  -r, --require LIBS
49
49
  --log-file LOG_FILE
50
50
  --verbose
@@ -2,22 +2,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change column (add collation)' do
3
3
  let(:actual_dsl) {
4
4
  erbh(<<-EOS)
5
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
6
- t.integer "emp_no", null: false
5
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
6
+ t.integer "emp_no", null: false
7
7
  t.integer "club_id", null: false, unsigned: true
8
- t.string "string", null: false, collation: "ascii_bin"
9
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false
8
+ t.string "string", null: false, collation: "ascii_bin"
9
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false
10
10
  end
11
11
  EOS
12
12
  }
13
13
 
14
14
  let(:expected_dsl) {
15
15
  erbh(<<-EOS)
16
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
17
- t.integer "emp_no", null: false
16
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
17
+ t.integer "emp_no", null: false
18
18
  t.integer "club_id", null: false, unsigned: true
19
- t.string "string", null: false, collation: "ascii_bin"
20
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false, collation: "utf8mb4_bin"
19
+ t.string "string", null: false, collation: "ascii_bin"
20
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false, collation: "utf8mb4_bin"
21
21
  end
22
22
  EOS
23
23
  }
@@ -37,22 +37,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
37
37
  context 'when change column (delete collation)' do
38
38
  let(:actual_dsl) {
39
39
  erbh(<<-EOS)
40
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
41
- t.integer "emp_no", null: false
40
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
41
+ t.integer "emp_no", null: false
42
42
  t.integer "club_id", null: false, unsigned: true
43
- t.string "string", null: false, collation: "ascii_bin"
44
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false, collation: "utf8mb4_bin"
43
+ t.string "string", null: false, collation: "ascii_bin"
44
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false, collation: "utf8mb4_bin"
45
45
  end
46
46
  EOS
47
47
  }
48
48
 
49
49
  let(:expected_dsl) {
50
50
  erbh(<<-EOS)
51
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
52
- t.integer "emp_no", null: false
51
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
52
+ t.integer "emp_no", null: false
53
53
  t.integer "club_id", null: false, unsigned: true
54
- t.string "string", null: false, collation: "ascii_bin"
55
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false
54
+ t.string "string", null: false, collation: "ascii_bin"
55
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false
56
56
  end
57
57
  EOS
58
58
  }
@@ -72,22 +72,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
72
72
  context 'when change column (change collation)' do
73
73
  let(:actual_dsl) {
74
74
  erbh(<<-EOS)
75
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
76
- t.integer "emp_no", null: false
75
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
76
+ t.integer "emp_no", null: false
77
77
  t.integer "club_id", null: false, unsigned: true
78
- t.string "string", null: false, collation: "ascii_bin"
79
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false, collation: "utf8mb4_bin"
78
+ t.string "string", null: false, collation: "ascii_bin"
79
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false, collation: "utf8mb4_bin"
80
80
  end
81
81
  EOS
82
82
  }
83
83
 
84
84
  let(:expected_dsl) {
85
85
  erbh(<<-EOS)
86
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
87
- t.integer "emp_no", null: false
86
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
87
+ t.integer "emp_no", null: false
88
88
  t.integer "club_id", null: false, unsigned: true
89
- t.string "string", <%= i limit(255) + {null: false, collation: "utf8mb4_bin"} %>
90
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false, collation: "ascii_bin"
89
+ t.string "string", null: false, collation: "utf8mb4_bin"
90
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false, collation: "ascii_bin"
91
91
  end
92
92
  EOS
93
93
  }
@@ -107,11 +107,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
107
107
  context 'when change column (no change collation)' do
108
108
  let(:actual_dsl) {
109
109
  erbh(<<-EOS)
110
- create_table "employee_clubs", <%= i cond('5.1.', id: :bigint) %>, unsigned: true, force: :cascade do |t|
111
- t.integer "emp_no", null: false
110
+ create_table "employee_clubs", <%= i cond(5.1, id: :bigint) %>, unsigned: true, force: :cascade do |t|
111
+ t.integer "emp_no", null: false
112
112
  t.integer "club_id", null: false, unsigned: true
113
- t.string "string", null: false, collation: "ascii_bin"
114
- t.text "text", <%= i cond('5.0.', limit: 65535) %>, null: false, collation: "utf8mb4_bin"
113
+ t.string "string", null: false, collation: "ascii_bin"
114
+ t.text "text", <%= i cond(5.0, limit: 65535) %>, null: false, collation: "utf8mb4_bin"
115
115
  end
116
116
  EOS
117
117
  }