ridgepole 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ridgepole/delta.rb +1 -1
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +5 -2
- metadata +3 -279
- data/.github/workflows/test.yml +0 -70
- data/.gitignore +0 -25
- data/spec/cli_helper.rb +0 -65
- data/spec/dsl_parser/context_spec.rb +0 -16
- data/spec/erb_helper.rb +0 -26
- data/spec/fixtures/for_require_relative_spec.rb +0 -3
- data/spec/hide_pending_formatter.rb +0 -9
- data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
- data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
- data/spec/mysql/cli/config_spec.rb +0 -210
- data/spec/mysql/cli/ridgepole_spec.rb +0 -447
- data/spec/mysql/collation/collation_spec.rb +0 -153
- data/spec/mysql/comment/comment_spec.rb +0 -179
- data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
- data/spec/mysql/diff/diff2_spec.rb +0 -189
- data/spec/mysql/diff/diff_spec.rb +0 -168
- data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
- data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
- data/spec/mysql/dump/dump_spec.rb +0 -74
- data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
- data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
- data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
- data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
- data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
- data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
- data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
- data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
- data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -276
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
- data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
- data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
- data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
- data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
- data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
- data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
- data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
- data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
- data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
- data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
- data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
- data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
- data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
- data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
- data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
- data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
- data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
- data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
- data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
- data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
- data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
- data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
- data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
- data/spec/mysql/ridgepole_test_database.sql +0 -2
- data/spec/mysql/ridgepole_test_tables.sql +0 -79
- data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
- data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
- data/spec/mysql57/json/add_json_column_spec.rb +0 -35
- data/spec/mysql57/json/change_json_column_spec.rb +0 -102
- data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
- data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
- data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
- data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
- data/spec/postgresql/diff/diff_spec.rb +0 -216
- data/spec/postgresql/dump/dump_spec.rb +0 -69
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
- data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
- data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
- data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
- data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
- data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
- data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
- data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
- data/spec/postgresql/ridgepole_test_database.sql +0 -16
- data/spec/postgresql/ridgepole_test_tables.sql +0 -75
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
- data/spec/processing_for_ci.rb +0 -13
- data/spec/spec_condition.rb +0 -58
- data/spec/spec_const.rb +0 -20
- data/spec/spec_helper.rb +0 -173
@@ -1,153 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change column (add collation)' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
8
|
-
t.integer "emp_no", null: false
|
9
|
-
t.integer "club_id", null: false, unsigned: true
|
10
|
-
t.string "string", null: false, collation: "ascii_bin"
|
11
|
-
t.text "text", null: false
|
12
|
-
end
|
13
|
-
ERB
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:expected_dsl) do
|
17
|
-
erbh(<<-ERB)
|
18
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
19
|
-
t.integer "emp_no", null: false
|
20
|
-
t.integer "club_id", null: false, unsigned: true
|
21
|
-
t.string "string", null: false, collation: "ascii_bin"
|
22
|
-
t.text "text", null: false, collation: "utf8mb4_bin"
|
23
|
-
end
|
24
|
-
ERB
|
25
|
-
end
|
26
|
-
|
27
|
-
before { subject.diff(actual_dsl).migrate }
|
28
|
-
subject { client }
|
29
|
-
|
30
|
-
specify do
|
31
|
-
delta = subject.diff(expected_dsl)
|
32
|
-
expect(delta.differ?).to be_truthy
|
33
|
-
expect(subject.dump).to match_ruby actual_dsl
|
34
|
-
delta.migrate
|
35
|
-
expect(subject.dump).to match_ruby expected_dsl
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when change column (delete collation)' do
|
40
|
-
let(:actual_dsl) do
|
41
|
-
erbh(<<-ERB)
|
42
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
43
|
-
t.integer "emp_no", null: false
|
44
|
-
t.integer "club_id", null: false, unsigned: true
|
45
|
-
t.string "string", null: false, collation: "ascii_bin"
|
46
|
-
t.text "text", null: false, collation: "utf8mb4_bin"
|
47
|
-
end
|
48
|
-
ERB
|
49
|
-
end
|
50
|
-
|
51
|
-
let(:expected_dsl) do
|
52
|
-
erbh(<<-ERB)
|
53
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
54
|
-
t.integer "emp_no", null: false
|
55
|
-
t.integer "club_id", null: false, unsigned: true
|
56
|
-
t.string "string", null: false, collation: "ascii_bin"
|
57
|
-
t.text "text", null: false
|
58
|
-
end
|
59
|
-
ERB
|
60
|
-
end
|
61
|
-
|
62
|
-
before { subject.diff(actual_dsl).migrate }
|
63
|
-
subject { client }
|
64
|
-
|
65
|
-
specify do
|
66
|
-
delta = subject.diff(expected_dsl)
|
67
|
-
expect(delta.differ?).to be_truthy
|
68
|
-
expect(subject.dump).to match_ruby actual_dsl
|
69
|
-
delta.migrate
|
70
|
-
expect(subject.dump).to match_ruby expected_dsl
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when change column (change collation)' do
|
75
|
-
let(:actual_dsl) do
|
76
|
-
erbh(<<-ERB)
|
77
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
78
|
-
t.integer "emp_no", null: false
|
79
|
-
t.integer "club_id", null: false, unsigned: true
|
80
|
-
t.string "string", null: false, collation: "ascii_bin"
|
81
|
-
t.text "text", null: false, collation: "utf8mb4_bin"
|
82
|
-
end
|
83
|
-
ERB
|
84
|
-
end
|
85
|
-
|
86
|
-
let(:expected_dsl) do
|
87
|
-
erbh(<<-ERB)
|
88
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
89
|
-
t.integer "emp_no", null: false
|
90
|
-
t.integer "club_id", null: false, unsigned: true
|
91
|
-
t.string "string", null: false, collation: "utf8mb4_bin"
|
92
|
-
t.text "text", null: false, collation: "ascii_bin"
|
93
|
-
end
|
94
|
-
ERB
|
95
|
-
end
|
96
|
-
|
97
|
-
before { subject.diff(actual_dsl).migrate }
|
98
|
-
subject { client }
|
99
|
-
|
100
|
-
specify do
|
101
|
-
delta = subject.diff(expected_dsl)
|
102
|
-
expect(delta.differ?).to be_truthy
|
103
|
-
expect(subject.dump).to match_ruby actual_dsl
|
104
|
-
delta.migrate
|
105
|
-
expect(subject.dump).to match_ruby expected_dsl
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'when change column (no change collation)' do
|
110
|
-
let(:actual_dsl) do
|
111
|
-
erbh(<<-ERB)
|
112
|
-
create_table "employee_clubs", <%= i cond("< 6.1", { id: :bigint, unsigned: true }, { id: { type: :bigint, unsigned: true } }) %>, force: :cascade do |t|
|
113
|
-
t.integer "emp_no", null: false
|
114
|
-
t.integer "club_id", null: false, unsigned: true
|
115
|
-
t.string "string", null: false, collation: "ascii_bin"
|
116
|
-
t.text "text", null: false, collation: "utf8mb4_bin"
|
117
|
-
end
|
118
|
-
ERB
|
119
|
-
end
|
120
|
-
|
121
|
-
before { subject.diff(actual_dsl).migrate }
|
122
|
-
subject { client }
|
123
|
-
|
124
|
-
specify do
|
125
|
-
delta = subject.diff(actual_dsl)
|
126
|
-
expect(delta.differ?).to be_falsey
|
127
|
-
expect(subject.dump).to match_ruby actual_dsl
|
128
|
-
delta.migrate
|
129
|
-
expect(subject.dump).to match_ruby actual_dsl
|
130
|
-
end
|
131
|
-
|
132
|
-
describe '#diff' do
|
133
|
-
specify do
|
134
|
-
Tempfile.open("#{File.basename __FILE__}.#{$PROCESS_ID}") do |f|
|
135
|
-
f.puts(actual_dsl)
|
136
|
-
f.flush
|
137
|
-
|
138
|
-
opts = ['--dump-without-table-options']
|
139
|
-
out, status = run_ridgepole('--diff', "'#{JSON.dump(conn_spec)}'", f.path, *opts)
|
140
|
-
|
141
|
-
# v6.0.3 is the oldest version that doesn't produce any kwargs warnings with Ruby 2.7
|
142
|
-
if condition('< 6.0.3')
|
143
|
-
# https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
|
144
|
-
out = out.lines.grep_v(/: warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z/).join
|
145
|
-
end
|
146
|
-
|
147
|
-
expect(out).to be_empty
|
148
|
-
expect(status.success?).to be_truthy
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
@@ -1,179 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client#diff -> migrate' do
|
4
|
-
context 'when change column (add comment)' do
|
5
|
-
let(:actual_dsl) do
|
6
|
-
erbh(<<-ERB)
|
7
|
-
create_table "employee_clubs", force: :cascade do |t|
|
8
|
-
t.integer "emp_no", null: false
|
9
|
-
t.integer "club_id", null: false
|
10
|
-
t.string "string", null: false
|
11
|
-
t.text "text", null: false
|
12
|
-
end
|
13
|
-
ERB
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:expected_dsl) do
|
17
|
-
erbh(<<-ERB)
|
18
|
-
create_table "employee_clubs", force: :cascade do |t|
|
19
|
-
t.integer "emp_no", null: false, comment: "any comment"
|
20
|
-
t.integer "club_id", null: false, comment: "any comment2"
|
21
|
-
t.string "string", null: false, comment: "any comment3"
|
22
|
-
t.text "text", null: false, comment: "any comment4"
|
23
|
-
end
|
24
|
-
ERB
|
25
|
-
end
|
26
|
-
|
27
|
-
before { subject.diff(actual_dsl).migrate }
|
28
|
-
subject { client }
|
29
|
-
|
30
|
-
it {
|
31
|
-
delta = subject.diff(expected_dsl)
|
32
|
-
expect(delta.differ?).to be_truthy
|
33
|
-
expect(subject.dump).to match_ruby actual_dsl
|
34
|
-
delta.migrate
|
35
|
-
expect(subject.dump).to match_ruby expected_dsl
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when change column (delete comment)' do
|
40
|
-
let(:actual_dsl) do
|
41
|
-
erbh(<<-ERB)
|
42
|
-
create_table "employee_clubs", force: :cascade do |t|
|
43
|
-
t.integer "emp_no", null: false, comment: "any comment"
|
44
|
-
t.integer "club_id", null: false, comment: "any comment2"
|
45
|
-
t.string "string", null: false, comment: "any comment3"
|
46
|
-
t.text "text", null: false, comment: "any comment4"
|
47
|
-
end
|
48
|
-
ERB
|
49
|
-
end
|
50
|
-
|
51
|
-
let(:expected_dsl) do
|
52
|
-
erbh(<<-ERB)
|
53
|
-
create_table "employee_clubs", force: :cascade do |t|
|
54
|
-
t.integer "emp_no", null: false
|
55
|
-
t.integer "club_id", null: false
|
56
|
-
t.string "string", null: false
|
57
|
-
t.text "text", null: false
|
58
|
-
end
|
59
|
-
ERB
|
60
|
-
end
|
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 match_ruby actual_dsl
|
69
|
-
delta.migrate
|
70
|
-
expect(subject.dump).to match_ruby expected_dsl
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when change column (change comment)' do
|
75
|
-
let(:actual_dsl) do
|
76
|
-
erbh(<<-ERB)
|
77
|
-
create_table "employee_clubs", force: :cascade do |t|
|
78
|
-
t.integer "emp_no", null: false, comment: "any comment"
|
79
|
-
t.integer "club_id", null: false, comment: "any comment2"
|
80
|
-
t.string "string", null: false, comment: "any comment3"
|
81
|
-
t.text "text", null: false, comment: "any comment4"
|
82
|
-
end
|
83
|
-
ERB
|
84
|
-
end
|
85
|
-
|
86
|
-
let(:expected_dsl) do
|
87
|
-
erbh(<<-ERB)
|
88
|
-
create_table "employee_clubs", force: :cascade do |t|
|
89
|
-
t.integer "emp_no", null: false, comment: "other comment"
|
90
|
-
t.integer "club_id", null: false, comment: "other comment2"
|
91
|
-
t.string "string", null: false, comment: "other comment3"
|
92
|
-
t.text "text", null: false, comment: "other comment4"
|
93
|
-
end
|
94
|
-
ERB
|
95
|
-
end
|
96
|
-
|
97
|
-
before { subject.diff(actual_dsl).migrate }
|
98
|
-
subject { client }
|
99
|
-
|
100
|
-
it {
|
101
|
-
delta = subject.diff(expected_dsl)
|
102
|
-
expect(delta.differ?).to be_truthy
|
103
|
-
expect(subject.dump).to match_ruby actual_dsl
|
104
|
-
delta.migrate
|
105
|
-
expect(subject.dump).to match_ruby expected_dsl
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'when change column (no change comment)' do
|
110
|
-
let(:actual_dsl) do
|
111
|
-
erbh(<<-ERB)
|
112
|
-
create_table "employee_clubs", force: :cascade do |t|
|
113
|
-
t.integer "emp_no", null: false, comment: "any comment"
|
114
|
-
t.integer "club_id", null: false, comment: "any comment2"
|
115
|
-
t.string "string", null: false, comment: "any comment3"
|
116
|
-
t.text "text", null: false, comment: "any comment4"
|
117
|
-
end
|
118
|
-
ERB
|
119
|
-
end
|
120
|
-
|
121
|
-
before { subject.diff(actual_dsl).migrate }
|
122
|
-
subject { client }
|
123
|
-
|
124
|
-
it {
|
125
|
-
delta = subject.diff(actual_dsl)
|
126
|
-
expect(delta.differ?).to be_falsey
|
127
|
-
expect(subject.dump).to match_ruby actual_dsl
|
128
|
-
delta.migrate
|
129
|
-
expect(subject.dump).to match_ruby actual_dsl
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'when create table (with comment)' do
|
134
|
-
let(:expected_dsl) do
|
135
|
-
erbh(<<-ERB)
|
136
|
-
create_table "employee_clubs", force: :cascade, comment: "table comment" do |t|
|
137
|
-
t.integer "emp_no", null: false, comment: "other comment"
|
138
|
-
t.integer "club_id", null: false, comment: "other comment2"
|
139
|
-
t.string "string", null: false, comment: "other comment3"
|
140
|
-
t.text "text", null: false, comment: "other comment4"
|
141
|
-
end
|
142
|
-
ERB
|
143
|
-
end
|
144
|
-
|
145
|
-
subject { client }
|
146
|
-
|
147
|
-
it {
|
148
|
-
delta = subject.diff(expected_dsl)
|
149
|
-
expect(delta.differ?).to be_truthy
|
150
|
-
expect(subject.dump.strip).to be_empty
|
151
|
-
delta.migrate
|
152
|
-
expect(subject.dump).to match_ruby expected_dsl
|
153
|
-
}
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'when drop table (with comment)' do
|
157
|
-
let(:actual_dsl) do
|
158
|
-
erbh(<<-ERB)
|
159
|
-
create_table "employee_clubs", force: :cascade, comment: "table comment" do |t|
|
160
|
-
t.integer "emp_no", null: false, comment: "other comment"
|
161
|
-
t.integer "club_id", null: false, comment: "other comment2"
|
162
|
-
t.string "string", null: false, comment: "other comment3"
|
163
|
-
t.text "text", null: false, comment: "other comment4"
|
164
|
-
end
|
165
|
-
ERB
|
166
|
-
end
|
167
|
-
|
168
|
-
before { subject.diff(actual_dsl).migrate }
|
169
|
-
subject { client }
|
170
|
-
|
171
|
-
it {
|
172
|
-
delta = subject.diff('')
|
173
|
-
expect(delta.differ?).to be_truthy
|
174
|
-
expect(subject.dump).to match_ruby actual_dsl
|
175
|
-
delta.migrate
|
176
|
-
expect(subject.dump).to be_empty
|
177
|
-
}
|
178
|
-
end
|
179
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Ridgepole::Client (use default:lambda)' do
|
4
|
-
context 'when create table with default:lambda' do
|
5
|
-
subject { client }
|
6
|
-
|
7
|
-
it do
|
8
|
-
delta = subject.diff(<<-RUBY)
|
9
|
-
create_table "foos", force: :cascade do |t|
|
10
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
11
|
-
end
|
12
|
-
RUBY
|
13
|
-
|
14
|
-
expect(delta.differ?).to be_truthy
|
15
|
-
delta.migrate
|
16
|
-
|
17
|
-
expect(subject.dump).to match_fuzzy <<-RUBY
|
18
|
-
create_table "foos", force: :cascade do |t|
|
19
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
20
|
-
end
|
21
|
-
RUBY
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when there is no difference' do
|
26
|
-
let(:dsl) do
|
27
|
-
<<-RUBY
|
28
|
-
create_table "foos", force: :cascade do |t|
|
29
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
30
|
-
end
|
31
|
-
RUBY
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { client }
|
35
|
-
|
36
|
-
before do
|
37
|
-
subject.diff(dsl).migrate
|
38
|
-
end
|
39
|
-
|
40
|
-
it do
|
41
|
-
delta = subject.diff(dsl)
|
42
|
-
expect(delta.differ?).to be_falsey
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when change column (1)' do
|
47
|
-
subject { client }
|
48
|
-
|
49
|
-
before do
|
50
|
-
subject.diff(<<-RUBY).migrate
|
51
|
-
create_table "foos", force: :cascade do |t|
|
52
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
53
|
-
end
|
54
|
-
RUBY
|
55
|
-
end
|
56
|
-
|
57
|
-
it do
|
58
|
-
delta = subject.diff(<<-RUBY)
|
59
|
-
create_table "foos", force: :cascade do |t|
|
60
|
-
t.datetime "bar", default: -> { '"1970-01-01 00:00:00"' }, null: false
|
61
|
-
end
|
62
|
-
RUBY
|
63
|
-
|
64
|
-
expect(delta.differ?).to be_truthy
|
65
|
-
delta.migrate
|
66
|
-
|
67
|
-
expect(subject.dump).to match_ruby erbh(<<-ERB)
|
68
|
-
create_table "foos", force: :cascade do |t|
|
69
|
-
t.datetime "bar", default: "1970-01-01 00:00:00", null: false
|
70
|
-
end
|
71
|
-
ERB
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'when change column (2)' do
|
76
|
-
subject { client }
|
77
|
-
|
78
|
-
before do
|
79
|
-
subject.diff(<<-RUBY).migrate
|
80
|
-
create_table "foos", force: :cascade do |t|
|
81
|
-
t.datetime "bar", default: '1970-01-01 00:00:00', null: false
|
82
|
-
end
|
83
|
-
RUBY
|
84
|
-
end
|
85
|
-
|
86
|
-
it do
|
87
|
-
delta = subject.diff(<<-RUBY)
|
88
|
-
create_table "foos", force: :cascade do |t|
|
89
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
90
|
-
end
|
91
|
-
RUBY
|
92
|
-
|
93
|
-
expect(delta.differ?).to be_truthy
|
94
|
-
delta.migrate
|
95
|
-
|
96
|
-
expect(subject.dump).to match_fuzzy <<-RUBY
|
97
|
-
create_table "foos", force: :cascade do |t|
|
98
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
99
|
-
end
|
100
|
-
RUBY
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'when add column' do
|
105
|
-
subject { client }
|
106
|
-
|
107
|
-
before do
|
108
|
-
subject.diff(<<-RUBY).migrate
|
109
|
-
create_table "foos", force: :cascade do |t|
|
110
|
-
t.integer "zoo"
|
111
|
-
end
|
112
|
-
RUBY
|
113
|
-
end
|
114
|
-
|
115
|
-
it do
|
116
|
-
delta = subject.diff(<<-RUBY)
|
117
|
-
create_table "foos", force: :cascade do |t|
|
118
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
119
|
-
t.integer "zoo"
|
120
|
-
end
|
121
|
-
RUBY
|
122
|
-
|
123
|
-
expect(delta.differ?).to be_truthy
|
124
|
-
delta.migrate
|
125
|
-
|
126
|
-
expect(subject.dump).to match_fuzzy <<-RUBY
|
127
|
-
create_table "foos", force: :cascade do |t|
|
128
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
129
|
-
t.integer "zoo"
|
130
|
-
end
|
131
|
-
RUBY
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context 'when drop column' do
|
136
|
-
subject { client }
|
137
|
-
|
138
|
-
before do
|
139
|
-
subject.diff(<<-RUBY).migrate
|
140
|
-
create_table "foos", force: :cascade do |t|
|
141
|
-
t.datetime "bar", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
142
|
-
t.integer "zoo"
|
143
|
-
end
|
144
|
-
RUBY
|
145
|
-
end
|
146
|
-
|
147
|
-
it do
|
148
|
-
delta = subject.diff(<<-RUBY)
|
149
|
-
create_table "foos", force: :cascade do |t|
|
150
|
-
t.integer "zoo"
|
151
|
-
end
|
152
|
-
RUBY
|
153
|
-
|
154
|
-
expect(delta.differ?).to be_truthy
|
155
|
-
delta.migrate
|
156
|
-
|
157
|
-
expect(subject.dump).to match_fuzzy <<-RUBY
|
158
|
-
create_table "foos", force: :cascade do |t|
|
159
|
-
t.integer "zoo"
|
160
|
-
end
|
161
|
-
RUBY
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|