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 add column' 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", limit: 255, default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
57
57
  t.date "to_date"
58
58
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
59
59
  end
60
- EOS
61
- }
60
+ ERB
61
+ end
62
62
 
63
- let(:expected_dsl) {
64
- erbh(<<-EOS)
63
+ let(:expected_dsl) do
64
+ erbh(<<-ERB)
65
65
  create_table "clubs", force: :cascade do |t|
66
66
  t.string "name", limit: 255, default: "", null: false
67
67
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -120,8 +120,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
120
120
  t.date "to_date"
121
121
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
122
122
  end
123
- EOS
124
- }
123
+ ERB
124
+ end
125
125
 
126
126
  before { subject.diff(actual_dsl).migrate }
127
127
  subject { client }
@@ -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 <<-EOS
141
+ expect(delta.script).to match_fuzzy <<-RUBY
142
142
  change_table("employee_clubs", {:bulk => true}) do |t|
143
143
  t.column("any_col", :string, {:limit=>255, :null=>false})
144
144
  end
@@ -147,26 +147,26 @@ describe 'Ridgepole::Client#diff -> migrate' do
147
147
  t.column("age", :integer, {:null=>false})
148
148
  t.column("updated_at", :date, {})
149
149
  end
150
- EOS
150
+ RUBY
151
151
  delta.migrate
152
152
  expect(subject.dump).to match_ruby expected_dsl
153
153
  }
154
154
  end
155
155
 
156
156
  context 'when add column (int/noop)' do
157
- let(:actual_dsl) {
158
- erbh(<<-EOS)
157
+ let(:actual_dsl) do
158
+ erbh(<<-ERB)
159
159
  create_table "dept_emp", id: false, force: :cascade do |t|
160
160
  t.integer "emp_no", null: false
161
161
  t.string "dept_no", limit: 4, null: false
162
162
  t.date "from_date", null: false
163
163
  t.date "to_date", null: false
164
164
  end
165
- EOS
166
- }
165
+ ERB
166
+ end
167
167
 
168
- let(:expected_dsl) {
169
- erbh(<<-EOS)
168
+ let(:expected_dsl) do
169
+ erbh(<<-ERB)
170
170
  create_table "dept_emp", id: false, force: :cascade do |t|
171
171
  t.integer "emp_no", null: false
172
172
  t.integer "emp_no2", null: false
@@ -174,8 +174,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
174
174
  t.date "from_date", null: false
175
175
  t.date "to_date", null: false
176
176
  end
177
- EOS
178
- }
177
+ ERB
178
+ end
179
179
 
180
180
  before { subject.diff(actual_dsl).migrate }
181
181
  subject { client }
@@ -184,11 +184,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
184
184
  delta = subject.diff(expected_dsl)
185
185
  expect(delta.differ?).to be_truthy
186
186
  expect(subject.dump).to match_ruby actual_dsl
187
- migrated, sql = delta.migrate(:noop => true)
187
+ migrated, sql = delta.migrate(noop: true)
188
188
  expect(migrated).to be_truthy
189
189
  expect(subject.dump).to match_ruby actual_dsl
190
190
 
191
- expect(sql).to match_fuzzy("ALTER TABLE \"dept_emp\" ADD \"emp_no2\" integer NOT NULL")
191
+ expect(sql).to match_fuzzy('ALTER TABLE "dept_emp" ADD "emp_no2" integer NOT NULL')
192
192
  }
193
193
  end
194
194
  end
@@ -3,14 +3,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
3
3
 
4
4
  context 'when add_index contains expression' do
5
5
  let(:actual_dsl) { '' }
6
- let(:expected_dsl) { erbh(<<-EOS) }
6
+ let(:expected_dsl) { erbh(<<-ERB) }
7
7
  create_table "users", force: :cascade do |t|
8
8
  t.string "name", null: false
9
9
  t.datetime "created_at", null: false
10
10
  t.datetime "updated_at", null: false
11
11
  t.index "lower((name)::text)", name: "index_users_on_lower_name", <%= i cond(5.0, using: :btree) %>
12
12
  end
13
- EOS
13
+ ERB
14
14
 
15
15
  specify do
16
16
  delta = subject.diff(expected_dsl)
@@ -2,13 +2,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when add bigint column' 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 "bigint_test", id: false, force: :cascade do |t|
8
8
  t.bigint "b"
9
9
  end
10
- EOS
11
- }
10
+ ERB
11
+ end
12
12
 
13
13
  before { subject.diff(actual_dsl).migrate }
14
14
  subject { client }
@@ -22,21 +22,21 @@ describe 'Ridgepole::Client#diff -> migrate' do
22
22
  end
23
23
 
24
24
  context 'when no change' do
25
- let(:dsl) {
26
- erbh(<<-EOS)
25
+ let(:dsl) do
26
+ erbh(<<-ERB)
27
27
  create_table "bigint_test", id: false, force: :cascade do |t|
28
28
  t.bigint "b"
29
29
  end
30
- EOS
31
- }
30
+ ERB
31
+ end
32
32
 
33
- let(:expected_dsl) {
34
- erbh(<<-EOS)
33
+ let(:expected_dsl) do
34
+ erbh(<<-ERB)
35
35
  create_table "bigint_test", id: false, force: :cascade do |t|
36
36
  t.bigint "b"
37
37
  end
38
- EOS
39
- }
38
+ ERB
39
+ end
40
40
 
41
41
  before { subject.diff(dsl).migrate }
42
42
  subject { client }
@@ -1,26 +1,26 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change column' do
3
- let(:actual_dsl) {
4
- <<-EOS
3
+ let(:actual_dsl) do
4
+ <<-RUBY
5
5
  create_table "salaries", id: false, force: :cascade do |t|
6
6
  t.integer "emp_no", default: 0, null: false
7
7
  t.integer "salary", null: false
8
8
  t.date "from_date", null: false
9
9
  t.date "to_date", null: false
10
10
  end
11
- EOS
12
- }
11
+ RUBY
12
+ end
13
13
 
14
- let(:expected_dsl) {
15
- <<-EOS
14
+ let(:expected_dsl) do
15
+ <<-RUBY
16
16
  create_table "salaries", id: false, force: :cascade do |t|
17
17
  t.integer "emp_no", null: false
18
18
  t.integer "salary", null: false
19
19
  t.date "from_date", null: false
20
20
  t.date "to_date", null: false
21
21
  end
22
- EOS
23
- }
22
+ RUBY
23
+ end
24
24
 
25
25
  before { subject.diff(actual_dsl).migrate }
26
26
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change column' 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", limit: 255, default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
57
57
  t.date "to_date"
58
58
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
59
59
  end
60
- EOS
61
- }
60
+ ERB
61
+ end
62
62
 
63
- let(:expected_dsl) {
64
- erbh(<<-EOS)
63
+ let(:expected_dsl) do
64
+ erbh(<<-ERB)
65
65
  create_table "clubs", force: :cascade do |t|
66
66
  t.string "name", limit: 255, default: "", null: false
67
67
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -117,8 +117,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
117
117
  t.date "to_date"
118
118
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
119
119
  end
120
- EOS
121
- }
120
+ ERB
121
+ end
122
122
 
123
123
  before { subject.diff(actual_dsl).migrate }
124
124
  subject { client }
@@ -132,10 +132,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
132
132
  }
133
133
 
134
134
  it {
135
- delta = client(:bulk_change => true).diff(expected_dsl)
135
+ delta = client(bulk_change: true).diff(expected_dsl)
136
136
  expect(delta.differ?).to be_truthy
137
137
  expect(subject.dump).to match_ruby actual_dsl
138
- expect(delta.script).to match_fuzzy <<-EOS
138
+ expect(delta.script).to match_fuzzy <<-RUBY
139
139
  change_table("employee_clubs", {:bulk => true}) do |t|
140
140
  t.change("club_id", :integer, {:null=>true, :default=>nil})
141
141
  end
@@ -143,30 +143,30 @@ describe 'Ridgepole::Client#diff -> migrate' do
143
143
  change_table("employees", {:bulk => true}) do |t|
144
144
  t.change("last_name", :string, {:limit=>20, :default=>"XXX"})
145
145
  end
146
- EOS
146
+ RUBY
147
147
  delta.migrate
148
148
  expect(subject.dump).to match_ruby expected_dsl
149
149
  }
150
150
  end
151
151
 
152
152
  context 'when string/text without limit (no change)' do
153
- let(:actual_dsl) {
154
- erbh(<<-EOS)
153
+ let(:actual_dsl) do
154
+ erbh(<<-ERB)
155
155
  create_table "clubs", force: :cascade do |t|
156
156
  t.string "name", default: "", null: false
157
157
  t.text "desc"
158
158
  end
159
- EOS
160
- }
159
+ ERB
160
+ end
161
161
 
162
- let(:expected_dsl) {
163
- erbh(<<-EOS)
162
+ let(:expected_dsl) do
163
+ erbh(<<-ERB)
164
164
  create_table "clubs", force: :cascade do |t|
165
165
  t.string "name", default: "", null: false
166
166
  t.text "desc"
167
167
  end
168
- EOS
169
- }
168
+ ERB
169
+ end
170
170
 
171
171
  before { subject.diff(actual_dsl).migrate }
172
172
  subject { client }
@@ -1,7 +1,7 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when change 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", limit: 255, default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -58,11 +58,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
58
58
  t.date "to_date"
59
59
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
60
60
  end
61
- EOS
62
- }
61
+ ERB
62
+ end
63
63
 
64
- let(:expected_dsl) {
65
- erbh(<<-EOS)
64
+ let(:expected_dsl) do
65
+ erbh(<<-ERB)
66
66
  create_table "clubs", force: :cascade do |t|
67
67
  t.string "name", limit: 255, default: "", null: false
68
68
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -119,8 +119,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
119
119
  t.date "to_date"
120
120
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
121
121
  end
122
- EOS
123
- }
122
+ ERB
123
+ end
124
124
 
125
125
  before { subject.diff(actual_dsl).migrate }
126
126
  subject { client }
@@ -134,10 +134,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
134
134
  }
135
135
 
136
136
  it {
137
- delta = client(:bulk_change => true).diff(expected_dsl)
137
+ delta = client(bulk_change: true).diff(expected_dsl)
138
138
  expect(delta.differ?).to be_truthy
139
139
  expect(subject.dump).to match_ruby actual_dsl
140
- expect(delta.script).to match_fuzzy <<-EOS
140
+ expect(delta.script).to match_fuzzy <<-RUBY
141
141
  change_table("dept_emp", {:bulk => true}) do |t|
142
142
  t.remove_index({:name=>"idx_dept_emp_emp_no"})
143
143
  t.index(["from_date"], {:name=>"idx_dept_emp_emp_no", :using=>:btree, :unique=>false})
@@ -152,11 +152,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
152
152
  t.remove_index({:name=>"idx_salaries_emp_no"})
153
153
  t.index(["from_date"], {:name=>"idx_salaries_emp_no", :using=>:btree, :unique=>false})
154
154
  end
155
- EOS
155
+ RUBY
156
156
 
157
- expect {
157
+ expect do
158
158
  delta.migrate
159
- }.to_not raise_error
159
+ end.to_not raise_error
160
160
  }
161
161
  end
162
162
  end
@@ -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.string "dept_no", limit: 4, null: false
26
26
  t.date "from_date", 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: 'bigserial') }
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=>:integer}
49
49
  dept_manager.employee_id: {:type=>:bigint}
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 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.string "dept_no", limit: 4, null: false
84
84
  t.date "from_date", null: false
@@ -94,8 +94,8 @@ 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: 'bigserial') }
@@ -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", limit: 255, default: "", null: false
7
7
  t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
57
57
  t.date "to_date"
58
58
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
59
59
  end
60
- EOS
61
- }
60
+ ERB
61
+ end
62
62
 
63
- let(:actual_dsl) {
64
- erbh(<<-EOS)
63
+ let(:actual_dsl) do
64
+ erbh(<<-ERB)
65
65
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
66
66
  t.string "dept_name", limit: 40, null: false
67
67
  end
@@ -99,8 +99,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
99
99
  t.date "to_date"
100
100
  t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
101
101
  end
102
- EOS
103
- }
102
+ ERB
103
+ end
104
104
 
105
105
  let(:expected_dsl) { dsl }
106
106