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
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when drop fk' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
6
6
|
end
|
7
7
|
|
@@ -11,17 +11,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
14
|
-
|
15
|
-
|
14
|
+
ERB
|
15
|
+
end
|
16
16
|
|
17
|
-
let(:sorted_actual_dsl)
|
18
|
-
expected_dsl +
|
17
|
+
let(:sorted_actual_dsl) do
|
18
|
+
expected_dsl + <<-RUBY
|
19
19
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
20
|
-
|
21
|
-
|
20
|
+
RUBY
|
21
|
+
end
|
22
22
|
|
23
|
-
let(:expected_dsl)
|
24
|
-
erbh(<<-
|
23
|
+
let(:expected_dsl) do
|
24
|
+
erbh(<<-ERB)
|
25
25
|
create_table "child", force: :cascade do |t|
|
26
26
|
t.integer "parent_id"
|
27
27
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -29,8 +29,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
|
30
30
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
31
31
|
end
|
32
|
-
|
33
|
-
|
32
|
+
ERB
|
33
|
+
end
|
34
34
|
|
35
35
|
before { subject.diff(actual_dsl).migrate }
|
36
36
|
subject { client(dump_with_default_fk_name: true) }
|
@@ -47,17 +47,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
47
47
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
48
48
|
expect(delta.differ?).to be_truthy
|
49
49
|
expect(subject.dump).to match_fuzzy sorted_actual_dsl
|
50
|
-
expect(delta.script).to match_fuzzy <<-
|
50
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
51
51
|
remove_foreign_key("child", {:name=>"fk_rails_e74ce85cbc"})
|
52
|
-
|
52
|
+
RUBY
|
53
53
|
delta.migrate
|
54
54
|
expect(subject.dump).to match_ruby expected_dsl
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'when drop fk when drop table' do
|
59
|
-
let(:dsl)
|
60
|
-
erbh(<<-
|
59
|
+
let(:dsl) do
|
60
|
+
erbh(<<-ERB)
|
61
61
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
62
62
|
end
|
63
63
|
|
@@ -67,11 +67,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
70
|
-
|
71
|
-
|
70
|
+
ERB
|
71
|
+
end
|
72
72
|
|
73
|
-
let(:sorted_dsl)
|
74
|
-
erbh(<<-
|
73
|
+
let(:sorted_dsl) do
|
74
|
+
erbh(<<-ERB)
|
75
75
|
create_table "child", force: :cascade do |t|
|
76
76
|
t.integer "parent_id"
|
77
77
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
84
|
-
|
85
|
-
|
84
|
+
ERB
|
85
|
+
end
|
86
86
|
|
87
87
|
before { subject.diff(dsl).migrate }
|
88
88
|
subject { client(dump_with_default_fk_name: true) }
|
@@ -1,9 +1,9 @@
|
|
1
|
-
describe 'Ridgepole::Client#diff -> migrate (with index)', condition: 5.1 do
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate (with index)', condition: '>= 5.1.0' do
|
2
2
|
context 'when create table with auto increment column' 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.integer "dept_no", null: false, auto_increment: true
|
@@ -12,8 +12,8 @@ describe 'Ridgepole::Client#diff -> migrate (with index)', condition: 5.1 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, mysql_dump_auto_increment: true) }
|
@@ -22,7 +22,7 @@ describe 'Ridgepole::Client#diff -> migrate (with index)', condition: 5.1 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", :"integer", {:null=>false, :auto_increment=>true, :limit=>4})
|
@@ -31,7 +31,7 @@ describe 'Ridgepole::Client#diff -> migrate (with index)', condition: 5.1 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,23 +1,23 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when add virtual column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title", null: false
|
7
7
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
8
8
|
end
|
9
|
-
|
10
|
-
|
9
|
+
ERB
|
10
|
+
end
|
11
11
|
|
12
|
-
let(:expected_dsl)
|
13
|
-
erbh(<<-
|
12
|
+
let(:expected_dsl) do
|
13
|
+
erbh(<<-ERB)
|
14
14
|
create_table "books", force: :cascade do |t|
|
15
15
|
t.string "title", null: false
|
16
16
|
t.json "attrs", null: false
|
17
17
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
ERB
|
20
|
+
end
|
21
21
|
|
22
22
|
before { subject.diff(actual_dsl).migrate }
|
23
23
|
subject { client }
|
@@ -1,24 +1,24 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when change virtual column / not null -> null' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title", null: false
|
7
7
|
t.json "attrs", null: false
|
8
8
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
ERB
|
11
|
+
end
|
12
12
|
|
13
|
-
let(:expected_dsl)
|
14
|
-
erbh(<<-
|
13
|
+
let(:expected_dsl) do
|
14
|
+
erbh(<<-ERB)
|
15
15
|
create_table "books", force: :cascade do |t|
|
16
16
|
t.string "title", null: false
|
17
17
|
t.json "attrs"
|
18
18
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
ERB
|
21
|
+
end
|
22
22
|
|
23
23
|
before { subject.diff(actual_dsl).migrate }
|
24
24
|
subject { client }
|
@@ -33,25 +33,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'when change virtual column / json -> string' do
|
36
|
-
let(:actual_dsl)
|
37
|
-
erbh(<<-
|
36
|
+
let(:actual_dsl) do
|
37
|
+
erbh(<<-ERB)
|
38
38
|
create_table "books", force: :cascade do |t|
|
39
39
|
t.string "title", null: false
|
40
40
|
t.json "attrs", null: false
|
41
41
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
42
42
|
end
|
43
|
-
|
44
|
-
|
43
|
+
ERB
|
44
|
+
end
|
45
45
|
|
46
|
-
let(:expected_dsl)
|
47
|
-
erbh(<<-
|
46
|
+
let(:expected_dsl) do
|
47
|
+
erbh(<<-ERB)
|
48
48
|
create_table "books", force: :cascade do |t|
|
49
49
|
t.string "title", null: false
|
50
50
|
t.string "attrs"
|
51
51
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
ERB
|
54
|
+
end
|
55
55
|
|
56
56
|
before { subject.diff(actual_dsl).migrate }
|
57
57
|
subject { client }
|
@@ -66,25 +66,25 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
context 'when change virtual column / string -> json' do
|
69
|
-
let(:actual_dsl)
|
70
|
-
erbh(<<-
|
69
|
+
let(:actual_dsl) do
|
70
|
+
erbh(<<-ERB)
|
71
71
|
create_table "books", force: :cascade do |t|
|
72
72
|
t.string "title", null: false
|
73
73
|
t.string "attrs"
|
74
74
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
75
75
|
end
|
76
|
-
|
77
|
-
|
76
|
+
ERB
|
77
|
+
end
|
78
78
|
|
79
|
-
let(:expected_dsl)
|
80
|
-
erbh(<<-
|
79
|
+
let(:expected_dsl) do
|
80
|
+
erbh(<<-ERB)
|
81
81
|
create_table "books", force: :cascade do |t|
|
82
82
|
t.string "title", null: false
|
83
83
|
t.json "attrs", null: false
|
84
84
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
ERB
|
87
|
+
end
|
88
88
|
|
89
89
|
before { subject.diff(actual_dsl).migrate }
|
90
90
|
subject { client }
|
@@ -1,23 +1,23 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when add virtual column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title", null: false
|
7
7
|
t.json "attrs", null: false
|
8
8
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
ERB
|
11
|
+
end
|
12
12
|
|
13
|
-
let(:expected_dsl)
|
14
|
-
erbh(<<-
|
13
|
+
let(:expected_dsl) do
|
14
|
+
erbh(<<-ERB)
|
15
15
|
create_table "books", force: :cascade do |t|
|
16
16
|
t.string "title", null: false
|
17
17
|
t.index ["title"], name: "index_books_on_title", <%= i cond(5.0, using: :btree) %>
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
ERB
|
20
|
+
end
|
21
21
|
|
22
22
|
before { subject.diff(actual_dsl).migrate }
|
23
23
|
subject { client }
|
@@ -1,16 +1,16 @@
|
|
1
|
-
describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate', condition: '>= 5.1.0' do
|
2
2
|
context 'when add virtual column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
<<-RUBY
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title"
|
7
7
|
t.index ["title"], name: "index_books_on_title"
|
8
8
|
end
|
9
|
-
|
10
|
-
|
9
|
+
RUBY
|
10
|
+
end
|
11
11
|
|
12
|
-
let(:expected_dsl)
|
13
|
-
<<-
|
12
|
+
let(:expected_dsl) do
|
13
|
+
<<-RUBY
|
14
14
|
create_table "books", force: :cascade do |t|
|
15
15
|
t.string "title"
|
16
16
|
t.virtual "upper_title", type: :string, as: "upper(`title`)"
|
@@ -18,8 +18,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
18
18
|
t.index ["title"], name: "index_books_on_title"
|
19
19
|
t.index ["title_length"], name: "index_books_on_title_length"
|
20
20
|
end
|
21
|
-
|
22
|
-
|
21
|
+
RUBY
|
22
|
+
end
|
23
23
|
|
24
24
|
before { subject.diff(actual_dsl).migrate }
|
25
25
|
subject { client }
|
@@ -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 'when change virtual column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
<<-RUBY
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title"
|
7
7
|
t.virtual "upper_title", type: :string, null: false, as: "upper(`title`)"
|
@@ -9,11 +9,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
9
9
|
t.index ["title"], name: "index_books_on_title"
|
10
10
|
t.index ["title_length"], name: "index_books_on_title_length"
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
RUBY
|
13
|
+
end
|
14
14
|
|
15
|
-
let(:expected_dsl)
|
16
|
-
<<-
|
15
|
+
let(:expected_dsl) do
|
16
|
+
<<-RUBY
|
17
17
|
create_table "books", force: :cascade do |t|
|
18
18
|
t.string "title"
|
19
19
|
t.virtual "upper_title", type: :string, null: false, as: "length(`title`)"
|
@@ -21,8 +21,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
21
21
|
t.index ["title"], name: "index_books_on_title"
|
22
22
|
t.index ["title_length"], name: "index_books_on_title_length"
|
23
23
|
end
|
24
|
-
|
25
|
-
|
24
|
+
RUBY
|
25
|
+
end
|
26
26
|
|
27
27
|
before { subject.diff(actual_dsl).migrate }
|
28
28
|
subject { client }
|
@@ -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 'when drop virtual column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
<<-RUBY
|
5
5
|
create_table "books", force: :cascade do |t|
|
6
6
|
t.string "title"
|
7
7
|
t.virtual "upper_title", type: :string, as: "upper(`title`)"
|
@@ -9,17 +9,17 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
9
9
|
t.index ["title"], name: "index_books_on_title"
|
10
10
|
t.index ["title_length"], name: "index_books_on_title_length"
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
RUBY
|
13
|
+
end
|
14
14
|
|
15
|
-
let(:expected_dsl)
|
16
|
-
<<-
|
15
|
+
let(:expected_dsl) do
|
16
|
+
<<-RUBY
|
17
17
|
create_table "books", force: :cascade do |t|
|
18
18
|
t.string "title"
|
19
19
|
t.index ["title"], name: "index_books_on_title"
|
20
20
|
end
|
21
|
-
|
22
|
-
|
21
|
+
RUBY
|
22
|
+
end
|
23
23
|
|
24
24
|
before { subject.diff(actual_dsl).migrate }
|
25
25
|
subject { client }
|
@@ -4,8 +4,8 @@ describe 'Ridgepole::Client.diff' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
context 'when change column' do
|
7
|
-
let(:actual_dsl)
|
8
|
-
<<-
|
7
|
+
let(:actual_dsl) do
|
8
|
+
<<-RUBY
|
9
9
|
create_table "clubs", force: :cascade do |t|
|
10
10
|
t.string "name", limit: 255, default: "", null: false
|
11
11
|
end
|
@@ -69,11 +69,11 @@ describe 'Ridgepole::Client.diff' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
72
|
-
|
73
|
-
|
72
|
+
RUBY
|
73
|
+
end
|
74
74
|
|
75
|
-
let(:expected_dsl)
|
76
|
-
<<-
|
75
|
+
let(:expected_dsl) do
|
76
|
+
<<-RUBY
|
77
77
|
create_table "clubs", force: :cascade do |t|
|
78
78
|
t.string "name", limit: 255, default: "", null: false
|
79
79
|
end
|
@@ -137,19 +137,19 @@ describe 'Ridgepole::Client.diff' do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
add_index "titles", ["emp_no"], name: "idx_titles_emp_no", using: :btree
|
140
|
-
|
141
|
-
|
140
|
+
RUBY
|
141
|
+
end
|
142
142
|
|
143
143
|
subject { Ridgepole::Client }
|
144
144
|
|
145
145
|
it {
|
146
146
|
delta = subject.diff(actual_dsl, expected_dsl)
|
147
147
|
expect(delta.differ?).to be_truthy
|
148
|
-
expect(delta.script).to match_fuzzy <<-
|
148
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
149
149
|
change_column("employee_clubs", "club_id", :integer, {:null=>true, :default=>nil})
|
150
150
|
|
151
151
|
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
152
|
-
|
152
|
+
RUBY
|
153
153
|
}
|
154
154
|
end
|
155
155
|
|
@@ -157,19 +157,19 @@ describe 'Ridgepole::Client.diff' do
|
|
157
157
|
subject { Ridgepole::Client }
|
158
158
|
|
159
159
|
context 'when adding a column to the last' do
|
160
|
-
let(:actual_dsl) { <<-
|
160
|
+
let(:actual_dsl) { <<-RUBY }
|
161
161
|
create_table "users", force: :cascade do |t|
|
162
162
|
t.string "name", null: false
|
163
163
|
end
|
164
|
-
|
164
|
+
RUBY
|
165
165
|
|
166
|
-
let(:expected_dsl) { <<-
|
166
|
+
let(:expected_dsl) { <<-RUBY }
|
167
167
|
create_table "users", force: :cascade do |t|
|
168
168
|
t.string "name", null: false
|
169
169
|
t.datetime "created_at", null: false
|
170
170
|
t.datetime "updated_at", null: false
|
171
171
|
end
|
172
|
-
|
172
|
+
RUBY
|
173
173
|
|
174
174
|
# XXX:
|
175
175
|
before { client }
|
@@ -183,20 +183,20 @@ describe 'Ridgepole::Client.diff' do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
context 'when adding a column to the middle' do
|
186
|
-
let(:actual_dsl) { <<-
|
186
|
+
let(:actual_dsl) { <<-RUBY }
|
187
187
|
create_table "users", force: :cascade do |t|
|
188
188
|
t.datetime "created_at", null: false
|
189
189
|
end
|
190
|
-
|
190
|
+
RUBY
|
191
191
|
|
192
|
-
let(:expected_dsl) { <<-
|
192
|
+
let(:expected_dsl) { <<-RUBY }
|
193
193
|
create_table "users", force: :cascade do |t|
|
194
194
|
t.string "name", null: false
|
195
195
|
t.integer "age", null: false
|
196
196
|
t.datetime "created_at", null: false
|
197
197
|
t.datetime "updated_at", null: false
|
198
198
|
end
|
199
|
-
|
199
|
+
RUBY
|
200
200
|
|
201
201
|
# XXX:
|
202
202
|
before { client }
|