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
- describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
1
+ describe 'Ridgepole::Client#diff -> migrate', condition: '>= 5.1.0' do
2
2
  context 'with warning' do
3
- let(:actual_dsl) {
4
- erbh(<<-EOS)
3
+ let(:actual_dsl) do
4
+ erbh(<<-ERB)
5
5
  create_table "dept_manager", force: :cascade do |t|
6
6
  t.string "dept_no", limit: 4, null: false
7
7
  t.date "from_date", null: false
@@ -16,11 +16,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
16
16
  t.string "gender", limit: 1, null: false
17
17
  t.date "hire_date", null: false
18
18
  end
19
- EOS
20
- }
19
+ ERB
20
+ end
21
21
 
22
- let(:expected_dsl) {
23
- erbh(<<-EOS)
22
+ let(:expected_dsl) do
23
+ erbh(<<-ERB)
24
24
  create_table "dept_manager", force: :cascade do |t|
25
25
  t.integer "employee_id"
26
26
  t.string "dept_no", limit: 4, null: false
@@ -36,18 +36,18 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
36
36
  t.string "gender", limit: 1, null: false
37
37
  t.date "hire_date", null: false
38
38
  end
39
- EOS
40
- }
39
+ ERB
40
+ end
41
41
 
42
42
  before { subject.diff(actual_dsl).migrate }
43
43
  subject { client(check_relation_type: 'bigint') }
44
44
 
45
45
  it {
46
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
46
+ expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
47
47
  [WARNING] Relation column type is different.
48
48
  employees.id: {:type=>:bigint}
49
49
  dept_manager.employee_id: {:type=>:integer}
50
- EOS
50
+ MSG
51
51
 
52
52
  delta = subject.diff(expected_dsl)
53
53
  expect(delta.differ?).to be_truthy
@@ -58,8 +58,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
58
58
  end
59
59
 
60
60
  context 'with unsigned warning' do
61
- let(:actual_dsl) {
62
- erbh(<<-EOS)
61
+ let(:actual_dsl) do
62
+ erbh(<<-ERB)
63
63
  create_table "dept_manager", force: :cascade do |t|
64
64
  t.string "dept_no", limit: 4, null: false
65
65
  t.date "from_date", null: false
@@ -74,11 +74,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
74
74
  t.string "gender", limit: 1, null: false
75
75
  t.date "hire_date", null: false
76
76
  end
77
- EOS
78
- }
77
+ ERB
78
+ end
79
79
 
80
- let(:expected_dsl) {
81
- erbh(<<-EOS)
80
+ let(:expected_dsl) do
81
+ erbh(<<-ERB)
82
82
  create_table "dept_manager", force: :cascade do |t|
83
83
  t.bigint "employee_id"
84
84
  t.string "dept_no", limit: 4, null: false
@@ -94,18 +94,18 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
94
94
  t.string "gender", limit: 1, null: false
95
95
  t.date "hire_date", null: false
96
96
  end
97
- EOS
98
- }
97
+ ERB
98
+ end
99
99
 
100
100
  before { subject.diff(actual_dsl).migrate }
101
101
  subject { client(check_relation_type: 'bigint') }
102
102
 
103
103
  it {
104
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-EOS)
104
+ expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
105
105
  [WARNING] Relation column type is different.
106
106
  employees.id: {:type=>:bigint, :unsigned=>true}
107
107
  dept_manager.employee_id: {:type=>:bigint}
108
- EOS
108
+ MSG
109
109
 
110
110
  delta = subject.diff(expected_dsl)
111
111
  expect(delta.differ?).to be_truthy
@@ -116,8 +116,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
116
116
  end
117
117
 
118
118
  context 'without warning' do
119
- let(:actual_dsl) {
120
- erbh(<<-EOS)
119
+ let(:actual_dsl) do
120
+ erbh(<<-ERB)
121
121
  create_table "dept_manager", force: :cascade do |t|
122
122
  t.string "dept_no", limit: 4, null: false
123
123
  t.date "from_date", null: false
@@ -132,11 +132,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
132
132
  t.string "gender", limit: 1, null: false
133
133
  t.date "hire_date", null: false
134
134
  end
135
- EOS
136
- }
135
+ ERB
136
+ end
137
137
 
138
- let(:expected_dsl) {
139
- erbh(<<-EOS)
138
+ let(:expected_dsl) do
139
+ erbh(<<-ERB)
140
140
  create_table "dept_manager", force: :cascade do |t|
141
141
  t.bigint "employee_id"
142
142
  t.string "dept_no", limit: 4, null: false
@@ -152,8 +152,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
152
152
  t.string "gender", limit: 1, null: false
153
153
  t.date "hire_date", null: false
154
154
  end
155
- EOS
156
- }
155
+ ERB
156
+ end
157
157
 
158
158
  before { subject.diff(actual_dsl).migrate }
159
159
  subject { client(check_relation_type: 'bigint') }
@@ -169,8 +169,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
169
169
  end
170
170
 
171
171
  context 'with unsigned warning' do
172
- let(:actual_dsl) {
173
- erbh(<<-EOS)
172
+ let(:actual_dsl) do
173
+ erbh(<<-ERB)
174
174
  create_table "dept_manager", force: :cascade do |t|
175
175
  t.string "dept_no", limit: 4, null: false
176
176
  t.date "from_date", null: false
@@ -185,11 +185,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
185
185
  t.string "gender", limit: 1, null: false
186
186
  t.date "hire_date", null: false
187
187
  end
188
- EOS
189
- }
188
+ ERB
189
+ end
190
190
 
191
- let(:expected_dsl) {
192
- erbh(<<-EOS)
191
+ let(:expected_dsl) do
192
+ erbh(<<-ERB)
193
193
  create_table "dept_manager", force: :cascade do |t|
194
194
  t.bigint "employee_id", unsigned: true
195
195
  t.string "dept_no", limit: 4, null: false
@@ -205,8 +205,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
205
205
  t.string "gender", limit: 1, null: false
206
206
  t.date "hire_date", null: false
207
207
  end
208
- EOS
209
- }
208
+ ERB
209
+ end
210
210
 
211
211
  before { subject.diff(actual_dsl).migrate }
212
212
  subject { client(check_relation_type: 'bigint') }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create index (use t.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
  end
@@ -118,11 +118,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
118
118
  t.date "from_date", null: false
119
119
  t.date "to_date"
120
120
  end
121
- EOS
122
- }
121
+ ERB
122
+ end
123
123
 
124
- let(:expected_dsl) {
125
- erbh(<<-EOS)
124
+ let(:expected_dsl) do
125
+ erbh(<<-ERB)
126
126
  create_table "clubs", force: :cascade do |t|
127
127
  t.string "name", limit: 255, default: "", null: false
128
128
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -184,8 +184,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
184
184
  t.date "to_date"
185
185
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
186
186
  end
187
- EOS
188
- }
187
+ ERB
188
+ end
189
189
 
190
190
  before { subject.diff(actual_dsl).migrate }
191
191
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create 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
  end
@@ -118,8 +118,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
118
118
  t.date "from_date", null: false
119
119
  t.date "to_date"
120
120
  end
121
- EOS
122
- }
121
+ ERB
122
+ end
123
123
 
124
124
  let(:expected_dsl) { dsl }
125
125
 
@@ -135,10 +135,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
135
135
  }
136
136
 
137
137
  it {
138
- delta = client(:bulk_change => true).diff(expected_dsl)
138
+ delta = client(bulk_change: true).diff(expected_dsl)
139
139
  expect(delta.differ?).to be_truthy
140
140
  expect(subject.dump).to match_ruby actual_dsl
141
- expect(delta.script).to match_fuzzy erbh(<<-EOS)
141
+ expect(delta.script).to match_fuzzy erbh(<<-ERB)
142
142
  change_table("clubs", {:bulk => true}) do |t|
143
143
  t.index(["name"], <%= {:name=>"idx_name", :unique=>true} + cond(5.0, using: :btree) %>)
144
144
  end
@@ -150,7 +150,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
150
150
  change_table("titles", {:bulk => true}) do |t|
151
151
  t.index(["emp_no"], <%= {:name=>"emp_no"} + cond(5.0, using: :btree) %>)
152
152
  end
153
- EOS
153
+ ERB
154
154
  delta.migrate
155
155
  expect(subject.dump).to match_ruby expected_dsl
156
156
  }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create table' 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 "departments", primary_key: "dept_no", force: :cascade do |t|
68
68
  t.string "dept_name", limit: 40, null: false
69
69
  t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -102,8 +102,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
102
102
  t.date "to_date"
103
103
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
104
104
  end
105
- EOS
106
- }
105
+ ERB
106
+ end
107
107
 
108
108
  let(:expected_dsl) { dsl }
109
109
 
@@ -2,8 +2,8 @@ describe 'Ridgepole::Client#diff -> migrate (with index)' do
2
2
  context 'when create table' do
3
3
  let(:actual_dsl) { '' }
4
4
 
5
- let(:expected_dsl) {
6
- erbh(<<-EOS)
5
+ let(:expected_dsl) do
6
+ erbh(<<-ERB)
7
7
  create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
8
8
  t.integer "emp_no", null: false
9
9
  t.string "dept_no", null: false
@@ -12,8 +12,8 @@ describe 'Ridgepole::Client#diff -> migrate (with index)' do
12
12
  t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
13
13
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
14
14
  end
15
- EOS
16
- }
15
+ ERB
16
+ end
17
17
 
18
18
  before { subject.diff(actual_dsl).migrate }
19
19
  subject { client(create_table_with_index: true) }
@@ -22,7 +22,7 @@ describe 'Ridgepole::Client#diff -> migrate (with index)' do
22
22
  delta = subject.diff(expected_dsl)
23
23
  expect(delta.differ?).to be_truthy
24
24
 
25
- expect(delta.script).to match_fuzzy erbh(<<-EOS)
25
+ expect(delta.script).to match_fuzzy erbh(<<-ERB)
26
26
  create_table("dept_emp", {:primary_key=>["emp_no", "dept_no"]}) do |t|
27
27
  t.column("emp_no", :"integer", {:null=>false, :limit=>4})
28
28
  t.column("dept_no", :"string", {:null=>false, :limit=>255})
@@ -31,7 +31,7 @@ describe 'Ridgepole::Client#diff -> migrate (with index)' do
31
31
  t.index(["dept_no"], <%= {:name=>"dept_no"} + cond(5.0, using: :btree) %>)
32
32
  t.index(["emp_no"], <%= {:name=>"emp_no"} + cond(5.0, using: :btree) %>)
33
33
  end
34
- EOS
34
+ ERB
35
35
 
36
36
  expect(subject.dump).to match_ruby actual_dsl
37
37
  delta.migrate
@@ -1,15 +1,15 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create table' do
3
- let(:expected_dsl) {
4
- <<-EOS
3
+ let(:expected_dsl) do
4
+ <<-RUBY
5
5
  create_table "employee_clubs", force: :cascade do |t|
6
6
  t.integer "emp_no", null: false, unsigned: true
7
7
  t.integer "club_id", null: false, unsigned: true
8
8
  end
9
9
 
10
10
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
11
- EOS
12
- }
11
+ RUBY
12
+ end
13
13
 
14
14
  subject { client(table_options: 'ENGINE=MyISAM CHARSET=utf8') }
15
15
 
@@ -17,27 +17,27 @@ describe 'Ridgepole::Client#diff -> migrate' do
17
17
  delta = subject.diff(expected_dsl)
18
18
  expect(delta.differ?).to be_truthy
19
19
 
20
- expect(delta.script).to match_fuzzy <<-EOS
20
+ expect(delta.script).to match_fuzzy <<-RUBY
21
21
  create_table("employee_clubs", {:options=>"ENGINE=MyISAM CHARSET=utf8"}) do |t|
22
22
  t.column("emp_no", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
23
23
  t.column("club_id", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
24
24
  end
25
25
  add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
26
- EOS
26
+ RUBY
27
27
  }
28
28
  end
29
29
 
30
30
  context 'when create table (table definition options takes precedence)' do
31
- let(:expected_dsl) {
32
- <<-EOS
31
+ let(:expected_dsl) do
32
+ <<-RUBY
33
33
  create_table "employee_clubs", force: :cascade, options: "ENGINE=InnoDB CHARSET=utf8mb4" do |t|
34
34
  t.integer "emp_no", null: false, unsigned: true
35
35
  t.integer "club_id", null: false, unsigned: true
36
36
  end
37
37
 
38
38
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
39
- EOS
40
- }
39
+ RUBY
40
+ end
41
41
 
42
42
  subject { client(table_options: 'ENGINE=MyISAM CHARSET=utf8') }
43
43
 
@@ -45,13 +45,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
45
45
  delta = subject.diff(expected_dsl)
46
46
  expect(delta.differ?).to be_truthy
47
47
 
48
- expect(delta.script).to match_fuzzy <<-EOS
48
+ expect(delta.script).to match_fuzzy <<-RUBY
49
49
  create_table("employee_clubs", {:options=>"ENGINE=InnoDB CHARSET=utf8mb4"}) do |t|
50
50
  t.column("emp_no", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
51
51
  t.column("club_id", :"integer", {:null=>false, :unsigned=>true, :limit=>4})
52
52
  end
53
53
  add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
54
- EOS
54
+ RUBY
55
55
  }
56
56
  end
57
57
  end
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when create table' 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 "departments", primary_key: "dept_no", force: :cascade do |t|
68
68
  t.string "dept_name", limit: 40, null: false
69
69
  t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -102,8 +102,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
102
102
  t.date "to_date"
103
103
  t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
104
104
  end
105
- EOS
106
- }
105
+ ERB
106
+ end
107
107
 
108
108
  let(:expected_dsl) { dsl }
109
109
 
@@ -115,12 +115,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
115
115
  expect(delta.differ?).to be_truthy
116
116
  expect(subject.dump).to match_ruby actual_dsl
117
117
 
118
- script = <<-EOS
118
+ script = <<-SHELL
119
119
  echo "$1" | #{MYSQL_CLI} #{TEST_SCHEMA}
120
- EOS
120
+ SHELL
121
121
 
122
122
  tempfile(File.basename(__FILE__), script) do |path|
123
- FileUtils.chmod(0755, path)
123
+ FileUtils.chmod(0o755, path)
124
124
  delta.migrate(external_script: path)
125
125
  end
126
126