ridgepole 0.6.4 → 0.6.5.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +18 -8
- data/Appraisals +8 -0
- data/README.md +26 -2
- data/docker-compose.yml +12 -0
- data/gemfiles/activerecord_4.2.gemfile +8 -0
- data/gemfiles/activerecord_5.0.gemfile +7 -0
- data/lib/ridgepole/diff.rb +3 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +6 -2
- data/spec/cli_helper.rb +63 -0
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +45 -0
- data/spec/mysql/cli/config_spec.rb +0 -2
- data/spec/mysql/cli/ridgepole_spec.rb +58 -56
- data/spec/mysql/collation/collation_spec.rb +134 -138
- data/spec/mysql/diff/diff2_spec.rb +1 -3
- data/spec/mysql/diff/diff_spec.rb +1 -3
- data/spec/mysql/dump/dump_class_method_spec.rb +29 -11
- data/spec/mysql/dump/dump_some_tables_spec.rb +18 -8
- data/spec/mysql/dump/dump_spec.rb +28 -10
- data/spec/mysql/dump/dump_without_table_options_spec.rb +29 -33
- data/spec/mysql/fk/migrate_change_fk_spec.rb +2 -4
- data/spec/mysql/fk/migrate_create_fk_spec.rb +39 -29
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/mysql/migrate/check_orphan_index_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -26
- data/spec/mysql/migrate/migrate_add_column_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +27 -17
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +54 -44
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +8 -10
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +28 -30
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +34 -36
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +10 -12
- data/spec/mysql/migrate/migrate_change_column_spec.rb +41 -29
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +12 -14
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +24 -26
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +34 -24
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +26 -16
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +38 -28
- data/spec/mysql/migrate/migrate_change_index_spec.rb +39 -29
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +26 -13
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_create_index_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_create_table_spec.rb +24 -14
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +4 -6
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +23 -13
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +32 -22
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +35 -25
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +36 -26
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +29 -19
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +2 -4
- data/spec/mysql/migrate/migrate_empty_spec.rb +24 -14
- data/spec/mysql/migrate/migrate_execute_spec.rb +78 -65
- data/spec/mysql/migrate/migrate_log_file_spec.rb +22 -12
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +31 -21
- data/spec/mysql/migrate/migrate_noop_spec.rb +55 -45
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +38 -28
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +43 -33
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +28 -18
- data/spec/mysql/migrate/migrate_same_spec.rb +26 -12
- data/spec/mysql/migrate/migrate_script_error_spec.rb +3 -5
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +30 -20
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +44 -46
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +6 -8
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +20 -22
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +22 -12
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +22 -12
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +39 -29
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/postgresql/diff/diff_spec.rb +7 -9
- data/spec/postgresql/dump/dump_spec.rb +2 -4
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +8 -10
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +24 -26
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +21 -23
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +19 -22
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +6 -8
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +17 -19
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +11 -13
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +6 -9
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +10 -12
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +7 -9
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -8
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +12 -14
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +14 -16
- data/spec/postgresql/migrate/migrate_same_spec.rb +4 -6
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +8 -10
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +24 -26
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +20 -22
- data/spec/processing_for_travis.rb +9 -0
- data/spec/spec_condition.rb +24 -0
- data/spec/spec_const.rb +18 -0
- data/spec/spec_helper.rb +125 -196
- data/spec/string_ext.rb +0 -13
- metadata +106 -32
- data/spec/mysql/bigint_pk/bigint_pkspec.rb +0 -47
@@ -1,148 +1,144 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when change column (delete collation)' do
|
40
|
-
let(:actual_dsl) {
|
41
|
-
<<-RUBY
|
42
|
-
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
43
|
-
t.integer "emp_no", limit: 4, null: false
|
44
|
-
t.integer "club_id", limit: 4, null: false, unsigned: true
|
45
|
-
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
46
|
-
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
47
|
-
end
|
48
|
-
RUBY
|
49
|
-
}
|
50
|
-
|
51
|
-
let(:expected_dsl) {
|
52
|
-
<<-RUBY
|
53
|
-
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
54
|
-
t.integer "emp_no", limit: 4, null: false
|
55
|
-
t.integer "club_id", limit: 4, null: false, unsigned: true
|
56
|
-
t.string "string", limit: 255, null: false
|
57
|
-
t.text "text", limit: 65535, null: false
|
58
|
-
end
|
59
|
-
RUBY
|
60
|
-
}
|
61
|
-
|
62
|
-
before { subject.diff(actual_dsl).migrate }
|
63
|
-
subject { client }
|
64
|
-
|
65
|
-
it {
|
66
|
-
delta = subject.diff(expected_dsl)
|
67
|
-
expect(delta.differ?).to be_truthy
|
68
|
-
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
69
|
-
delta.migrate
|
70
|
-
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when change column (change collation)' do
|
75
|
-
let(:actual_dsl) {
|
76
|
-
<<-RUBY
|
77
|
-
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
78
|
-
t.integer "emp_no", limit: 4, null: false
|
79
|
-
t.integer "club_id", limit: 4, null: false, unsigned: true
|
80
|
-
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
81
|
-
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
82
|
-
end
|
83
|
-
RUBY
|
84
|
-
}
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate', condition: [:mysql_awesome_enabled] do
|
2
|
+
context 'when change column (add collation)' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-RUBY
|
5
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
6
|
+
t.integer "emp_no", limit: 4, null: false
|
7
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
8
|
+
t.string "string", limit: 255, null: false
|
9
|
+
t.text "text", limit: 65535, null: false
|
10
|
+
end
|
11
|
+
RUBY
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:expected_dsl) {
|
15
|
+
<<-RUBY
|
16
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
17
|
+
t.integer "emp_no", limit: 4, null: false
|
18
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
19
|
+
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
20
|
+
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
21
|
+
end
|
22
|
+
RUBY
|
23
|
+
}
|
24
|
+
|
25
|
+
before { subject.diff(actual_dsl).migrate }
|
26
|
+
subject { client }
|
27
|
+
|
28
|
+
it {
|
29
|
+
delta = subject.diff(expected_dsl)
|
30
|
+
expect(delta.differ?).to be_truthy
|
31
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
32
|
+
delta.migrate
|
33
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
34
|
+
}
|
35
|
+
end
|
85
36
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
37
|
+
context 'when change column (delete collation)' do
|
38
|
+
let(:actual_dsl) {
|
39
|
+
<<-RUBY
|
40
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
41
|
+
t.integer "emp_no", limit: 4, null: false
|
42
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
43
|
+
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
44
|
+
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
45
|
+
end
|
46
|
+
RUBY
|
47
|
+
}
|
48
|
+
|
49
|
+
let(:expected_dsl) {
|
50
|
+
<<-RUBY
|
51
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
52
|
+
t.integer "emp_no", limit: 4, null: false
|
53
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
54
|
+
t.string "string", limit: 255, null: false
|
55
|
+
t.text "text", limit: 65535, null: false
|
56
|
+
end
|
57
|
+
RUBY
|
58
|
+
}
|
59
|
+
|
60
|
+
before { subject.diff(actual_dsl).migrate }
|
61
|
+
subject { client }
|
62
|
+
|
63
|
+
it {
|
64
|
+
delta = subject.diff(expected_dsl)
|
65
|
+
expect(delta.differ?).to be_truthy
|
66
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
67
|
+
delta.migrate
|
68
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
69
|
+
}
|
70
|
+
end
|
96
71
|
|
97
|
-
|
98
|
-
|
72
|
+
context 'when change column (change collation)' do
|
73
|
+
let(:actual_dsl) {
|
74
|
+
<<-RUBY
|
75
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
76
|
+
t.integer "emp_no", limit: 4, null: false
|
77
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
78
|
+
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
79
|
+
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
80
|
+
end
|
81
|
+
RUBY
|
82
|
+
}
|
83
|
+
|
84
|
+
let(:expected_dsl) {
|
85
|
+
<<-RUBY
|
86
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
87
|
+
t.integer "emp_no", limit: 4, null: false
|
88
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
89
|
+
t.string "string", limit: 255, null: false, collation: "utf8mb4_bin"
|
90
|
+
t.text "text", limit: 65535, null: false, collation: "ascii_bin"
|
91
|
+
end
|
92
|
+
RUBY
|
93
|
+
}
|
94
|
+
|
95
|
+
before { subject.diff(actual_dsl).migrate }
|
96
|
+
subject { client }
|
97
|
+
|
98
|
+
it {
|
99
|
+
delta = subject.diff(expected_dsl)
|
100
|
+
expect(delta.differ?).to be_truthy
|
101
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
102
|
+
delta.migrate
|
103
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
104
|
+
}
|
105
|
+
end
|
99
106
|
|
107
|
+
context 'when change column (no change collation)' do
|
108
|
+
let(:actual_dsl) {
|
109
|
+
<<-RUBY
|
110
|
+
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
111
|
+
t.integer "emp_no", limit: 4, null: false
|
112
|
+
t.integer "club_id", limit: 4, null: false, unsigned: true
|
113
|
+
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
114
|
+
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
115
|
+
end
|
116
|
+
RUBY
|
117
|
+
}
|
118
|
+
|
119
|
+
before { subject.diff(actual_dsl).migrate }
|
120
|
+
subject { client }
|
121
|
+
|
122
|
+
it {
|
123
|
+
delta = subject.diff(actual_dsl)
|
124
|
+
expect(delta.differ?).to be_falsey
|
125
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
126
|
+
delta.migrate
|
127
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
128
|
+
}
|
129
|
+
|
130
|
+
describe '#diff' do
|
100
131
|
it {
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
delta.migrate
|
105
|
-
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'when change column (no change collation)' do
|
110
|
-
let(:actual_dsl) {
|
111
|
-
<<-RUBY
|
112
|
-
create_table "employee_clubs", unsigned: true, force: :cascade do |t|
|
113
|
-
t.integer "emp_no", limit: 4, null: false
|
114
|
-
t.integer "club_id", limit: 4, null: false, unsigned: true
|
115
|
-
t.string "string", limit: 255, null: false, collation: "ascii_bin"
|
116
|
-
t.text "text", limit: 65535, null: false, collation: "utf8mb4_bin"
|
117
|
-
end
|
118
|
-
RUBY
|
119
|
-
}
|
132
|
+
Tempfile.open("#{File.basename __FILE__}.#{$$}") do |f|
|
133
|
+
f.puts(actual_dsl)
|
134
|
+
f.flush
|
120
135
|
|
121
|
-
|
122
|
-
subject { client }
|
136
|
+
out, status = run_ridgepole('--diff', "'#{JSON.dump(conn_spec)}'", f.path, '--enable-mysql-awesome', '--dump-without-table-options')
|
123
137
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
128
|
-
delta.migrate
|
129
|
-
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
138
|
+
expect(out).to be_empty
|
139
|
+
expect(status.success?).to be_truthy
|
140
|
+
end
|
130
141
|
}
|
131
|
-
|
132
|
-
describe '#diff' do
|
133
|
-
it {
|
134
|
-
Tempfile.open("#{File.basename __FILE__}.#{$$}") do |f|
|
135
|
-
f.puts(actual_dsl)
|
136
|
-
f.flush
|
137
|
-
|
138
|
-
out, status = run_ridgepole('--diff', "'#{JSON.dump(conn_spec)}'", f.path, '--enable-mysql-awesome', '--dump-without-table-options')
|
139
|
-
|
140
|
-
expect(out).to be_empty
|
141
|
-
expect(status.success?).to be_truthy
|
142
|
-
end
|
143
|
-
}
|
144
|
-
end
|
145
142
|
end
|
146
143
|
end
|
147
144
|
end
|
148
|
-
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client.diff' do
|
3
2
|
context 'when change column' do
|
4
3
|
let(:tmpdir) { Dir.mktmpdir }
|
@@ -170,7 +169,7 @@ describe 'Ridgepole::Client.diff' do
|
|
170
169
|
it {
|
171
170
|
delta = subject.diff(actual_dsl, expected_dsl, enable_mysql_unsigned: true)
|
172
171
|
expect(delta.differ?).to be_truthy
|
173
|
-
expect(delta.script).to
|
172
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
174
173
|
change_column("employee_clubs", "club_id", :integer, {:unsigned=>false, :null=>true, :default=>nil})
|
175
174
|
|
176
175
|
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
@@ -183,4 +182,3 @@ describe 'Ridgepole::Client.diff' do
|
|
183
182
|
end
|
184
183
|
end
|
185
184
|
end
|
186
|
-
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client.diff' do
|
3
2
|
context 'when change column' do
|
4
3
|
let(:actual_dsl) {
|
@@ -144,7 +143,7 @@ describe 'Ridgepole::Client.diff' do
|
|
144
143
|
it {
|
145
144
|
delta = subject.diff(actual_dsl, expected_dsl, enable_mysql_unsigned: true)
|
146
145
|
expect(delta.differ?).to be_truthy
|
147
|
-
expect(delta.script).to
|
146
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
148
147
|
change_column("employee_clubs", "club_id", :integer, {:unsigned=>false, :null=>true, :default=>nil})
|
149
148
|
|
150
149
|
change_column("employees", "last_name", :string, {:limit=>20, :default=>"XXX"})
|
@@ -153,4 +152,3 @@ describe 'Ridgepole::Client.diff' do
|
|
153
152
|
}
|
154
153
|
end
|
155
154
|
end
|
156
|
-
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client.dump' do
|
3
2
|
context 'when there is a tables' do
|
4
3
|
before { restore_tables }
|
@@ -7,7 +6,7 @@ describe 'Ridgepole::Client.dump' do
|
|
7
6
|
let(:options) {
|
8
7
|
opts = {}
|
9
8
|
|
10
|
-
if mysql_awesome_enabled
|
9
|
+
if condition(:mysql_awesome_enabled)
|
11
10
|
opts[:enable_mysql_awesome] = true
|
12
11
|
opts[:dump_without_table_options] = true
|
13
12
|
else
|
@@ -17,15 +16,35 @@ describe 'Ridgepole::Client.dump' do
|
|
17
16
|
opts
|
18
17
|
}
|
19
18
|
|
19
|
+
let(:template_variables) {
|
20
|
+
opts = {
|
21
|
+
clubs: {force: :cascade},
|
22
|
+
departments: {force: :cascade},
|
23
|
+
employee_clubs: {force: :cascade},
|
24
|
+
employees: {force: :cascade},
|
25
|
+
unsigned: {},
|
26
|
+
}
|
27
|
+
|
28
|
+
if condition(:mysql_awesome_enabled)
|
29
|
+
opts[:clubs].unshift(unsigned: true)
|
30
|
+
opts[:departments].unshift(id: :string, limit: 4)
|
31
|
+
opts[:employee_clubs].unshift(unsigned: true)
|
32
|
+
opts[:employees].unshift(id: :integer, limit: 4)
|
33
|
+
opts[:unsigned] = {unsigned: true}
|
34
|
+
end
|
35
|
+
|
36
|
+
opts
|
37
|
+
}
|
38
|
+
|
20
39
|
it {
|
21
|
-
expect(subject.dump(conn_spec, options)).to
|
22
|
-
create_table "clubs"
|
40
|
+
expect(subject.dump(conn_spec, options)).to match_fuzzy erbh(<<-EOS, template_variables)
|
41
|
+
create_table "clubs", <%= @clubs.i %> do |t|
|
23
42
|
t.string "name", limit: 255, default: "", null: false
|
24
43
|
end
|
25
44
|
|
26
45
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
27
46
|
|
28
|
-
create_table "departments", primary_key: "dept_no"
|
47
|
+
create_table "departments", primary_key: "dept_no", <%= @departments.i %> do |t|
|
29
48
|
t.string "dept_name", limit: 40, null: false
|
30
49
|
end
|
31
50
|
|
@@ -51,14 +70,14 @@ describe 'Ridgepole::Client.dump' do
|
|
51
70
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
52
71
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
53
72
|
|
54
|
-
create_table "employee_clubs"
|
55
|
-
t.integer "emp_no", limit: 4, null: false
|
56
|
-
t.integer "club_id", limit: 4, null: false
|
73
|
+
create_table "employee_clubs", <%= @employee_clubs.i %> do |t|
|
74
|
+
t.integer "emp_no", <%= {limit: 4, null: false}.push(@unsigned).i %>
|
75
|
+
t.integer "club_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
|
57
76
|
end
|
58
77
|
|
59
78
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
60
79
|
|
61
|
-
create_table "employees", primary_key: "emp_no"
|
80
|
+
create_table "employees", primary_key: "emp_no", <%= @employees.i %> do |t|
|
62
81
|
t.date "birth_date", null: false
|
63
82
|
t.string "first_name", limit: 14, null: false
|
64
83
|
t.string "last_name", limit: 16, null: false
|
@@ -83,8 +102,7 @@ describe 'Ridgepole::Client.dump' do
|
|
83
102
|
end
|
84
103
|
|
85
104
|
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
86
|
-
|
105
|
+
EOS
|
87
106
|
}
|
88
107
|
end
|
89
108
|
end
|
90
|
-
end
|
@@ -1,12 +1,23 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client#dump' do
|
2
|
+
let(:template_variables) {
|
3
|
+
opts = {
|
4
|
+
employees: {force: :cascade},
|
5
|
+
}
|
6
|
+
|
7
|
+
if condition(:mysql_awesome_enabled)
|
8
|
+
opts[:employees].unshift(id: :integer, limit: 4)
|
9
|
+
end
|
10
|
+
|
11
|
+
opts
|
12
|
+
}
|
13
|
+
|
3
14
|
context 'when there is a tables (dump some tables)' do
|
4
15
|
before { restore_tables }
|
5
16
|
subject { client(tables: ['employees', 'salaries']) }
|
6
17
|
|
7
18
|
it {
|
8
|
-
expect(subject.dump).to
|
9
|
-
create_table "employees", primary_key: "emp_no"
|
19
|
+
expect(subject.dump).to match_fuzzy erbh(<<-EOS, template_variables)
|
20
|
+
create_table "employees", primary_key: "emp_no", <%= @employees.i %> do |t|
|
10
21
|
t.date "birth_date", null: false
|
11
22
|
t.string "first_name", limit: 14, null: false
|
12
23
|
t.string "last_name", limit: 16, null: false
|
@@ -22,7 +33,7 @@ describe 'Ridgepole::Client#dump' do
|
|
22
33
|
end
|
23
34
|
|
24
35
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
25
|
-
|
36
|
+
EOS
|
26
37
|
}
|
27
38
|
end
|
28
39
|
|
@@ -40,8 +51,8 @@ describe 'Ridgepole::Client#dump' do
|
|
40
51
|
}
|
41
52
|
|
42
53
|
it {
|
43
|
-
expect(subject.dump).to
|
44
|
-
create_table "employees", primary_key: "emp_no"
|
54
|
+
expect(subject.dump).to match_fuzzy erbh(<<-EOS, template_variables)
|
55
|
+
create_table "employees", primary_key: "emp_no", <%= @employees.i %> do |t|
|
45
56
|
t.date "birth_date", null: false
|
46
57
|
t.string "first_name", limit: 14, null: false
|
47
58
|
t.string "last_name", limit: 16, null: false
|
@@ -57,8 +68,7 @@ describe 'Ridgepole::Client#dump' do
|
|
57
68
|
end
|
58
69
|
|
59
70
|
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
60
|
-
|
71
|
+
EOS
|
61
72
|
}
|
62
73
|
end
|
63
74
|
end
|
64
|
-
end
|
@@ -1,18 +1,37 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client#dump' do
|
3
2
|
context 'when there is a tables' do
|
4
3
|
before { restore_tables }
|
5
4
|
subject { client }
|
6
5
|
|
6
|
+
let(:template_variables) {
|
7
|
+
opts = {
|
8
|
+
clubs: {force: :cascade},
|
9
|
+
departments: {force: :cascade},
|
10
|
+
employee_clubs: {force: :cascade},
|
11
|
+
employees: {force: :cascade},
|
12
|
+
unsigned: {}
|
13
|
+
}
|
14
|
+
|
15
|
+
if condition(:mysql_awesome_enabled)
|
16
|
+
opts[:clubs].unshift(unsigned: true)
|
17
|
+
opts[:departments].unshift(id: :string, limit: 4)
|
18
|
+
opts[:employee_clubs].unshift(unsigned: true)
|
19
|
+
opts[:employees].unshift(id: :integer, limit: 4)
|
20
|
+
opts[:unsigned] = {unsigned: true}
|
21
|
+
end
|
22
|
+
|
23
|
+
opts
|
24
|
+
}
|
25
|
+
|
7
26
|
it {
|
8
|
-
expect(subject.dump).to
|
9
|
-
create_table "clubs"
|
27
|
+
expect(subject.dump).to match_fuzzy erbh(<<-EOS, template_variables)
|
28
|
+
create_table "clubs", <%= @clubs.i %> do |t|
|
10
29
|
t.string "name", limit: 255, default: "", null: false
|
11
30
|
end
|
12
31
|
|
13
32
|
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
14
33
|
|
15
|
-
create_table "departments", primary_key: "dept_no"
|
34
|
+
create_table "departments", primary_key: "dept_no", <%= @departments.i %> do |t|
|
16
35
|
t.string "dept_name", limit: 40, null: false
|
17
36
|
end
|
18
37
|
|
@@ -38,14 +57,14 @@ describe 'Ridgepole::Client#dump' do
|
|
38
57
|
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
39
58
|
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
40
59
|
|
41
|
-
create_table "employee_clubs"
|
42
|
-
t.integer "emp_no", limit: 4, null: false
|
43
|
-
t.integer "club_id", limit: 4, null: false
|
60
|
+
create_table "employee_clubs", <%= @employee_clubs.i %> do |t|
|
61
|
+
t.integer "emp_no", <%= {limit: 4, null: false}.push(@unsigned).i %>
|
62
|
+
t.integer "club_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
|
44
63
|
end
|
45
64
|
|
46
65
|
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
47
66
|
|
48
|
-
create_table "employees", primary_key: "emp_no"
|
67
|
+
create_table "employees", primary_key: "emp_no", <%= @employees.i %> do |t|
|
49
68
|
t.date "birth_date", null: false
|
50
69
|
t.string "first_name", limit: 14, null: false
|
51
70
|
t.string "last_name", limit: 16, null: false
|
@@ -70,8 +89,7 @@ describe 'Ridgepole::Client#dump' do
|
|
70
89
|
end
|
71
90
|
|
72
91
|
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
73
|
-
|
92
|
+
EOS
|
74
93
|
}
|
75
94
|
end
|
76
95
|
end
|
77
|
-
end
|
@@ -1,45 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
describe 'Ridgepole::Client#dump', condition: [:mysql_awesome_enabled] do
|
2
|
+
let(:actual_dsl) {
|
3
|
+
<<-'EOS'
|
4
|
+
create_table "books", unsigned: true, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='\"london\" bridge \"is\" falling \"down\"'" do |t|
|
5
|
+
t.string "title", limit: 255, null: false
|
6
|
+
t.integer "author_id", limit: 4, null: false
|
7
|
+
t.datetime "created_at"
|
8
|
+
t.datetime "updated_at"
|
9
|
+
end
|
10
|
+
EOS
|
11
|
+
}
|
12
|
+
|
13
|
+
context 'when without table options' do
|
14
|
+
let(:expected_dsl) {
|
15
|
+
<<-EOS
|
16
|
+
create_table "books", unsigned: true, force: :cascade do |t|
|
7
17
|
t.string "title", limit: 255, null: false
|
8
18
|
t.integer "author_id", limit: 4, null: false
|
9
19
|
t.datetime "created_at"
|
10
20
|
t.datetime "updated_at"
|
11
21
|
end
|
12
|
-
|
22
|
+
EOS
|
13
23
|
}
|
14
24
|
|
15
|
-
|
16
|
-
|
17
|
-
<<-RUBY
|
18
|
-
create_table "books", unsigned: true, force: :cascade do |t|
|
19
|
-
t.string "title", limit: 255, null: false
|
20
|
-
t.integer "author_id", limit: 4, null: false
|
21
|
-
t.datetime "created_at"
|
22
|
-
t.datetime "updated_at"
|
23
|
-
end
|
24
|
-
RUBY
|
25
|
-
}
|
26
|
-
|
27
|
-
before { subject.diff(actual_dsl).migrate }
|
28
|
-
subject { client }
|
25
|
+
before { subject.diff(actual_dsl).migrate }
|
26
|
+
subject { client }
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
it {
|
29
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
30
|
+
}
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
context 'when with table options' do
|
34
|
+
before { subject.diff(actual_dsl).migrate }
|
35
|
+
subject { client(dump_without_table_options: false) }
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
37
|
+
it {
|
38
|
+
expect(subject.dump).to match_fuzzy actual_dsl
|
39
|
+
}
|
43
40
|
end
|
44
41
|
end
|
45
|
-
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
unless postgresql?
|
2
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
3
2
|
context 'when change fk' do
|
4
3
|
let(:actual_dsl) {
|
@@ -53,10 +52,9 @@ add_foreign_key "child", "parent", name: "child_ibfk_1"
|
|
53
52
|
it {
|
54
53
|
delta = subject.diff(expected_dsl)
|
55
54
|
expect(delta.differ?).to be_truthy
|
56
|
-
expect(subject.dump
|
55
|
+
expect(subject.dump).to match_fuzzy sorted_actual_dsl
|
57
56
|
delta.migrate
|
58
|
-
expect(subject.dump
|
57
|
+
expect(subject.dump).to match_fuzzy expected_dsl
|
59
58
|
}
|
60
59
|
end
|
61
60
|
end
|
62
|
-
end
|