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 add column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
6
|
t.string "name", limit: 255, default: "", null: false
|
7
7
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
57
57
|
t.date "to_date"
|
58
58
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
59
59
|
end
|
60
|
-
|
61
|
-
|
60
|
+
ERB
|
61
|
+
end
|
62
62
|
|
63
|
-
let(:expected_dsl)
|
64
|
-
erbh(<<-
|
63
|
+
let(:expected_dsl) do
|
64
|
+
erbh(<<-ERB)
|
65
65
|
create_table "clubs", force: :cascade do |t|
|
66
66
|
t.string "name", limit: 255, default: "", null: false
|
67
67
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -120,8 +120,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
120
120
|
t.date "to_date"
|
121
121
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
122
122
|
end
|
123
|
-
|
124
|
-
|
123
|
+
ERB
|
124
|
+
end
|
125
125
|
|
126
126
|
before { subject.diff(actual_dsl).migrate }
|
127
127
|
subject { client }
|
@@ -135,10 +135,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
135
135
|
}
|
136
136
|
|
137
137
|
it {
|
138
|
-
delta = client(:
|
138
|
+
delta = client(bulk_change: true).diff(expected_dsl)
|
139
139
|
expect(delta.differ?).to be_truthy
|
140
140
|
expect(subject.dump).to match_ruby actual_dsl
|
141
|
-
expect(delta.script).to match_fuzzy <<-
|
141
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
142
142
|
change_table("employee_clubs", {:bulk => true}) do |t|
|
143
143
|
t.column("any_col", :string, {:limit=>255, :null=>false})
|
144
144
|
end
|
@@ -147,26 +147,26 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
147
147
|
t.column("age", :integer, {:null=>false})
|
148
148
|
t.column("updated_at", :date, {})
|
149
149
|
end
|
150
|
-
|
150
|
+
RUBY
|
151
151
|
delta.migrate
|
152
152
|
expect(subject.dump).to match_ruby expected_dsl
|
153
153
|
}
|
154
154
|
end
|
155
155
|
|
156
156
|
context 'when add column (int/noop)' do
|
157
|
-
let(:actual_dsl)
|
158
|
-
erbh(<<-
|
157
|
+
let(:actual_dsl) do
|
158
|
+
erbh(<<-ERB)
|
159
159
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
160
160
|
t.integer "emp_no", null: false
|
161
161
|
t.string "dept_no", limit: 4, null: false
|
162
162
|
t.date "from_date", null: false
|
163
163
|
t.date "to_date", null: false
|
164
164
|
end
|
165
|
-
|
166
|
-
|
165
|
+
ERB
|
166
|
+
end
|
167
167
|
|
168
|
-
let(:expected_dsl)
|
169
|
-
erbh(<<-
|
168
|
+
let(:expected_dsl) do
|
169
|
+
erbh(<<-ERB)
|
170
170
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
171
171
|
t.integer "emp_no", null: false
|
172
172
|
t.integer "emp_no2", null: false
|
@@ -174,8 +174,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
174
174
|
t.date "from_date", null: false
|
175
175
|
t.date "to_date", null: false
|
176
176
|
end
|
177
|
-
|
178
|
-
|
177
|
+
ERB
|
178
|
+
end
|
179
179
|
|
180
180
|
before { subject.diff(actual_dsl).migrate }
|
181
181
|
subject { client }
|
@@ -184,11 +184,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
184
184
|
delta = subject.diff(expected_dsl)
|
185
185
|
expect(delta.differ?).to be_truthy
|
186
186
|
expect(subject.dump).to match_ruby actual_dsl
|
187
|
-
migrated, sql = delta.migrate(:
|
187
|
+
migrated, sql = delta.migrate(noop: true)
|
188
188
|
expect(migrated).to be_truthy
|
189
189
|
expect(subject.dump).to match_ruby actual_dsl
|
190
190
|
|
191
|
-
expect(sql).to match_fuzzy(
|
191
|
+
expect(sql).to match_fuzzy('ALTER TABLE "dept_emp" ADD "emp_no2" integer NOT NULL')
|
192
192
|
}
|
193
193
|
end
|
194
194
|
end
|
@@ -3,14 +3,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
|
4
4
|
context 'when add_index contains expression' do
|
5
5
|
let(:actual_dsl) { '' }
|
6
|
-
let(:expected_dsl) { erbh(<<-
|
6
|
+
let(:expected_dsl) { erbh(<<-ERB) }
|
7
7
|
create_table "users", force: :cascade do |t|
|
8
8
|
t.string "name", null: false
|
9
9
|
t.datetime "created_at", null: false
|
10
10
|
t.datetime "updated_at", null: false
|
11
11
|
t.index "lower((name)::text)", name: "index_users_on_lower_name", <%= i cond(5.0, using: :btree) %>
|
12
12
|
end
|
13
|
-
|
13
|
+
ERB
|
14
14
|
|
15
15
|
specify do
|
16
16
|
delta = subject.diff(expected_dsl)
|
@@ -2,13 +2,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when add bigint 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 "bigint_test", id: false, force: :cascade do |t|
|
8
8
|
t.bigint "b"
|
9
9
|
end
|
10
|
-
|
11
|
-
|
10
|
+
ERB
|
11
|
+
end
|
12
12
|
|
13
13
|
before { subject.diff(actual_dsl).migrate }
|
14
14
|
subject { client }
|
@@ -22,21 +22,21 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'when no change' do
|
25
|
-
let(:dsl)
|
26
|
-
erbh(<<-
|
25
|
+
let(:dsl) do
|
26
|
+
erbh(<<-ERB)
|
27
27
|
create_table "bigint_test", id: false, force: :cascade do |t|
|
28
28
|
t.bigint "b"
|
29
29
|
end
|
30
|
-
|
31
|
-
|
30
|
+
ERB
|
31
|
+
end
|
32
32
|
|
33
|
-
let(:expected_dsl)
|
34
|
-
erbh(<<-
|
33
|
+
let(:expected_dsl) do
|
34
|
+
erbh(<<-ERB)
|
35
35
|
create_table "bigint_test", id: false, force: :cascade do |t|
|
36
36
|
t.bigint "b"
|
37
37
|
end
|
38
|
-
|
39
|
-
|
38
|
+
ERB
|
39
|
+
end
|
40
40
|
|
41
41
|
before { subject.diff(dsl).migrate }
|
42
42
|
subject { client }
|
@@ -1,26 +1,26 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when change column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
<<-RUBY
|
5
5
|
create_table "salaries", id: false, force: :cascade do |t|
|
6
6
|
t.integer "emp_no", default: 0, null: false
|
7
7
|
t.integer "salary", null: false
|
8
8
|
t.date "from_date", null: false
|
9
9
|
t.date "to_date", null: false
|
10
10
|
end
|
11
|
-
|
12
|
-
|
11
|
+
RUBY
|
12
|
+
end
|
13
13
|
|
14
|
-
let(:expected_dsl)
|
15
|
-
<<-
|
14
|
+
let(:expected_dsl) do
|
15
|
+
<<-RUBY
|
16
16
|
create_table "salaries", id: false, force: :cascade do |t|
|
17
17
|
t.integer "emp_no", null: false
|
18
18
|
t.integer "salary", null: false
|
19
19
|
t.date "from_date", null: false
|
20
20
|
t.date "to_date", null: false
|
21
21
|
end
|
22
|
-
|
23
|
-
|
22
|
+
RUBY
|
23
|
+
end
|
24
24
|
|
25
25
|
before { subject.diff(actual_dsl).migrate }
|
26
26
|
subject { client }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when change column' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
6
|
t.string "name", limit: 255, default: "", null: false
|
7
7
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
57
57
|
t.date "to_date"
|
58
58
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
59
59
|
end
|
60
|
-
|
61
|
-
|
60
|
+
ERB
|
61
|
+
end
|
62
62
|
|
63
|
-
let(:expected_dsl)
|
64
|
-
erbh(<<-
|
63
|
+
let(:expected_dsl) do
|
64
|
+
erbh(<<-ERB)
|
65
65
|
create_table "clubs", force: :cascade do |t|
|
66
66
|
t.string "name", limit: 255, default: "", null: false
|
67
67
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -117,8 +117,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
117
117
|
t.date "to_date"
|
118
118
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
119
119
|
end
|
120
|
-
|
121
|
-
|
120
|
+
ERB
|
121
|
+
end
|
122
122
|
|
123
123
|
before { subject.diff(actual_dsl).migrate }
|
124
124
|
subject { client }
|
@@ -132,10 +132,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
132
132
|
}
|
133
133
|
|
134
134
|
it {
|
135
|
-
delta = client(:
|
135
|
+
delta = client(bulk_change: true).diff(expected_dsl)
|
136
136
|
expect(delta.differ?).to be_truthy
|
137
137
|
expect(subject.dump).to match_ruby actual_dsl
|
138
|
-
expect(delta.script).to match_fuzzy <<-
|
138
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
139
139
|
change_table("employee_clubs", {:bulk => true}) do |t|
|
140
140
|
t.change("club_id", :integer, {:null=>true, :default=>nil})
|
141
141
|
end
|
@@ -143,30 +143,30 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
143
143
|
change_table("employees", {:bulk => true}) do |t|
|
144
144
|
t.change("last_name", :string, {:limit=>20, :default=>"XXX"})
|
145
145
|
end
|
146
|
-
|
146
|
+
RUBY
|
147
147
|
delta.migrate
|
148
148
|
expect(subject.dump).to match_ruby expected_dsl
|
149
149
|
}
|
150
150
|
end
|
151
151
|
|
152
152
|
context 'when string/text without limit (no change)' do
|
153
|
-
let(:actual_dsl)
|
154
|
-
erbh(<<-
|
153
|
+
let(:actual_dsl) do
|
154
|
+
erbh(<<-ERB)
|
155
155
|
create_table "clubs", force: :cascade do |t|
|
156
156
|
t.string "name", default: "", null: false
|
157
157
|
t.text "desc"
|
158
158
|
end
|
159
|
-
|
160
|
-
|
159
|
+
ERB
|
160
|
+
end
|
161
161
|
|
162
|
-
let(:expected_dsl)
|
163
|
-
erbh(<<-
|
162
|
+
let(:expected_dsl) do
|
163
|
+
erbh(<<-ERB)
|
164
164
|
create_table "clubs", force: :cascade do |t|
|
165
165
|
t.string "name", default: "", null: false
|
166
166
|
t.text "desc"
|
167
167
|
end
|
168
|
-
|
169
|
-
|
168
|
+
ERB
|
169
|
+
end
|
170
170
|
|
171
171
|
before { subject.diff(actual_dsl).migrate }
|
172
172
|
subject { client }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when change index' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
6
|
t.string "name", limit: 255, default: "", null: false
|
7
7
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -58,11 +58,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
58
58
|
t.date "to_date"
|
59
59
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
ERB
|
62
|
+
end
|
63
63
|
|
64
|
-
let(:expected_dsl)
|
65
|
-
erbh(<<-
|
64
|
+
let(:expected_dsl) do
|
65
|
+
erbh(<<-ERB)
|
66
66
|
create_table "clubs", force: :cascade do |t|
|
67
67
|
t.string "name", limit: 255, default: "", null: false
|
68
68
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -119,8 +119,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
119
119
|
t.date "to_date"
|
120
120
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
121
121
|
end
|
122
|
-
|
123
|
-
|
122
|
+
ERB
|
123
|
+
end
|
124
124
|
|
125
125
|
before { subject.diff(actual_dsl).migrate }
|
126
126
|
subject { client }
|
@@ -134,10 +134,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
}
|
135
135
|
|
136
136
|
it {
|
137
|
-
delta = client(:
|
137
|
+
delta = client(bulk_change: true).diff(expected_dsl)
|
138
138
|
expect(delta.differ?).to be_truthy
|
139
139
|
expect(subject.dump).to match_ruby actual_dsl
|
140
|
-
expect(delta.script).to match_fuzzy <<-
|
140
|
+
expect(delta.script).to match_fuzzy <<-RUBY
|
141
141
|
change_table("dept_emp", {:bulk => true}) do |t|
|
142
142
|
t.remove_index({:name=>"idx_dept_emp_emp_no"})
|
143
143
|
t.index(["from_date"], {:name=>"idx_dept_emp_emp_no", :using=>:btree, :unique=>false})
|
@@ -152,11 +152,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
152
152
|
t.remove_index({:name=>"idx_salaries_emp_no"})
|
153
153
|
t.index(["from_date"], {:name=>"idx_salaries_emp_no", :using=>:btree, :unique=>false})
|
154
154
|
end
|
155
|
-
|
155
|
+
RUBY
|
156
156
|
|
157
|
-
expect
|
157
|
+
expect do
|
158
158
|
delta.migrate
|
159
|
-
|
159
|
+
end.to_not raise_error
|
160
160
|
}
|
161
161
|
end
|
162
162
|
end
|
@@ -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 'with warning' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "dept_manager", force: :cascade do |t|
|
6
6
|
t.string "dept_no", limit: 4, null: false
|
7
7
|
t.date "from_date", null: false
|
@@ -16,11 +16,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
16
16
|
t.string "gender", limit: 1, null: false
|
17
17
|
t.date "hire_date", null: false
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
ERB
|
20
|
+
end
|
21
21
|
|
22
|
-
let(:expected_dsl)
|
23
|
-
erbh(<<-
|
22
|
+
let(:expected_dsl) do
|
23
|
+
erbh(<<-ERB)
|
24
24
|
create_table "dept_manager", force: :cascade do |t|
|
25
25
|
t.string "dept_no", limit: 4, null: false
|
26
26
|
t.date "from_date", null: false
|
@@ -36,18 +36,18 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
36
36
|
t.string "gender", limit: 1, null: false
|
37
37
|
t.date "hire_date", null: false
|
38
38
|
end
|
39
|
-
|
40
|
-
|
39
|
+
ERB
|
40
|
+
end
|
41
41
|
|
42
42
|
before { subject.diff(actual_dsl).migrate }
|
43
43
|
subject { client(check_relation_type: 'bigserial') }
|
44
44
|
|
45
45
|
it {
|
46
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-
|
46
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
|
47
47
|
[WARNING] Relation column type is different.
|
48
48
|
employees.id: {:type=>:integer}
|
49
49
|
dept_manager.employee_id: {:type=>:bigint}
|
50
|
-
|
50
|
+
MSG
|
51
51
|
|
52
52
|
delta = subject.diff(expected_dsl)
|
53
53
|
expect(delta.differ?).to be_truthy
|
@@ -58,8 +58,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'with warning' do
|
61
|
-
let(:actual_dsl)
|
62
|
-
erbh(<<-
|
61
|
+
let(:actual_dsl) do
|
62
|
+
erbh(<<-ERB)
|
63
63
|
create_table "dept_manager", force: :cascade do |t|
|
64
64
|
t.string "dept_no", limit: 4, null: false
|
65
65
|
t.date "from_date", null: false
|
@@ -74,11 +74,11 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
74
74
|
t.string "gender", limit: 1, null: false
|
75
75
|
t.date "hire_date", null: false
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
ERB
|
78
|
+
end
|
79
79
|
|
80
|
-
let(:expected_dsl)
|
81
|
-
erbh(<<-
|
80
|
+
let(:expected_dsl) do
|
81
|
+
erbh(<<-ERB)
|
82
82
|
create_table "dept_manager", force: :cascade do |t|
|
83
83
|
t.string "dept_no", limit: 4, null: false
|
84
84
|
t.date "from_date", null: false
|
@@ -94,8 +94,8 @@ describe 'Ridgepole::Client#diff -> migrate', condition: 5.1 do
|
|
94
94
|
t.string "gender", limit: 1, null: false
|
95
95
|
t.date "hire_date", null: false
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
ERB
|
98
|
+
end
|
99
99
|
|
100
100
|
before { subject.diff(actual_dsl).migrate }
|
101
101
|
subject { client(check_relation_type: 'bigserial') }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when create table' 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", limit: 255, default: "", null: false
|
7
7
|
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
@@ -57,11 +57,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
57
57
|
t.date "to_date"
|
58
58
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
59
59
|
end
|
60
|
-
|
61
|
-
|
60
|
+
ERB
|
61
|
+
end
|
62
62
|
|
63
|
-
let(:actual_dsl)
|
64
|
-
erbh(<<-
|
63
|
+
let(:actual_dsl) do
|
64
|
+
erbh(<<-ERB)
|
65
65
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
66
66
|
t.string "dept_name", limit: 40, null: false
|
67
67
|
end
|
@@ -99,8 +99,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
99
99
|
t.date "to_date"
|
100
100
|
t.index ["emp_no"], name: "idx_titles_emp_no", <%= i cond(5.0, using: :btree) %>
|
101
101
|
end
|
102
|
-
|
103
|
-
|
102
|
+
ERB
|
103
|
+
end
|
104
104
|
|
105
105
|
let(:expected_dsl) { dsl }
|
106
106
|
|