ridgepole 0.8.12 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +27 -20
- data/.rubocop.yml +5 -4
- data/.simplecov +6 -0
- data/Appraisals +4 -5
- data/README.md +22 -41
- data/bin/ridgepole +13 -3
- data/gemfiles/{activerecord_5.0.gemfile → activerecord_6.1.gemfile} +1 -2
- data/lib/ridgepole/client.rb +8 -3
- data/lib/ridgepole/default_limit.rb +1 -1
- data/lib/ridgepole/delta.rb +16 -1
- data/lib/ridgepole/diff.rb +50 -31
- data/lib/ridgepole/dsl_parser/table_definition.rb +49 -42
- data/lib/ridgepole/execute_expander.rb +10 -1
- data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +9 -1
- data/lib/ridgepole/external_sql_executer.rb +12 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +6 -3
- data/spec/erb_helper.rb +1 -1
- data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +2 -2
- data/spec/mysql/bigint_pk/int_pk_spec.rb +1 -1
- data/spec/mysql/cli/ridgepole_spec.rb +35 -1
- data/spec/mysql/collation/collation_spec.rb +14 -14
- data/spec/mysql/comment/comment_spec.rb +9 -9
- data/spec/mysql/diff/diff2_spec.rb +5 -5
- data/spec/mysql/diff/diff_spec.rb +3 -3
- data/spec/mysql/dump/dump_class_method_spec.rb +13 -13
- data/spec/mysql/dump/dump_some_tables_spec.rb +4 -4
- data/spec/mysql/dump/dump_spec.rb +13 -13
- data/spec/mysql/dump/dump_unknown_column_type_spec.rb +2 -2
- data/spec/mysql/dump/dump_without_table_options_spec.rb +2 -2
- data/spec/mysql/fk/migrate_change_fk2_spec.rb +2 -2
- data/spec/mysql/fk/migrate_change_fk_spec.rb +88 -20
- data/spec/mysql/fk/migrate_create_fk_spec.rb +77 -22
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +81 -26
- data/spec/mysql/fk/migrate_fk_with_column_spec.rb +16 -16
- data/spec/mysql/fk/migrate_ignore_fk_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_add_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +106 -18
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +10 -10
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +3 -3
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +7 -7
- data/spec/mysql/migrate/migrate_change_column8_spec.rb +38 -5
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +2 -14
- data/spec/mysql/migrate/migrate_change_column_spec.rb +21 -21
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +7 -7
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +6 -6
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +27 -27
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index8_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_change_index_spec.rb +34 -28
- data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_create_index_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_create_table_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +1 -1
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +15 -15
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_empty_spec.rb +9 -9
- data/spec/mysql/migrate/migrate_execute_spec.rb +32 -32
- data/spec/mysql/migrate/migrate_ignore_column_spec.rb +4 -4
- data/spec/mysql/migrate/migrate_ignore_index_spec.rb +5 -5
- data/spec/mysql/migrate/migrate_log_file_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_noop_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +31 -6
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +22 -22
- data/spec/mysql/migrate/migrate_same_spec.rb +13 -13
- data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +18 -18
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +2 -2
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +9 -9
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +5 -5
- data/spec/mysql57/json/add_json_column_spec.rb +2 -2
- data/spec/mysql57/json/change_json_column_spec.rb +6 -6
- data/spec/mysql57/json/drop_json_column_spec.rb +2 -2
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +1 -1
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +1 -1
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +1 -1
- data/spec/postgresql/dump/dump_spec.rb +13 -13
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +5 -5
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +27 -20
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +20 -16
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +14 -14
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +29 -22
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +17 -17
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +15 -15
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +16 -16
- data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_primary_key_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_references_spec.rb +6 -6
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_same_spec.rb +13 -13
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +3 -3
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +4 -4
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +4 -4
- data/spec/processing_for_ci.rb +13 -0
- data/spec/spec_const.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- metadata +68 -43
- data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +0 -31
- data/omnibus-ridgepole/.gitignore +0 -10
- data/omnibus-ridgepole/Dockerfile.centos +0 -25
- data/omnibus-ridgepole/Dockerfile.ubuntu +0 -21
- data/omnibus-ridgepole/Gemfile +0 -24
- data/omnibus-ridgepole/README.md +0 -15
- data/omnibus-ridgepole/Rakefile +0 -38
- data/omnibus-ridgepole/config/projects/ridgepole.rb +0 -27
- data/omnibus-ridgepole/config/software/ridgepole.rb +0 -13
- data/omnibus-ridgepole/omnibus.rb +0 -54
- data/omnibus-ridgepole/package-scripts/ridgepole/postinst +0 -1
- data/omnibus-ridgepole/package-scripts/ridgepole/postrm +0 -1
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +0 -47
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +0 -141
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +0 -141
- data/spec/processing_for_travis.rb +0 -11
@@ -10,7 +10,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
10
10
|
t.string "last_name", limit: 16, null: false
|
11
11
|
t.string "gender", limit: 1, null: false
|
12
12
|
t.date "hire_date", null: false
|
13
|
-
t.index ["gender"], name: "gender"
|
13
|
+
t.index ["gender"], name: "gender"
|
14
14
|
end
|
15
15
|
ERB
|
16
16
|
end
|
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
23
23
|
t.string "last_name", limit: 16, null: false
|
24
24
|
t.string "gender", limit: 1, null: false
|
25
25
|
t.date :hire_date, null: false
|
26
|
-
t.index :gender, name: :gender
|
26
|
+
t.index :gender, name: :gender
|
27
27
|
end
|
28
28
|
ERB
|
29
29
|
end
|
@@ -46,7 +46,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
46
46
|
t.string "last_name", limit: 16, null: false
|
47
47
|
t.string "gender", limit: 1, null: false
|
48
48
|
t.date "hire_date", null: false
|
49
|
-
t.index ["gender"], name: "gender"
|
49
|
+
t.index ["gender"], name: "gender"
|
50
50
|
end
|
51
51
|
ERB
|
52
52
|
end
|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
t.string "last_name", limit: 16, null: false
|
60
60
|
t.string "gender", limit: 1, null: false
|
61
61
|
t.date :hire_date2, null: false
|
62
|
-
t.index :last_name, name: :last_name
|
62
|
+
t.index :last_name, name: :last_name
|
63
63
|
end
|
64
64
|
ERB
|
65
65
|
end
|
@@ -72,7 +72,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
72
72
|
t.string "last_name", limit: 16, null: false
|
73
73
|
t.string "gender", limit: 1, null: false
|
74
74
|
t.date "hire_date2", null: false
|
75
|
-
t.index ["last_name"], name: "last_name"
|
75
|
+
t.index ["last_name"], name: "last_name"
|
76
76
|
end
|
77
77
|
ERB
|
78
78
|
end
|
@@ -99,7 +99,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
99
99
|
t.string "last_name", limit: 16, null: false
|
100
100
|
t.string "gender", limit: 1, null: false
|
101
101
|
t.date "hire_date", null: false
|
102
|
-
t
|
102
|
+
t.bigint "user_id"
|
103
103
|
t.index "user_id"
|
104
104
|
end
|
105
105
|
ERB
|
@@ -136,7 +136,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
136
136
|
t.string "last_name", limit: 16, null: false
|
137
137
|
t.string "gender", limit: 1, null: false
|
138
138
|
t.date "hire_date", null: false
|
139
|
-
t
|
139
|
+
t.bigint "user_id"
|
140
140
|
t.string "user_type"
|
141
141
|
t.index ["user_type", "user_id"]
|
142
142
|
end
|
@@ -169,7 +169,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
169
169
|
let(:actual_dsl) do
|
170
170
|
erbh(<<-ERB)
|
171
171
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
172
|
-
t
|
172
|
+
t.bigint "user_id", unsigned: true
|
173
173
|
t.string "user_type"
|
174
174
|
t.index ["user_type", "user_id"]
|
175
175
|
end
|
@@ -227,8 +227,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
227
227
|
t.string "last_name", limit: 16, null: false
|
228
228
|
t.string "gender", limit: 1, null: false
|
229
229
|
t.date "hire_date", null: false
|
230
|
-
t
|
231
|
-
t.index ["user_id"], name: "index_employees_on_user_id"
|
230
|
+
t.bigint "user_id"
|
231
|
+
t.index ["user_id"], name: "index_employees_on_user_id"
|
232
232
|
end
|
233
233
|
ERB
|
234
234
|
end
|
@@ -279,9 +279,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
279
279
|
t.string "last_name", limit: 16, null: false
|
280
280
|
t.string "gender", limit: 1, null: false
|
281
281
|
t.date "hire_date", null: false
|
282
|
-
t
|
282
|
+
t.bigint "user_id"
|
283
283
|
t.string "user_type"
|
284
|
-
t.index ["user_type", "user_id"], name: "index_employees_on_user_type_and_user_id"
|
284
|
+
t.index ["user_type", "user_id"], name: "index_employees_on_user_type_and_user_id"
|
285
285
|
end
|
286
286
|
ERB
|
287
287
|
end
|
@@ -310,7 +310,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
310
310
|
t.string "last_name", limit: 16, null: false
|
311
311
|
t.string "gender", limit: 1, null: false
|
312
312
|
t.date "hire_date", null: false
|
313
|
-
t
|
313
|
+
t.bigint "user_id"
|
314
314
|
t.index "user_id"
|
315
315
|
end
|
316
316
|
|
@@ -381,8 +381,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
381
381
|
t.string "last_name", limit: 16, null: false
|
382
382
|
t.string "gender", limit: 1, null: false
|
383
383
|
t.date "hire_date", null: false
|
384
|
-
t
|
385
|
-
t.index ["user_id"], name: "index_employees_on_user_id"
|
384
|
+
t.bigint "user_id"
|
385
|
+
t.index ["user_id"], name: "index_employees_on_user_id"
|
386
386
|
end
|
387
387
|
create_table "users", force: :cascade do |t|
|
388
388
|
end
|
@@ -12,7 +12,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
12
12
|
t.date "hire_date", null: false
|
13
13
|
t.datetime "created_at", null: false
|
14
14
|
t.datetime "updated_at", null: false
|
15
|
-
t.binary "registered_name"
|
15
|
+
t.binary "registered_name"
|
16
16
|
end
|
17
17
|
ERB
|
18
18
|
end
|
@@ -70,7 +70,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
70
70
|
t.date "hire_date", null: false
|
71
71
|
t.datetime "created_at", null: false
|
72
72
|
t.datetime "updated_at", null: false
|
73
|
-
t.binary "registered_name"
|
73
|
+
t.binary "registered_name"
|
74
74
|
end
|
75
75
|
ERB
|
76
76
|
end
|
@@ -98,7 +98,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
98
98
|
t.date "hire_date", null: false
|
99
99
|
t.datetime "created_at", null: false
|
100
100
|
t.datetime "updated_at", null: false
|
101
|
-
t.binary "registered_name"
|
101
|
+
t.binary "registered_name"
|
102
102
|
end
|
103
103
|
ERB
|
104
104
|
end
|
@@ -12,7 +12,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
12
12
|
t.date "hire_date", null: false
|
13
13
|
t.datetime "created_at", null: false
|
14
14
|
t.datetime "updated_at", null: false
|
15
|
-
t.binary "registered_name"
|
15
|
+
t.binary "registered_name"
|
16
16
|
end
|
17
17
|
ERB
|
18
18
|
end
|
@@ -45,7 +45,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
45
45
|
|
46
46
|
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
47
47
|
CREATE TABLE `employees` (
|
48
|
-
`id`
|
48
|
+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
49
49
|
`ext_column` varchar(255) NOT NULL,
|
50
50
|
`birth_date` date NOT NULL,
|
51
51
|
`first_name` varchar(14) NOT NULL,
|
@@ -72,7 +72,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
72
72
|
t.date "hire_date", null: false
|
73
73
|
t.datetime "created_at", null: false
|
74
74
|
t.datetime "updated_at", null: false
|
75
|
-
t.binary "registered_name"
|
75
|
+
t.binary "registered_name"
|
76
76
|
end
|
77
77
|
ERB
|
78
78
|
end
|
@@ -105,7 +105,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
105
105
|
|
106
106
|
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
107
107
|
CREATE TABLE `employees` (
|
108
|
-
`emp_id`
|
108
|
+
`emp_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
109
109
|
`ext_column` varchar(255) NOT NULL,
|
110
110
|
`birth_date` date NOT NULL,
|
111
111
|
`first_name` varchar(14) NOT NULL,
|
@@ -132,7 +132,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
132
132
|
t.date "hire_date", null: false
|
133
133
|
t.datetime "created_at", null: false
|
134
134
|
t.datetime "updated_at", null: false
|
135
|
-
t.binary "registered_name"
|
135
|
+
t.binary "registered_name"
|
136
136
|
end
|
137
137
|
ERB
|
138
138
|
end
|
@@ -190,7 +190,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
190
190
|
t.date "hire_date", null: false
|
191
191
|
t.datetime "created_at", null: false
|
192
192
|
t.datetime "updated_at", null: false
|
193
|
-
t.binary "registered_name"
|
193
|
+
t.binary "registered_name"
|
194
194
|
end
|
195
195
|
ERB
|
196
196
|
end
|
@@ -223,7 +223,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
223
223
|
|
224
224
|
expect(show_create_table_mysql('employees')).to match_fuzzy erbh(<<-ERB)
|
225
225
|
CREATE TABLE `employees` (
|
226
|
-
`id`
|
226
|
+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
227
227
|
`ext_column` varchar(255) NOT NULL,
|
228
228
|
`birth_date` date NOT NULL,
|
229
229
|
`first_name` varchar(14) NOT NULL,
|
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
describe 'Ridgepole::Client#diff -> migrate' do
|
4
4
|
before { subject.diff(actual_dsl).migrate }
|
5
|
-
subject { client(table_options: table_options, dump_without_table_options: dump_without_table_options) }
|
5
|
+
subject { client(table_options: table_options, table_hash_options: table_hash_options, dump_without_table_options: dump_without_table_options) }
|
6
6
|
|
7
7
|
let(:warning_regexp) { /Table option changes are ignored/ }
|
8
8
|
let(:dump_without_table_options) { false }
|
9
|
+
let(:table_options) { nil }
|
10
|
+
let(:table_hash_options) { {} }
|
9
11
|
|
10
12
|
let(:actual_dsl) do
|
11
13
|
erbh(<<-ERB)
|
12
|
-
create_table "employees", primary_key: "emp_no", force: :cascade, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
|
14
|
+
create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond('>= 6.1', { charset: 'utf8' }, { options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8' }) %> do |t|
|
13
15
|
end
|
14
16
|
ERB
|
15
17
|
end
|
@@ -21,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
21
23
|
ERB
|
22
24
|
end
|
23
25
|
|
24
|
-
context 'when change options (no change)' do
|
26
|
+
context 'when change options (no change)', condition: '< 6.1' do
|
25
27
|
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8' }
|
26
28
|
|
27
29
|
it {
|
@@ -31,7 +33,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
31
33
|
}
|
32
34
|
end
|
33
35
|
|
34
|
-
context 'when change options (change)' do
|
36
|
+
context 'when change options (change)', condition: '< 6.1' do
|
35
37
|
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }
|
36
38
|
|
37
39
|
it {
|
@@ -41,7 +43,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
41
43
|
}
|
42
44
|
end
|
43
45
|
|
44
|
-
context 'when dump_without_table_options => true' do
|
46
|
+
context 'when dump_without_table_options => true', condition: '< 6.1' do
|
45
47
|
let(:table_options) { 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4' }
|
46
48
|
let(:dump_without_table_options) { true }
|
47
49
|
|
@@ -51,4 +53,35 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
53
|
expect(delta.differ?).to be_falsey
|
52
54
|
}
|
53
55
|
end
|
56
|
+
|
57
|
+
context 'when change options (no change)', condition: '>= 6.1' do
|
58
|
+
let(:table_hash_options) { { charset: 'utf8' } }
|
59
|
+
|
60
|
+
it {
|
61
|
+
expect(Ridgepole::Logger.instance).to_not receive(:warn).with(warning_regexp)
|
62
|
+
delta = subject.diff(expected_dsl)
|
63
|
+
expect(delta.differ?).to be_falsey
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when change options (change)', condition: '>= 6.1' do
|
68
|
+
let(:table_hash_options) { { charset: 'utf8mb4' } }
|
69
|
+
|
70
|
+
it {
|
71
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(warning_regexp)
|
72
|
+
delta = subject.diff(expected_dsl)
|
73
|
+
expect(delta.differ?).to be_falsey
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when dump_without_table_options => true', condition: '>= 6.1' do
|
78
|
+
let(:table_hash_options) { { charset: 'utf8mb4' } }
|
79
|
+
let(:dump_without_table_options) { true }
|
80
|
+
|
81
|
+
it {
|
82
|
+
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
83
|
+
delta = subject.diff(expected_dsl)
|
84
|
+
expect(delta.differ?).to be_falsey
|
85
|
+
}
|
86
|
+
end
|
54
87
|
end
|
@@ -175,7 +175,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
175
175
|
let(:result_dsl) do
|
176
176
|
erbh(<<-ERB)
|
177
177
|
create_table "salaries", id: false, force: :cascade do |t|
|
178
|
-
t.integer "emp_no",
|
178
|
+
t.integer "emp_no", null: false
|
179
179
|
t.float "salary", <%= i cond('< 5.2.0.beta2', limit: 24) %>, null: false
|
180
180
|
t.date "from_date", null: false
|
181
181
|
t.date "to_date", null: false
|
@@ -187,25 +187,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
187
187
|
subject { client }
|
188
188
|
|
189
189
|
it {
|
190
|
-
|
191
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with('[WARNING] Table `salaries`: `default: nil` is ignored when `null: false`. Please apply twice')
|
192
|
-
else
|
193
|
-
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
194
|
-
end
|
190
|
+
expect(Ridgepole::Logger.instance).to_not receive(:warn)
|
195
191
|
|
196
192
|
delta = subject.diff(expected_dsl)
|
197
193
|
expect(delta.differ?).to be_truthy
|
198
194
|
expect(subject.dump).to match_ruby actual_dsl
|
199
195
|
delta.migrate
|
200
196
|
expect(subject.dump).to match_fuzzy result_dsl
|
201
|
-
|
202
|
-
if condition(5.0)
|
203
|
-
delta = subject.diff(expected_dsl)
|
204
|
-
expect(delta.differ?).to be_truthy
|
205
|
-
expect(subject.dump).to match_fuzzy result_dsl
|
206
|
-
delta.migrate
|
207
|
-
expect(subject.dump).to match_ruby expected_dsl
|
208
|
-
end
|
209
197
|
}
|
210
198
|
end
|
211
199
|
end
|
@@ -6,12 +6,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
6
6
|
erbh(<<-ERB)
|
7
7
|
create_table "clubs", force: :cascade do |t|
|
8
8
|
t.string "name", default: "", null: false
|
9
|
-
t.index ["name"], name: "idx_name", unique: true
|
9
|
+
t.index ["name"], name: "idx_name", unique: true
|
10
10
|
end
|
11
11
|
|
12
12
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
13
13
|
t.string "dept_name", limit: 40, null: false
|
14
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
14
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
15
15
|
end
|
16
16
|
|
17
17
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
19
19
|
t.string "dept_no", null: false
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
|
-
t.index ["dept_no"], name: "dept_no"
|
23
|
-
t.index ["emp_no"], name: "emp_no"
|
22
|
+
t.index ["dept_no"], name: "dept_no"
|
23
|
+
t.index ["emp_no"], name: "emp_no"
|
24
24
|
end
|
25
25
|
|
26
26
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -28,14 +28,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
28
28
|
t.integer "emp_no", null: false
|
29
29
|
t.date "from_date", null: false
|
30
30
|
t.date "to_date", null: false
|
31
|
-
t.index ["dept_no"], name: "dept_no"
|
32
|
-
t.index ["emp_no"], name: "emp_no"
|
31
|
+
t.index ["dept_no"], name: "dept_no"
|
32
|
+
t.index ["emp_no"], name: "emp_no"
|
33
33
|
end
|
34
34
|
|
35
35
|
create_table "employee_clubs", force: :cascade do |t|
|
36
36
|
t.integer "emp_no", null: false
|
37
37
|
t.integer "club_id", null: false
|
38
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
38
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
39
39
|
end
|
40
40
|
|
41
41
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
t.integer "salary", null: false
|
52
52
|
t.date "from_date", null: false
|
53
53
|
t.date "to_date", null: false
|
54
|
-
t.index ["emp_no"], name: "emp_no"
|
54
|
+
t.index ["emp_no"], name: "emp_no"
|
55
55
|
end
|
56
56
|
|
57
57
|
create_table "titles", id: false, force: :cascade do |t|
|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
t.string "title", limit: 50, null: false
|
60
60
|
t.date "from_date", null: false
|
61
61
|
t.date "to_date"
|
62
|
-
t.index ["emp_no"], name: "emp_no"
|
62
|
+
t.index ["emp_no"], name: "emp_no"
|
63
63
|
end
|
64
64
|
ERB
|
65
65
|
end
|
@@ -68,12 +68,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
68
68
|
erbh(<<-ERB)
|
69
69
|
create_table "clubs", force: :cascade do |t|
|
70
70
|
t.string "name", default: "", null: false
|
71
|
-
t.index ["name"], name: "idx_name", unique: true
|
71
|
+
t.index ["name"], name: "idx_name", unique: true
|
72
72
|
end
|
73
73
|
|
74
74
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
75
|
t.string "dept_name", limit: 40, null: false
|
76
|
-
t.index ["dept_name"], name: "dept_name", unique: true
|
76
|
+
t.index ["dept_name"], name: "dept_name", unique: true
|
77
77
|
end
|
78
78
|
|
79
79
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
81
81
|
t.string "dept_no", null: false
|
82
82
|
t.date "from_date", null: false
|
83
83
|
t.date "to_date", null: false
|
84
|
-
t.index ["dept_no"], name: "dept_no"
|
85
|
-
t.index ["emp_no"], name: "emp_no"
|
84
|
+
t.index ["dept_no"], name: "dept_no"
|
85
|
+
t.index ["emp_no"], name: "emp_no"
|
86
86
|
end
|
87
87
|
|
88
88
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
@@ -90,14 +90,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
90
90
|
t.integer "emp_no", null: false
|
91
91
|
t.date "from_date", null: false
|
92
92
|
t.date "to_date", null: false
|
93
|
-
t.index ["dept_no"], name: "dept_no"
|
94
|
-
t.index ["emp_no"], name: "emp_no"
|
93
|
+
t.index ["dept_no"], name: "dept_no"
|
94
|
+
t.index ["emp_no"], name: "emp_no"
|
95
95
|
end
|
96
96
|
|
97
97
|
create_table "employee_clubs", force: :cascade do |t|
|
98
98
|
t.integer "emp_no", null: false
|
99
99
|
t.integer "club_id"
|
100
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
100
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
|
101
101
|
end
|
102
102
|
|
103
103
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
@@ -113,7 +113,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
113
113
|
t.integer "salary", null: false
|
114
114
|
t.date "from_date", null: false
|
115
115
|
t.date "to_date", null: false
|
116
|
-
t.index ["emp_no"], name: "emp_no"
|
116
|
+
t.index ["emp_no"], name: "emp_no"
|
117
117
|
end
|
118
118
|
|
119
119
|
create_table "titles", id: false, force: :cascade do |t|
|
@@ -121,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
121
121
|
t.string "title", limit: 50, null: false
|
122
122
|
t.date "from_date", null: false
|
123
123
|
t.date "to_date"
|
124
|
-
t.index ["emp_no"], name: "emp_no"
|
124
|
+
t.index ["emp_no"], name: "emp_no"
|
125
125
|
end
|
126
126
|
ERB
|
127
127
|
end
|
@@ -143,12 +143,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
143
143
|
expect(subject.dump).to match_ruby actual_dsl
|
144
144
|
expect(delta.script).to match_fuzzy erbh(<<-ERB)
|
145
145
|
change_table("employee_clubs", bulk: true) do |t|
|
146
|
-
t.change("club_id", :integer,
|
146
|
+
t.change("club_id", :integer, **{:null=>true, :default=>nil, :unsigned=>false, :comment=>nil})
|
147
147
|
end
|
148
148
|
|
149
149
|
change_table("employees", bulk: true) do |t|
|
150
|
-
t.change("last_name", :string,
|
151
|
-
t.change("gender", :string,
|
150
|
+
t.change("last_name", :string, **{:limit=>20, :default=>"XXX", :unsigned=>false, :comment=>nil})
|
151
|
+
t.change("gender", :string, **{:limit=>2, :null=>false, :default=>nil, :unsigned=>false, :comment=>nil})
|
152
152
|
end
|
153
153
|
ERB
|
154
154
|
delta.migrate
|