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,8 +1,8 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'migrate with pre/post query' do
|
3
3
|
let(:actual_dsl) { '' }
|
4
|
-
let(:dsl)
|
5
|
-
erbh(<<-
|
4
|
+
let(:dsl) do
|
5
|
+
erbh(<<-ERB)
|
6
6
|
create_table "clubs", force: :cascade do |t|
|
7
7
|
t.string "name", default: "", null: false
|
8
8
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -60,11 +60,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
60
60
|
t.date "to_date"
|
61
61
|
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
ERB
|
64
|
+
end
|
65
65
|
|
66
|
-
let(:expected_dsl)
|
67
|
-
erbh(<<-
|
66
|
+
let(:expected_dsl) do
|
67
|
+
erbh(<<-ERB)
|
68
68
|
create_table "clubs", force: :cascade do |t|
|
69
69
|
t.string "name", default: "", null: false
|
70
70
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -130,15 +130,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
130
130
|
t.date "to_date"
|
131
131
|
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
132
132
|
end
|
133
|
-
|
134
|
-
|
133
|
+
ERB
|
134
|
+
end
|
135
135
|
|
136
|
-
subject
|
136
|
+
subject do
|
137
137
|
client(
|
138
|
-
:
|
139
|
-
:
|
138
|
+
pre_query: 'create table pre (id int)',
|
139
|
+
post_query: 'create table post (id int)'
|
140
140
|
)
|
141
|
-
|
141
|
+
end
|
142
142
|
|
143
143
|
it {
|
144
144
|
delta = subject.diff(dsl)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when with tables option (same)' do
|
3
|
-
let(:current_schema)
|
4
|
-
<<-
|
3
|
+
let(:current_schema) do
|
4
|
+
<<-RUBY
|
5
5
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
6
|
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
@@ -18,11 +18,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
21
|
-
|
22
|
-
|
21
|
+
RUBY
|
22
|
+
end
|
23
23
|
|
24
|
-
let(:dsl)
|
25
|
-
<<-
|
24
|
+
let(:dsl) do
|
25
|
+
<<-RUBY
|
26
26
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
27
27
|
t.date "birth_date", null: false
|
28
28
|
t.string "first_name", limit: 14, null: false
|
@@ -39,11 +39,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
42
|
-
|
43
|
-
|
42
|
+
RUBY
|
43
|
+
end
|
44
44
|
|
45
|
-
let(:expected_dsl)
|
46
|
-
<<-
|
45
|
+
let(:expected_dsl) do
|
46
|
+
<<-RUBY
|
47
47
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
48
48
|
t.date "birth_date", null: false
|
49
49
|
t.string "first_name", limit: 14, null: false
|
@@ -51,11 +51,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
51
|
t.string "gender", limit: 1, null: false
|
52
52
|
t.date "hire_date", null: false
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
RUBY
|
55
|
+
end
|
56
56
|
|
57
57
|
before { subject.diff(current_schema).migrate }
|
58
|
-
subject { client(tables: ['employees']
|
58
|
+
subject { client(tables: ['employees']) }
|
59
59
|
|
60
60
|
it {
|
61
61
|
delta = subject.diff(dsl)
|
@@ -67,8 +67,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when with tables option (differ)' do
|
70
|
-
let(:current_schema)
|
71
|
-
<<-
|
70
|
+
let(:current_schema) do
|
71
|
+
<<-RUBY
|
72
72
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
73
73
|
t.date "birth_date", null: false
|
74
74
|
t.string "first_name", limit: 14, null: false
|
@@ -85,11 +85,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
88
|
-
|
89
|
-
|
88
|
+
RUBY
|
89
|
+
end
|
90
90
|
|
91
|
-
let(:dsl)
|
92
|
-
<<-
|
91
|
+
let(:dsl) do
|
92
|
+
<<-RUBY
|
93
93
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
94
94
|
t.date "birth_date", null: false
|
95
95
|
t.string "first_name", limit: 15, null: false
|
@@ -106,11 +106,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
109
|
-
|
110
|
-
|
109
|
+
RUBY
|
110
|
+
end
|
111
111
|
|
112
|
-
let(:before_dsl)
|
113
|
-
<<-
|
112
|
+
let(:before_dsl) do
|
113
|
+
<<-RUBY
|
114
114
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
115
115
|
t.date "birth_date", null: false
|
116
116
|
t.string "first_name", limit: 14, null: false
|
@@ -118,11 +118,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
118
118
|
t.string "gender", limit: 1, null: false
|
119
119
|
t.date "hire_date", null: false
|
120
120
|
end
|
121
|
-
|
122
|
-
|
121
|
+
RUBY
|
122
|
+
end
|
123
123
|
|
124
|
-
let(:after_dsl)
|
125
|
-
<<-
|
124
|
+
let(:after_dsl) do
|
125
|
+
<<-RUBY
|
126
126
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
127
127
|
t.date "birth_date", null: false
|
128
128
|
t.string "first_name", limit: 15, null: false
|
@@ -130,8 +130,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
130
130
|
t.string "gender", limit: 1, null: false
|
131
131
|
t.date "hire_date", null: false
|
132
132
|
end
|
133
|
-
|
134
|
-
|
133
|
+
RUBY
|
134
|
+
end
|
135
135
|
|
136
136
|
before { subject.diff(current_schema).migrate }
|
137
137
|
subject { client(tables: ['employees']) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'with verbose log' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
6
|
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
@@ -9,11 +9,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
9
9
|
t.string "gender", limit: 1, null: false
|
10
10
|
t.date "hire_date", null: false
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
ERB
|
13
|
+
end
|
14
14
|
|
15
|
-
let(:expected_dsl)
|
16
|
-
erbh(<<-
|
15
|
+
let(:expected_dsl) do
|
16
|
+
erbh(<<-ERB)
|
17
17
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
18
18
|
t.date "birth_date", null: false
|
19
19
|
t.string "first_name", limit: 14, null: false
|
@@ -21,15 +21,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
21
21
|
t.string "gender2", limit: 1, null: false
|
22
22
|
t.date "hire_date", null: false
|
23
23
|
end
|
24
|
-
|
25
|
-
|
24
|
+
ERB
|
25
|
+
end
|
26
26
|
|
27
27
|
before { subject.diff(actual_dsl).migrate }
|
28
28
|
subject { client }
|
29
29
|
|
30
30
|
it {
|
31
31
|
verbose_infos = []
|
32
|
-
allow(Ridgepole::Logger.instance).to receive(:verbose_info) {|m| verbose_infos << m }
|
32
|
+
allow(Ridgepole::Logger.instance).to receive(:verbose_info) { |m| verbose_infos << m }
|
33
33
|
|
34
34
|
Ridgepole::Logger.verbose = true
|
35
35
|
delta = subject.diff(expected_dsl)
|
@@ -40,16 +40,16 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
40
40
|
Ridgepole::Logger.verbose = false
|
41
41
|
|
42
42
|
expected_verbose_infos = [
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
'# Parse DSL',
|
44
|
+
'# Load tables',
|
45
|
+
'# employees',
|
46
|
+
'# Compare definitions',
|
47
|
+
'# employees',
|
48
48
|
" {:definition=>\n {\"birth_date\"=>{:options=>{:null=>false}, :type=>:date},\n \"first_name\"=>{:options=>{:limit=>14, :null=>false}, :type=>:string},\n- \"gender\"=>{:options=>{:limit=>1, :null=>false}, :type=>:string},\n+ \"gender2\"=>{:options=>{:limit=>1, :null=>false}, :type=>:string},\n \"hire_date\"=>{:options=>{:null=>false}, :type=>:date},\n \"last_name\"=>{:options=>{:limit=>16, :null=>false}, :type=>:string}},\n :options=>{:primary_key=>\"emp_no\"}}",
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
'# Load tables',
|
50
|
+
'# employees',
|
51
|
+
'# Load tables',
|
52
|
+
'# employees'
|
53
53
|
]
|
54
54
|
|
55
55
|
expect(verbose_infos).to match_array expected_verbose_infos
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when drop 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,13 +59,13 @@ 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
65
|
let(:actual_dsl) { dsl }
|
66
66
|
|
67
|
-
let(:expected_dsl)
|
68
|
-
erbh(<<-
|
67
|
+
let(:expected_dsl) do
|
68
|
+
erbh(<<-ERB)
|
69
69
|
create_table "clubs", force: :cascade do |t|
|
70
70
|
t.string "name", default: "", null: false
|
71
71
|
end
|
@@ -120,8 +120,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
120
120
|
t.date "from_date", null: false
|
121
121
|
t.date "to_date"
|
122
122
|
end
|
123
|
-
|
124
|
-
|
123
|
+
ERB
|
124
|
+
end
|
125
125
|
|
126
126
|
before { subject.diff(actual_dsl).migrate }
|
127
127
|
subject { client(mysql_use_alter: true) }
|
@@ -3,7 +3,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
3
3
|
subject { client }
|
4
4
|
|
5
5
|
it do
|
6
|
-
delta = subject.diff(<<-
|
6
|
+
delta = subject.diff(<<-RUBY)
|
7
7
|
create_table :foos, id: :unsigned_integer do |t|
|
8
8
|
t.blob :blob
|
9
9
|
t.tinyblob :tiny_blob
|
@@ -17,12 +17,12 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
17
17
|
t.unsigned_bigint :unsigned_bigint
|
18
18
|
t.unsigned_integer :unsigned_integer
|
19
19
|
end
|
20
|
-
|
20
|
+
RUBY
|
21
21
|
|
22
22
|
expect(delta.differ?).to be_truthy
|
23
23
|
delta.migrate
|
24
24
|
|
25
|
-
expect(subject.dump).to match_fuzzy erbh(<<-
|
25
|
+
expect(subject.dump).to match_fuzzy erbh(<<-ERB)
|
26
26
|
create_table "foos", id: :integer, unsigned: true, force: :cascade do |t|
|
27
27
|
t.binary "blob", <%= i cond(5.0, limit: 65535) %>
|
28
28
|
t.blob "tiny_blob", limit: 255
|
@@ -36,7 +36,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
36
36
|
t.bigint "unsigned_bigint", unsigned: true
|
37
37
|
t.integer "unsigned_integer", unsigned: true
|
38
38
|
end
|
39
|
-
|
39
|
+
ERB
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,7 +44,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
44
44
|
subject { client }
|
45
45
|
|
46
46
|
before do
|
47
|
-
subject.diff(<<-
|
47
|
+
subject.diff(<<-RUBY).migrate
|
48
48
|
create_table :foos do |t|
|
49
49
|
t.blob :blob
|
50
50
|
t.tinyblob :tiny_blob
|
@@ -58,11 +58,11 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
58
58
|
t.unsigned_bigint :unsigned_bigint
|
59
59
|
t.unsigned_integer :unsigned_integer
|
60
60
|
end
|
61
|
-
|
61
|
+
RUBY
|
62
62
|
end
|
63
63
|
|
64
64
|
it do
|
65
|
-
delta = subject.diff(<<-
|
65
|
+
delta = subject.diff(<<-RUBY)
|
66
66
|
create_table :foos do |t|
|
67
67
|
t.blob :blob
|
68
68
|
t.tinyblob :tiny_blob
|
@@ -76,7 +76,7 @@ describe 'Ridgepole::Client (with new text/blob types)' do
|
|
76
76
|
t.unsigned_bigint :unsigned_bigint
|
77
77
|
t.unsigned_integer :unsigned_integer
|
78
78
|
end
|
79
|
-
|
79
|
+
RUBY
|
80
80
|
|
81
81
|
expect(delta.differ?).to be_falsey
|
82
82
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when change 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,11 +11,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
14
|
-
|
15
|
-
|
14
|
+
ERB
|
15
|
+
end
|
16
16
|
|
17
|
-
let(:sorted_actual_dsl)
|
18
|
-
erbh(<<-
|
17
|
+
let(:sorted_actual_dsl) do
|
18
|
+
erbh(<<-ERB)
|
19
19
|
create_table "child", force: :cascade do |t|
|
20
20
|
t.integer "parent_id"
|
21
21
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -25,11 +25,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
|
28
|
-
|
29
|
-
|
28
|
+
ERB
|
29
|
+
end
|
30
30
|
|
31
|
-
let(:expected_dsl)
|
32
|
-
erbh(<<-
|
31
|
+
let(:expected_dsl) do
|
32
|
+
erbh(<<-ERB)
|
33
33
|
create_table "child", force: :cascade do |t|
|
34
34
|
t.integer "parent_id"
|
35
35
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -39,8 +39,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
42
|
-
|
43
|
-
|
42
|
+
ERB
|
43
|
+
end
|
44
44
|
|
45
45
|
before { subject.diff(actual_dsl).migrate }
|
46
46
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when create fk' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "child", force: :cascade do |t|
|
6
6
|
t.integer "parent_id"
|
7
7
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -9,14 +9,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
9
9
|
|
10
10
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
11
11
|
end
|
12
|
-
|
13
|
-
|
12
|
+
ERB
|
13
|
+
end
|
14
14
|
|
15
|
-
let(:expected_dsl)
|
16
|
-
actual_dsl +
|
15
|
+
let(:expected_dsl) do
|
16
|
+
actual_dsl + <<-RUBY
|
17
17
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
18
|
-
|
19
|
-
|
18
|
+
RUBY
|
19
|
+
end
|
20
20
|
|
21
21
|
before { subject.diff(actual_dsl).migrate }
|
22
22
|
subject { client(dump_with_default_fk_name: true) }
|
@@ -33,17 +33,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
33
33
|
delta = client(bulk_change: true, dump_with_default_fk_name: true).diff(expected_dsl)
|
34
34
|
expect(delta.differ?).to be_truthy
|
35
35
|
expect(subject.dump).to match_ruby actual_dsl
|
36
|
-
expect(delta.script).to match_fuzzy <<-
|
36
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
37
37
|
add_foreign_key("child", "parent", {:name=>"fk_rails_e74ce85cbc"})
|
38
|
-
|
38
|
+
RUBY
|
39
39
|
delta.migrate
|
40
40
|
expect(subject.dump).to match_ruby expected_dsl
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
44
44
|
context 'when create fk when create table' do
|
45
|
-
let(:dsl)
|
46
|
-
erbh(<<-
|
45
|
+
let(:dsl) do
|
46
|
+
erbh(<<-ERB)
|
47
47
|
# Define parent before child
|
48
48
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
49
49
|
end
|
@@ -54,11 +54,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
57
|
-
|
58
|
-
|
57
|
+
ERB
|
58
|
+
end
|
59
59
|
|
60
|
-
let(:sorted_dsl)
|
61
|
-
erbh(<<-
|
60
|
+
let(:sorted_dsl) do
|
61
|
+
erbh(<<-ERB)
|
62
62
|
create_table "child", force: :cascade do |t|
|
63
63
|
t.integer "parent_id"
|
64
64
|
t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
|
@@ -68,8 +68,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
71
|
-
|
72
|
-
|
71
|
+
ERB
|
72
|
+
end
|
73
73
|
|
74
74
|
subject { client(dump_with_default_fk_name: true) }
|
75
75
|
|
@@ -83,8 +83,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'already defined' do
|
86
|
-
let(:dsl)
|
87
|
-
erbh(<<-
|
86
|
+
let(:dsl) do
|
87
|
+
erbh(<<-ERB)
|
88
88
|
# Define parent before child
|
89
89
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
90
90
|
end
|
@@ -97,35 +97,35 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
97
97
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
98
98
|
|
99
99
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
100
|
-
|
101
|
-
|
100
|
+
ERB
|
101
|
+
end
|
102
102
|
|
103
103
|
subject { client(dump_with_default_fk_name: true) }
|
104
104
|
|
105
105
|
it {
|
106
|
-
expect
|
106
|
+
expect do
|
107
107
|
subject.diff(dsl)
|
108
|
-
|
108
|
+
end.to raise_error('Foreign Key `child(fk_rails_e74ce85cbc)` already defined')
|
109
109
|
}
|
110
110
|
end
|
111
111
|
|
112
112
|
context 'orphan fk' do
|
113
|
-
let(:dsl)
|
114
|
-
erbh(<<-
|
113
|
+
let(:dsl) do
|
114
|
+
erbh(<<-ERB)
|
115
115
|
# Define parent before child
|
116
116
|
create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
|
117
117
|
end
|
118
118
|
|
119
119
|
add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
|
120
|
-
|
121
|
-
|
120
|
+
ERB
|
121
|
+
end
|
122
122
|
|
123
123
|
subject { client(dump_with_default_fk_name: true) }
|
124
124
|
|
125
125
|
it {
|
126
|
-
expect
|
126
|
+
expect do
|
127
127
|
subject.diff(dsl)
|
128
|
-
|
128
|
+
end.to raise_error('Table `child` to create the foreign key is not defined: fk_rails_e74ce85cbc')
|
129
129
|
}
|
130
130
|
end
|
131
131
|
end
|