ridgepole 0.7.3.beta → 0.7.3.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +38 -0
  3. data/Appraisals +2 -2
  4. data/README.md +3 -9
  5. data/Rakefile +7 -1
  6. data/bin/ridgepole +97 -108
  7. data/gemfiles/activerecord_5.2.gemfile +1 -1
  8. data/lib/ridgepole/cli/config.rb +43 -43
  9. data/lib/ridgepole/client.rb +65 -63
  10. data/lib/ridgepole/default_limit.rb +26 -24
  11. data/lib/ridgepole/delta.rb +367 -369
  12. data/lib/ridgepole/diff.rb +366 -377
  13. data/lib/ridgepole/dsl_parser.rb +22 -20
  14. data/lib/ridgepole/dsl_parser/context.rb +95 -93
  15. data/lib/ridgepole/dsl_parser/table_definition.rb +125 -123
  16. data/lib/ridgepole/dumper.rb +73 -71
  17. data/lib/ridgepole/execute_expander.rb +55 -55
  18. data/lib/ridgepole/ext/abstract_mysql_adapter/dump_auto_increment.rb +3 -3
  19. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +1 -1
  20. data/lib/ridgepole/ext/pp_sort_hash.rb +14 -14
  21. data/lib/ridgepole/ext/schema_dumper.rb +1 -1
  22. data/lib/ridgepole/external_sql_executer.rb +20 -20
  23. data/lib/ridgepole/logger.rb +17 -15
  24. data/lib/ridgepole/migration_ext.rb +6 -8
  25. data/lib/ridgepole/schema_statements_ext.rb +3 -3
  26. data/lib/ridgepole/version.rb +1 -1
  27. data/ridgepole.gemspec +11 -10
  28. data/spec/cli_helper.rb +2 -2
  29. data/spec/erb_helper.rb +6 -2
  30. data/spec/hide_pending_formatter.rb +5 -4
  31. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +8 -8
  32. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +8 -8
  33. data/spec/mysql/bigint_pk/int_pk_spec.rb +13 -13
  34. data/spec/mysql/cli/config_spec.rb +52 -53
  35. data/spec/mysql/cli/ridgepole_spec.rb +111 -111
  36. data/spec/mysql/collation/collation_spec.rb +39 -39
  37. data/spec/mysql/comment/comment_spec.rb +36 -36
  38. data/spec/mysql/default_lambda/default_lambda_spec.rb +30 -30
  39. data/spec/mysql/diff/diff2_spec.rb +18 -18
  40. data/spec/mysql/diff/diff_spec.rb +11 -11
  41. data/spec/mysql/dump/dump_class_method_spec.rb +2 -2
  42. data/spec/mysql/dump/dump_some_tables_spec.rb +14 -14
  43. data/spec/mysql/dump/dump_spec.rb +2 -2
  44. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +3 -3
  45. data/spec/mysql/dump/dump_without_table_options_spec.rb +8 -8
  46. data/spec/mysql/fk/migrate_change_fk_spec.rb +40 -40
  47. data/spec/mysql/fk/migrate_create_fk_spec.rb +40 -40
  48. data/spec/mysql/fk/migrate_drop_fk_spec.rb +60 -60
  49. data/spec/mysql/migrate/check_orphan_index_spec.rb +6 -6
  50. data/spec/mysql/migrate/migrate_add_column2_spec.rb +43 -43
  51. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +50 -50
  52. data/spec/mysql/migrate/migrate_add_column_spec.rb +11 -11
  53. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +8 -8
  54. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +11 -11
  55. data/spec/mysql/migrate/migrate_change_column2_spec.rb +20 -20
  56. data/spec/mysql/migrate/migrate_change_column3_spec.rb +60 -60
  57. data/spec/mysql/migrate/migrate_change_column4_spec.rb +16 -16
  58. data/spec/mysql/migrate/migrate_change_column5_spec.rb +24 -24
  59. data/spec/mysql/migrate/migrate_change_column6_spec.rb +40 -40
  60. data/spec/mysql/migrate/migrate_change_column7_spec.rb +4 -4
  61. data/spec/mysql/migrate/migrate_change_column8_spec.rb +9 -9
  62. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +48 -48
  63. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
  64. data/spec/mysql/migrate/migrate_change_column_spec.rb +11 -11
  65. data/spec/mysql/migrate/migrate_change_index2_spec.rb +20 -20
  66. data/spec/mysql/migrate/migrate_change_index3_spec.rb +43 -43
  67. data/spec/mysql/migrate/migrate_change_index4_spec.rb +24 -24
  68. data/spec/mysql/migrate/migrate_change_index5_spec.rb +16 -16
  69. data/spec/mysql/migrate/migrate_change_index6_spec.rb +12 -12
  70. data/spec/mysql/migrate/migrate_change_index7_spec.rb +20 -20
  71. data/spec/mysql/migrate/migrate_change_index8_spec.rb +20 -20
  72. data/spec/mysql/migrate/migrate_change_index_spec.rb +17 -17
  73. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +10 -10
  74. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +18 -18
  75. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +37 -37
  76. data/spec/mysql/migrate/migrate_create_index2_spec.rb +12 -12
  77. data/spec/mysql/migrate/migrate_create_index_spec.rb +11 -11
  78. data/spec/mysql/migrate/migrate_create_table_spec.rb +8 -8
  79. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +6 -6
  80. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +12 -12
  81. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +11 -11
  82. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +9 -9
  83. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +12 -12
  84. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +10 -10
  85. data/spec/mysql/migrate/migrate_drop_column_spec.rb +11 -11
  86. data/spec/mysql/migrate/migrate_drop_index_spec.rb +11 -11
  87. data/spec/mysql/migrate/migrate_drop_table_spec.rb +8 -8
  88. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +6 -6
  89. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +6 -6
  90. data/spec/mysql/migrate/migrate_empty_spec.rb +4 -4
  91. data/spec/mysql/migrate/migrate_execute_spec.rb +55 -55
  92. data/spec/mysql/migrate/migrate_log_file_spec.rb +9 -9
  93. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +9 -9
  94. data/spec/mysql/migrate/migrate_noop_spec.rb +19 -19
  95. data/spec/mysql/migrate/migrate_primary_key_spec.rb +18 -18
  96. data/spec/mysql/migrate/migrate_rename_column_spec.rb +17 -17
  97. data/spec/mysql/migrate/migrate_rename_table_spec.rb +26 -26
  98. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +16 -16
  99. data/spec/mysql/migrate/migrate_same_spec.rb +4 -4
  100. data/spec/mysql/migrate/migrate_script_error_spec.rb +8 -8
  101. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +8 -8
  102. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +9 -9
  103. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +8 -8
  104. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +9 -9
  105. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +64 -64
  106. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +12 -12
  107. data/spec/mysql/migrate/migrate_with_tables_spec.rb +29 -29
  108. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +18 -18
  109. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +8 -8
  110. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +8 -8
  111. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +8 -8
  112. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
  113. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
  114. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
  115. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +7 -7
  116. data/spec/mysql57/json/add_json_column_spec.rb +8 -8
  117. data/spec/mysql57/json/change_json_column_spec.rb +24 -24
  118. data/spec/mysql57/json/drop_json_column_spec.rb +8 -8
  119. data/spec/mysql57/virtual/add_virtual_column_spec.rb +9 -9
  120. data/spec/mysql57/virtual/change_virtual_column_spec.rb +9 -9
  121. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +9 -9
  122. data/spec/postgresql/diff/diff_spec.rb +18 -18
  123. data/spec/postgresql/dump/dump_spec.rb +2 -2
  124. data/spec/postgresql/fk/migrate_change_fk_spec.rb +24 -24
  125. data/spec/postgresql/fk/migrate_create_fk_spec.rb +40 -40
  126. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +44 -44
  127. data/spec/postgresql/migrate/migrate_add_column_spec.rb +21 -21
  128. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +2 -2
  129. data/spec/postgresql/migrate/migrate_bigint_spec.rb +12 -12
  130. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +8 -8
  131. data/spec/postgresql/migrate/migrate_change_column_spec.rb +19 -19
  132. data/spec/postgresql/migrate/migrate_change_index_spec.rb +13 -13
  133. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +19 -19
  134. data/spec/postgresql/migrate/migrate_create_table_spec.rb +8 -8
  135. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +18 -18
  136. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +11 -11
  137. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -12
  138. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +8 -8
  139. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +11 -11
  140. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +8 -8
  141. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +8 -8
  142. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +97 -0
  143. data/spec/postgresql/migrate/migrate_references_spec.rb +24 -24
  144. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +11 -11
  145. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +16 -16
  146. data/spec/postgresql/migrate/migrate_same_spec.rb +4 -4
  147. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
  148. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
  149. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
  150. data/spec/processing_for_travis.rb +1 -1
  151. data/spec/spec_condition.rb +2 -2
  152. data/spec/spec_const.rb +9 -9
  153. data/spec/spec_helper.rb +21 -23
  154. metadata +54 -37
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change index (unique: false)' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "salaries", force: :cascade do |t|
6
6
  t.integer "emp_no", null: false
7
7
  t.integer "salary", null: false
@@ -9,11 +9,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
9
9
  t.date "to_date", null: false
10
10
  t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
11
11
  end
12
- EOS
13
- }
12
+ ERB
13
+ end
14
14
 
15
- let(:expected_dsl) {
16
- erbh(<<-EOS)
15
+ let(:expected_dsl) do
16
+ erbh(<<-ERB)
17
17
  create_table "salaries", force: :cascade do |t|
18
18
  t.integer "emp_no", null: false
19
19
  t.integer "salary", null: false
@@ -21,8 +21,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
21
21
  t.date "to_date", null: false
22
22
  t.index ["emp_no", "id"], name: "emp_no", unique: false, <%= i cond(5.0, using: :btree) %>
23
23
  end
24
- EOS
25
- }
24
+ ERB
25
+ end
26
26
 
27
27
  before { subject.diff(actual_dsl).migrate }
28
28
  subject { client }
@@ -34,8 +34,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
34
34
  end
35
35
 
36
36
  context 'when change index (unique: true)' do
37
- let(:actual_dsl) {
38
- erbh(<<-EOS)
37
+ let(:actual_dsl) do
38
+ erbh(<<-ERB)
39
39
  create_table "salaries", force: :cascade do |t|
40
40
  t.integer "emp_no", null: false
41
41
  t.integer "salary", null: false
@@ -43,11 +43,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
43
43
  t.date "to_date", null: false
44
44
  t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
45
45
  end
46
- EOS
47
- }
46
+ ERB
47
+ end
48
48
 
49
- let(:expected_dsl) {
50
- erbh(<<-EOS)
49
+ let(:expected_dsl) do
50
+ erbh(<<-ERB)
51
51
  create_table "salaries", force: :cascade do |t|
52
52
  t.integer "emp_no", null: false
53
53
  t.integer "salary", null: false
@@ -55,8 +55,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
55
55
  t.date "to_date", null: false
56
56
  t.index ["emp_no", "id"], name: "emp_no", unique: true, <%= i cond(5.0, using: :btree) %>
57
57
  end
58
- EOS
59
- }
58
+ ERB
59
+ end
60
60
 
61
61
  before { subject.diff(actual_dsl).migrate }
62
62
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change index (use t.index)' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "clubs", force: :cascade do |t|
6
6
  t.string "name", default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -59,11 +59,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.date "to_date"
60
60
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
61
61
  end
62
- EOS
63
- }
62
+ ERB
63
+ end
64
64
 
65
- let(:expected_dsl) {
66
- erbh(<<-EOS)
65
+ let(:expected_dsl) do
66
+ erbh(<<-ERB)
67
67
  create_table "clubs", force: :cascade do |t|
68
68
  t.string "name", default: "", null: false
69
69
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -121,11 +121,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
121
121
  t.date "to_date"
122
122
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
123
123
  end
124
- EOS
125
- }
124
+ ERB
125
+ end
126
126
 
127
- let(:expected_dsl_using_t_index) {
128
- erbh(<<-EOS)
127
+ let(:expected_dsl_using_t_index) do
128
+ erbh(<<-ERB)
129
129
  create_table "clubs", force: :cascade do |t|
130
130
  t.string "name", default: "", null: false
131
131
  t.index "name", name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -183,8 +183,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
183
183
  t.date "to_date"
184
184
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
185
185
  end
186
- EOS
187
- }
186
+ ERB
187
+ end
188
188
 
189
189
  before { subject.diff(actual_dsl).migrate }
190
190
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change index (length is Numeric) / No update' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
6
6
  t.date "birth_date", null: false
7
7
  t.string "first_name", limit: 14, null: false
@@ -10,11 +10,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
10
10
  t.date "hire_date", null: false
11
11
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
12
12
  end
13
- EOS
14
- }
13
+ ERB
14
+ end
15
15
 
16
- let(:expected_dsl) {
17
- erbh(<<-EOS)
16
+ let(:expected_dsl) do
17
+ erbh(<<-ERB)
18
18
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
19
19
  t.date "birth_date", null: false
20
20
  t.string "first_name", limit: 14, null: false
@@ -23,8 +23,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
23
23
  t.date "hire_date", null: false
24
24
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>, <%= i cond(5.0, using: :btree) %>
25
25
  end
26
- EOS
27
- }
26
+ ERB
27
+ end
28
28
 
29
29
  before { subject.diff(actual_dsl).migrate }
30
30
  subject { client }
@@ -37,8 +37,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
37
37
  end
38
38
 
39
39
  context 'when change index (length is Numeric) / Update' do
40
- let(:actual_dsl) {
41
- <<-EOS
40
+ let(:actual_dsl) do
41
+ <<-RUBY
42
42
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
43
43
  t.date "birth_date", null: false
44
44
  t.string "first_name", limit: 14, null: false
@@ -46,11 +46,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
46
46
  t.string "gender", limit: 1, null: false
47
47
  t.date "hire_date", null: false
48
48
  end
49
- EOS
50
- }
49
+ RUBY
50
+ end
51
51
 
52
- let(:expected_dsl) {
53
- erbh(<<-EOS)
52
+ let(:expected_dsl) do
53
+ erbh(<<-ERB)
54
54
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
55
55
  t.date "birth_date", null: false
56
56
  t.string "first_name", limit: 14, null: false
@@ -59,15 +59,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.date "hire_date", null: false
60
60
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>, <%= i cond(5.0, using: :btree) %>
61
61
  end
62
- EOS
63
- }
62
+ ERB
63
+ end
64
64
 
65
- let(:actual_dsl_plus_index) {
66
- actual_dsl.sub(/\bend\b/, erbh(<<-EOS))
65
+ let(:actual_dsl_plus_index) do
66
+ actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
67
67
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
68
68
  end
69
- EOS
70
- }
69
+ ERB
70
+ end
71
71
 
72
72
  before { subject.diff(actual_dsl).migrate }
73
73
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change index (length has string keys) / No update' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
6
6
  t.date "birth_date", null: false
7
7
  t.string "first_name", limit: 14, null: false
@@ -10,11 +10,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
10
10
  t.date "hire_date", null: false
11
11
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
12
12
  end
13
- EOS
14
- }
13
+ ERB
14
+ end
15
15
 
16
- let(:expected_dsl) {
17
- erbh(<<-EOS)
16
+ let(:expected_dsl) do
17
+ erbh(<<-ERB)
18
18
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
19
19
  t.date "birth_date", null: false
20
20
  t.string "first_name", limit: 14, null: false
@@ -23,8 +23,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
23
23
  t.date "hire_date", null: false
24
24
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10, "foo" => nil }') %>, <%= i cond(5.0, using: :btree) %>
25
25
  end
26
- EOS
27
- }
26
+ ERB
27
+ end
28
28
 
29
29
  before { subject.diff(actual_dsl).migrate }
30
30
  subject { client }
@@ -37,8 +37,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
37
37
  end
38
38
 
39
39
  context 'when change index (length has string keys) / Update' do
40
- let(:actual_dsl) {
41
- <<-EOS
40
+ let(:actual_dsl) do
41
+ <<-RUBY
42
42
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
43
43
  t.date "birth_date", null: false
44
44
  t.string "first_name", limit: 14, null: false
@@ -46,11 +46,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
46
46
  t.string "gender", limit: 1, null: false
47
47
  t.date "hire_date", null: false
48
48
  end
49
- EOS
50
- }
49
+ RUBY
50
+ end
51
51
 
52
- let(:expected_dsl) {
53
- erbh(<<-EOS)
52
+ let(:expected_dsl) do
53
+ erbh(<<-ERB)
54
54
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
55
55
  t.date "birth_date", null: false
56
56
  t.string "first_name", limit: 14, null: false
@@ -59,15 +59,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.date "hire_date", null: false
60
60
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10 }') %>, <%= i cond(5.0, using: :btree) %>
61
61
  end
62
- EOS
63
- }
62
+ ERB
63
+ end
64
64
 
65
- let(:actual_dsl_plus_index) {
66
- actual_dsl.sub(/\bend\b/, erbh(<<-EOS))
65
+ let(:actual_dsl_plus_index) do
66
+ actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
67
67
  t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
68
68
  end
69
- EOS
70
- }
69
+ ERB
70
+ end
71
71
 
72
72
  before { subject.diff(actual_dsl).migrate }
73
73
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change index' do
3
- let(:dsl) {
4
- erbh(<<-EOS)
3
+ let(:dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "clubs", force: :cascade do |t|
6
6
  t.string "name", default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -59,11 +59,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.date "to_date"
60
60
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
61
61
  end
62
- EOS
63
- }
62
+ ERB
63
+ end
64
64
 
65
- let(:actual_dsl) {
66
- erbh(<<-EOS)
65
+ let(:actual_dsl) do
66
+ erbh(<<-ERB)
67
67
  create_table "clubs", force: :cascade do |t|
68
68
  t.string "name", default: "", null: false
69
69
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -121,11 +121,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
121
121
  t.date "to_date"
122
122
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
123
123
  end
124
- EOS
125
- }
124
+ ERB
125
+ end
126
126
 
127
- let(:expected_dsl) {
128
- erbh(<<-EOS)
127
+ let(:expected_dsl) do
128
+ erbh(<<-ERB)
129
129
  create_table "clubs", force: :cascade do |t|
130
130
  t.string "name", default: "", null: false
131
131
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -183,8 +183,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
183
183
  t.date "to_date"
184
184
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
185
185
  end
186
- EOS
187
- }
186
+ ERB
187
+ end
188
188
 
189
189
  before { subject.diff(actual_dsl).migrate }
190
190
  subject { client }
@@ -198,10 +198,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
198
198
  }
199
199
 
200
200
  it {
201
- delta = client(:bulk_change => true).diff(expected_dsl)
201
+ delta = client(bulk_change: true).diff(expected_dsl)
202
202
  expect(delta.differ?).to be_truthy
203
203
  expect(subject.dump).to match_ruby actual_dsl
204
- expect(delta.script).to match_fuzzy <<-EOS
204
+ expect(delta.script).to match_fuzzy <<-RUBY
205
205
  change_table("dept_emp", {:bulk => true}) do |t|
206
206
  t.remove_index({:name=>"emp_no"})
207
207
  t.index(["from_date"], {:name=>"emp_no", :using=>:btree, :unique=>false})
@@ -216,12 +216,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
216
216
  t.remove_index({:name=>"emp_no"})
217
217
  t.index(["from_date"], {:name=>"emp_no", :using=>:btree, :unique=>false})
218
218
  end
219
- EOS
219
+ RUBY
220
220
 
221
221
  # XXX: Can not add an index of the same name
222
- expect {
222
+ expect do
223
223
  delta.migrate
224
- }.to raise_error(/Index name 'emp_no' on table 'dept_emp' already exists/)
224
+ end.to raise_error(/Index name 'emp_no' on table 'dept_emp' already exists/)
225
225
  }
226
226
  end
227
227
  end
@@ -1,6 +1,6 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
- let(:actual_dsl) {
3
- erbh(<<-EOS)
2
+ let(:actual_dsl) do
3
+ erbh(<<-ERB)
4
4
  create_table "employees", force: :cascade, comment: "old comment" do |t|
5
5
  t.date "birth_date", null: false
6
6
  t.string "first_name", limit: 14, null: false
@@ -8,11 +8,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
8
8
  t.string "gender", limit: 1, null: false
9
9
  t.date "hire_date", null: false
10
10
  end
11
- EOS
12
- }
11
+ ERB
12
+ end
13
13
 
14
- let(:expected_dsl) {
15
- erbh(<<-EOS)
14
+ let(:expected_dsl) do
15
+ erbh(<<-ERB)
16
16
  create_table "employees", force: :cascade, comment: "new comment" do |t|
17
17
  t.date "birth_date", null: false
18
18
  t.string "first_name", limit: 14, null: false
@@ -20,8 +20,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
20
20
  t.string "gender", limit: 1, null: false
21
21
  t.date "hire_date", null: false
22
22
  end
23
- EOS
24
- }
23
+ ERB
24
+ end
25
25
 
26
26
  before { subject.diff(actual_dsl).migrate }
27
27
 
@@ -29,11 +29,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
29
29
  subject { client }
30
30
 
31
31
  it {
32
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
32
+ expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
33
33
  [WARNING] No difference of schema configuration for table `employees` but table options differ.
34
34
  from: {:comment=>"old comment"}
35
35
  to: {:comment=>"new comment"}
36
- EOS
36
+ MSG
37
37
  delta = subject.diff(expected_dsl)
38
38
  expect(delta.differ?).to be_falsey
39
39
  expect(subject.dump).to match_ruby actual_dsl
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create_table options are different' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
6
6
  t.date "birth_date", null: false
7
7
  t.string "first_name", limit: 14, null: false
@@ -9,11 +9,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
9
9
  t.string "gender", limit: 1, null: false
10
10
  t.date "hire_date", null: false
11
11
  end
12
- EOS
13
- }
12
+ ERB
13
+ end
14
14
 
15
- let(:expected_dsl) {
16
- erbh(<<-EOS)
15
+ let(:expected_dsl) do
16
+ erbh(<<-ERB)
17
17
  create_table "employees", primary_key: "emp_no2", force: :cascade do |t|
18
18
  t.date "birth_date", null: false
19
19
  t.string "first_name", limit: 14, null: false
@@ -21,18 +21,18 @@ describe 'Ridgepole::Client#diff -> migrate' do
21
21
  t.string "gender", limit: 1, null: false
22
22
  t.date "hire_date", null: false
23
23
  end
24
- EOS
25
- }
24
+ ERB
25
+ end
26
26
 
27
27
  before { subject.diff(actual_dsl).migrate }
28
28
  subject { client }
29
29
 
30
30
  it {
31
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
31
+ expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
32
32
  [WARNING] No difference of schema configuration for table `employees` but table options differ.
33
33
  from: {:primary_key=>"emp_no"}
34
34
  to: {:primary_key=>"emp_no2"}
35
- EOS
35
+ MSG
36
36
  delta = subject.diff(expected_dsl)
37
37
  expect(delta.differ?).to be_falsey
38
38
  expect(subject.dump).to match_ruby actual_dsl
@@ -42,8 +42,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
42
42
  end
43
43
 
44
44
  context 'when create_table options are different (ignore comment)' do
45
- let(:actual_dsl) {
46
- erbh(<<-EOS)
45
+ let(:actual_dsl) do
46
+ erbh(<<-ERB)
47
47
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
48
48
  t.date "birth_date", null: false
49
49
  t.string "first_name", limit: 14, null: false
@@ -51,11 +51,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
51
51
  t.string "gender", limit: 1, null: false
52
52
  t.date "hire_date", null: false
53
53
  end
54
- EOS
55
- }
54
+ ERB
55
+ end
56
56
 
57
- let(:expected_dsl) {
58
- erbh(<<-EOS)
57
+ let(:expected_dsl) do
58
+ erbh(<<-ERB)
59
59
  create_table "employees", primary_key: "emp_no", comment: "my comment", force: :cascade do |t|
60
60
  t.date "birth_date", null: false
61
61
  t.string "first_name", limit: 14, null: false
@@ -63,8 +63,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
63
63
  t.string "gender", limit: 1, null: false
64
64
  t.date "hire_date", null: false
65
65
  end
66
- EOS
67
- }
66
+ ERB
67
+ end
68
68
 
69
69
  before { subject.diff(actual_dsl).migrate }
70
70
  subject { client(ignore_table_comment: true) }