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.
- checksums.yaml +4 -4
- data/.rubocop.yml +38 -0
- data/Appraisals +2 -2
- data/README.md +3 -9
- data/Rakefile +7 -1
- data/bin/ridgepole +97 -108
- data/gemfiles/activerecord_5.2.gemfile +1 -1
- data/lib/ridgepole/cli/config.rb +43 -43
- data/lib/ridgepole/client.rb +65 -63
- data/lib/ridgepole/default_limit.rb +26 -24
- data/lib/ridgepole/delta.rb +367 -369
- data/lib/ridgepole/diff.rb +366 -377
- data/lib/ridgepole/dsl_parser.rb +22 -20
- data/lib/ridgepole/dsl_parser/context.rb +95 -93
- data/lib/ridgepole/dsl_parser/table_definition.rb +125 -123
- data/lib/ridgepole/dumper.rb +73 -71
- data/lib/ridgepole/execute_expander.rb +55 -55
- data/lib/ridgepole/ext/abstract_mysql_adapter/dump_auto_increment.rb +3 -3
- data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +1 -1
- data/lib/ridgepole/ext/pp_sort_hash.rb +14 -14
- data/lib/ridgepole/ext/schema_dumper.rb +1 -1
- data/lib/ridgepole/external_sql_executer.rb +20 -20
- data/lib/ridgepole/logger.rb +17 -15
- data/lib/ridgepole/migration_ext.rb +6 -8
- data/lib/ridgepole/schema_statements_ext.rb +3 -3
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +11 -10
- data/spec/cli_helper.rb +2 -2
- data/spec/erb_helper.rb +6 -2
- data/spec/hide_pending_formatter.rb +5 -4
- data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +8 -8
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +8 -8
- data/spec/mysql/bigint_pk/int_pk_spec.rb +13 -13
- data/spec/mysql/cli/config_spec.rb +52 -53
- data/spec/mysql/cli/ridgepole_spec.rb +111 -111
- data/spec/mysql/collation/collation_spec.rb +39 -39
- data/spec/mysql/comment/comment_spec.rb +36 -36
- data/spec/mysql/default_lambda/default_lambda_spec.rb +30 -30
- data/spec/mysql/diff/diff2_spec.rb +18 -18
- data/spec/mysql/diff/diff_spec.rb +11 -11
- data/spec/mysql/dump/dump_class_method_spec.rb +2 -2
- data/spec/mysql/dump/dump_some_tables_spec.rb +14 -14
- data/spec/mysql/dump/dump_spec.rb +2 -2
- data/spec/mysql/dump/dump_unknown_column_type_spec.rb +3 -3
- data/spec/mysql/dump/dump_without_table_options_spec.rb +8 -8
- data/spec/mysql/fk/migrate_change_fk_spec.rb +40 -40
- data/spec/mysql/fk/migrate_create_fk_spec.rb +40 -40
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +60 -60
- data/spec/mysql/migrate/check_orphan_index_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +43 -43
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +50 -50
- data/spec/mysql/migrate/migrate_add_column_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +20 -20
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +60 -60
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +40 -40
- data/spec/mysql/migrate/migrate_change_column7_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_column8_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +48 -48
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_change_column_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +20 -20
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +43 -43
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +20 -20
- data/spec/mysql/migrate/migrate_change_index8_spec.rb +20 -20
- data/spec/mysql/migrate/migrate_change_index_spec.rb +17 -17
- data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +10 -10
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +37 -37
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_create_index_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_create_table_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +10 -10
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +11 -11
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_empty_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_execute_spec.rb +55 -55
- data/spec/mysql/migrate/migrate_log_file_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_noop_spec.rb +19 -19
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +17 -17
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +26 -26
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_same_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_script_error_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +64 -64
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +29 -29
- data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +18 -18
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +8 -8
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +8 -8
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +8 -8
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
- data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +7 -7
- data/spec/mysql57/json/add_json_column_spec.rb +8 -8
- data/spec/mysql57/json/change_json_column_spec.rb +24 -24
- data/spec/mysql57/json/drop_json_column_spec.rb +8 -8
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +9 -9
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +9 -9
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +9 -9
- data/spec/postgresql/diff/diff_spec.rb +18 -18
- data/spec/postgresql/dump/dump_spec.rb +2 -2
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +24 -24
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +40 -40
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +44 -44
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +21 -21
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +2 -2
- data/spec/postgresql/migrate/migrate_bigint_spec.rb +12 -12
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +19 -19
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +13 -13
- data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +19 -19
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +11 -11
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -12
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +11 -11
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_primary_key_spec.rb +97 -0
- data/spec/postgresql/migrate/migrate_references_spec.rb +24 -24
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +11 -11
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +16 -16
- data/spec/postgresql/migrate/migrate_same_spec.rb +4 -4
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +12 -12
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +30 -30
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +22 -22
- data/spec/processing_for_travis.rb +1 -1
- data/spec/spec_condition.rb +2 -2
- data/spec/spec_const.rb +9 -9
- data/spec/spec_helper.rb +21 -23
- 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(<<-
|
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
|
-
|
20
|
-
|
19
|
+
ERB
|
20
|
+
end
|
21
21
|
|
22
|
-
let(:expected_dsl)
|
23
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
78
|
-
|
77
|
+
ERB
|
78
|
+
end
|
79
79
|
|
80
|
-
let(:expected_dsl)
|
81
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
136
|
-
|
135
|
+
ERB
|
136
|
+
end
|
137
137
|
|
138
|
-
let(:expected_dsl)
|
139
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
189
|
-
|
188
|
+
ERB
|
189
|
+
end
|
190
190
|
|
191
|
-
let(:expected_dsl)
|
192
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
63
|
-
|
62
|
+
ERB
|
63
|
+
end
|
64
64
|
|
65
|
-
let(:actual_dsl)
|
66
|
-
erbh(<<-
|
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
|
-
|
122
|
-
|
121
|
+
ERB
|
122
|
+
end
|
123
123
|
|
124
|
-
let(:expected_dsl)
|
125
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
63
|
-
|
62
|
+
ERB
|
63
|
+
end
|
64
64
|
|
65
|
-
let(:actual_dsl)
|
66
|
-
erbh(<<-
|
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
|
-
|
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(:
|
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(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
63
|
-
|
62
|
+
ERB
|
63
|
+
end
|
64
64
|
|
65
|
-
let(:actual_dsl)
|
66
|
-
erbh(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
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(<<-
|
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
|
-
|
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
|
-
<<-
|
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
|
-
|
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 <<-
|
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
|
-
|
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
|
-
<<-
|
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
|
-
|
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 <<-
|
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
|
-
|
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(<<-
|
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
|
-
|
63
|
-
|
62
|
+
ERB
|
63
|
+
end
|
64
64
|
|
65
|
-
let(:actual_dsl)
|
66
|
-
erbh(<<-
|
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
|
-
|
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 = <<-
|
118
|
+
script = <<-SHELL
|
119
119
|
echo "$1" | #{MYSQL_CLI} #{TEST_SCHEMA}
|
120
|
-
|
120
|
+
SHELL
|
121
121
|
|
122
122
|
tempfile(File.basename(__FILE__), script) do |path|
|
123
|
-
FileUtils.chmod(
|
123
|
+
FileUtils.chmod(0o755, path)
|
124
124
|
delta.migrate(external_script: path)
|
125
125
|
end
|
126
126
|
|