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,18 +1,18 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when add column (int/noop) (1)' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
6
6
|
t.integer "emp_no", null: false
|
7
7
|
t.string "dept_no", limit: 4, null: false
|
8
8
|
t.date "from_date", null: false
|
9
9
|
t.date "to_date", null: false
|
10
10
|
end
|
11
|
-
|
12
|
-
|
11
|
+
ERB
|
12
|
+
end
|
13
13
|
|
14
|
-
let(:expected_dsl)
|
15
|
-
<<-
|
14
|
+
let(:expected_dsl) do
|
15
|
+
<<-RUBY
|
16
16
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
17
17
|
t.integer "emp_no", limit: 4, null: false
|
18
18
|
t.integer "emp_no2", null: false
|
@@ -20,8 +20,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
RUBY
|
24
|
+
end
|
25
25
|
|
26
26
|
before { subject.diff(actual_dsl).migrate }
|
27
27
|
subject { client }
|
@@ -30,28 +30,28 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
30
30
|
delta = subject.diff(expected_dsl)
|
31
31
|
expect(delta.differ?).to be_truthy
|
32
32
|
expect(subject.dump).to match_ruby actual_dsl
|
33
|
-
migrated, sql = delta.migrate(:
|
33
|
+
migrated, sql = delta.migrate(noop: true)
|
34
34
|
expect(migrated).to be_truthy
|
35
35
|
expect(subject.dump).to match_ruby actual_dsl
|
36
36
|
|
37
|
-
expect(sql).to match_fuzzy erbh(
|
37
|
+
expect(sql).to match_fuzzy erbh('ALTER TABLE `dept_emp` ADD `emp_no2` int NOT NULL AFTER `emp_no`')
|
38
38
|
}
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'when add column (int/noop) (2)' do
|
42
|
-
let(:actual_dsl)
|
43
|
-
erbh(<<-
|
42
|
+
let(:actual_dsl) do
|
43
|
+
erbh(<<-ERB)
|
44
44
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
45
45
|
t.integer "emp_no", null: false
|
46
46
|
t.string "dept_no", limit: 4, null: false
|
47
47
|
t.date "from_date", null: false
|
48
48
|
t.date "to_date", null: false
|
49
49
|
end
|
50
|
-
|
51
|
-
|
50
|
+
ERB
|
51
|
+
end
|
52
52
|
|
53
|
-
let(:expected_dsl)
|
54
|
-
<<-
|
53
|
+
let(:expected_dsl) do
|
54
|
+
<<-RUBY
|
55
55
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
56
56
|
t.integer "emp_no", limit: 3, null: false
|
57
57
|
t.integer "emp_no2", null: false
|
@@ -59,38 +59,38 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
59
59
|
t.date "from_date", null: false
|
60
60
|
t.date "to_date", null: false
|
61
61
|
end
|
62
|
-
|
63
|
-
|
62
|
+
RUBY
|
63
|
+
end
|
64
64
|
|
65
65
|
before { subject.diff(actual_dsl).migrate }
|
66
|
-
subject { client(:
|
66
|
+
subject { client(default_integer_limit: 3) }
|
67
67
|
|
68
68
|
it {
|
69
69
|
delta = subject.diff(expected_dsl)
|
70
70
|
expect(delta.differ?).to be_truthy
|
71
71
|
expect(subject.dump).to match_ruby actual_dsl.sub(/"emp_no"/, '"emp_no", limit: 3')
|
72
|
-
migrated, sql = delta.migrate(:
|
72
|
+
migrated, sql = delta.migrate(noop: true)
|
73
73
|
expect(migrated).to be_truthy
|
74
74
|
expect(subject.dump).to match_ruby actual_dsl.sub(/"emp_no"/, '"emp_no", limit: 3')
|
75
75
|
|
76
|
-
expect(sql).to match_fuzzy erbh(
|
76
|
+
expect(sql).to match_fuzzy erbh('ALTER TABLE `dept_emp` ADD `emp_no2` mediumint NOT NULL AFTER `emp_no`')
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
80
80
|
context 'when add column (int/noop) (3)' do
|
81
|
-
let(:actual_dsl)
|
82
|
-
erbh(<<-
|
81
|
+
let(:actual_dsl) do
|
82
|
+
erbh(<<-ERB)
|
83
83
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
84
84
|
t.integer "emp_no", null: false
|
85
85
|
t.string "dept_no", limit: 4, null: false
|
86
86
|
t.date "from_date", null: false
|
87
87
|
t.date "to_date", null: false
|
88
88
|
end
|
89
|
-
|
90
|
-
|
89
|
+
ERB
|
90
|
+
end
|
91
91
|
|
92
|
-
let(:expected_dsl)
|
93
|
-
<<-
|
92
|
+
let(:expected_dsl) do
|
93
|
+
<<-RUBY
|
94
94
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
95
95
|
t.integer "emp_no", limit: 3, null: false
|
96
96
|
t.integer "emp_no2", limit: 4, null: false
|
@@ -98,38 +98,38 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
98
98
|
t.date "from_date", null: false
|
99
99
|
t.date "to_date", null: false
|
100
100
|
end
|
101
|
-
|
102
|
-
|
101
|
+
RUBY
|
102
|
+
end
|
103
103
|
|
104
104
|
before { subject.diff(actual_dsl).migrate }
|
105
|
-
subject { client(:
|
105
|
+
subject { client(default_integer_limit: 3) }
|
106
106
|
|
107
107
|
it {
|
108
108
|
delta = subject.diff(expected_dsl)
|
109
109
|
expect(delta.differ?).to be_truthy
|
110
110
|
expect(subject.dump).to match_ruby actual_dsl.sub(/"emp_no"/, '"emp_no", limit: 3')
|
111
|
-
migrated, sql = delta.migrate(:
|
111
|
+
migrated, sql = delta.migrate(noop: true)
|
112
112
|
expect(migrated).to be_truthy
|
113
113
|
expect(subject.dump).to match_ruby actual_dsl.sub(/"emp_no"/, '"emp_no", limit: 3')
|
114
114
|
|
115
|
-
expect(sql).to match_fuzzy erbh(
|
115
|
+
expect(sql).to match_fuzzy erbh('ALTER TABLE `dept_emp` ADD `emp_no2` int NOT NULL AFTER `emp_no`')
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
119
119
|
context 'when add column (bigint/noop)' do
|
120
|
-
let(:actual_dsl)
|
121
|
-
erbh(<<-
|
120
|
+
let(:actual_dsl) do
|
121
|
+
erbh(<<-ERB)
|
122
122
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
123
123
|
t.bigint "emp_no", null: false
|
124
124
|
t.string "dept_no", limit: 4, null: false
|
125
125
|
t.date "from_date", null: false
|
126
126
|
t.date "to_date", null: false
|
127
127
|
end
|
128
|
-
|
129
|
-
|
128
|
+
ERB
|
129
|
+
end
|
130
130
|
|
131
|
-
let(:expected_dsl)
|
132
|
-
<<-
|
131
|
+
let(:expected_dsl) do
|
132
|
+
<<-RUBY
|
133
133
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
134
134
|
t.bigint "emp_no", limit: 9, null: false
|
135
135
|
t.integer "emp_no2", null: false
|
@@ -137,21 +137,21 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
137
137
|
t.date "from_date", null: false
|
138
138
|
t.date "to_date", null: false
|
139
139
|
end
|
140
|
-
|
141
|
-
|
140
|
+
RUBY
|
141
|
+
end
|
142
142
|
|
143
143
|
before { subject.diff(actual_dsl).migrate }
|
144
|
-
subject { client(:
|
144
|
+
subject { client(default_bigint_limit: 9) }
|
145
145
|
|
146
146
|
it {
|
147
147
|
delta = subject.diff(expected_dsl)
|
148
148
|
expect(delta.differ?).to be_truthy
|
149
149
|
expect(subject.dump).to match_ruby actual_dsl
|
150
|
-
migrated, sql = delta.migrate(:
|
150
|
+
migrated, sql = delta.migrate(noop: true)
|
151
151
|
expect(migrated).to be_truthy
|
152
152
|
expect(subject.dump).to match_ruby actual_dsl
|
153
153
|
|
154
|
-
expect(sql).to match_fuzzy erbh(
|
154
|
+
expect(sql).to match_fuzzy erbh('ALTER TABLE `dept_emp` ADD `emp_no2` int NOT NULL AFTER `emp_no`')
|
155
155
|
}
|
156
156
|
end
|
157
157
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
context 'when add column to first' do
|
3
|
-
let(:actual_dsl)
|
4
|
-
erbh(<<-
|
3
|
+
let(:actual_dsl) do
|
4
|
+
erbh(<<-ERB)
|
5
5
|
create_table "dept_emp", force: :cascade do |t|
|
6
6
|
t.integer "emp_no", null: false
|
7
7
|
t.string "dept_no", limit: 4, null: false
|
8
8
|
t.date "from_date", null: false
|
9
9
|
t.date "to_date", null: false
|
10
10
|
end
|
11
|
-
|
12
|
-
|
11
|
+
ERB
|
12
|
+
end
|
13
13
|
|
14
|
-
let(:expected_dsl)
|
15
|
-
erbh(<<-
|
14
|
+
let(:expected_dsl) do
|
15
|
+
erbh(<<-ERB)
|
16
16
|
create_table "dept_emp", force: :cascade do |t|
|
17
17
|
t.integer "emp_no0", null: false
|
18
18
|
t.integer "emp_no", null: false
|
@@ -20,8 +20,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
20
20
|
t.date "from_date", null: false
|
21
21
|
t.date "to_date", null: false
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
ERB
|
24
|
+
end
|
25
25
|
|
26
26
|
before { subject.diff(actual_dsl).migrate }
|
27
27
|
subject { client }
|
@@ -33,7 +33,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
33
33
|
delta.migrate
|
34
34
|
expect(subject.dump).to match_ruby expected_dsl
|
35
35
|
|
36
|
-
expect(show_create_table_mysql('dept_emp')).to match_fuzzy erbh(<<-
|
36
|
+
expect(show_create_table_mysql('dept_emp')).to match_fuzzy erbh(<<-ERB)
|
37
37
|
CREATE TABLE `dept_emp` (
|
38
38
|
`id` <%= cond('>= 5.1','bigint(20)', 'int(11)') %> NOT NULL AUTO_INCREMENT,
|
39
39
|
`emp_no0` int(11) NOT NULL,
|
@@ -43,24 +43,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
43
43
|
`to_date` date NOT NULL,
|
44
44
|
PRIMARY KEY (`id`)
|
45
45
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
46
|
-
|
46
|
+
ERB
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when add column to first (no id)' do
|
51
|
-
let(:actual_dsl)
|
52
|
-
erbh(<<-
|
51
|
+
let(:actual_dsl) do
|
52
|
+
erbh(<<-ERB)
|
53
53
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
54
54
|
t.integer "emp_no", null: false
|
55
55
|
t.string "dept_no", limit: 4, null: false
|
56
56
|
t.date "from_date", null: false
|
57
57
|
t.date "to_date", null: false
|
58
58
|
end
|
59
|
-
|
60
|
-
|
59
|
+
ERB
|
60
|
+
end
|
61
61
|
|
62
|
-
let(:expected_dsl)
|
63
|
-
erbh(<<-
|
62
|
+
let(:expected_dsl) do
|
63
|
+
erbh(<<-ERB)
|
64
64
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
65
65
|
t.integer "emp_no0", null: false
|
66
66
|
t.integer "emp_no", null: false
|
@@ -68,8 +68,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
68
68
|
t.date "from_date", null: false
|
69
69
|
t.date "to_date", null: false
|
70
70
|
end
|
71
|
-
|
72
|
-
|
71
|
+
ERB
|
72
|
+
end
|
73
73
|
|
74
74
|
before { subject.diff(actual_dsl).migrate }
|
75
75
|
subject { client }
|
@@ -81,7 +81,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
81
81
|
delta.migrate
|
82
82
|
expect(subject.dump).to match_ruby expected_dsl
|
83
83
|
|
84
|
-
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-
|
84
|
+
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-SQL
|
85
85
|
CREATE TABLE `dept_emp` (
|
86
86
|
`emp_no0` int(11) NOT NULL,
|
87
87
|
`emp_no` int(11) NOT NULL,
|
@@ -89,31 +89,31 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
89
89
|
`from_date` date NOT NULL,
|
90
90
|
`to_date` date NOT NULL
|
91
91
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
92
|
-
|
92
|
+
SQL
|
93
93
|
}
|
94
94
|
end
|
95
95
|
|
96
96
|
context 'when add column to first (with pk)' do
|
97
|
-
let(:actual_dsl)
|
98
|
-
erbh(<<-
|
97
|
+
let(:actual_dsl) do
|
98
|
+
erbh(<<-ERB)
|
99
99
|
create_table "dept_emp", primary_key: "emp_no", force: :cascade do |t|
|
100
100
|
t.string "dept_no", limit: 4, null: false
|
101
101
|
t.date "from_date", null: false
|
102
102
|
t.date "to_date", null: false
|
103
103
|
end
|
104
|
-
|
105
|
-
|
104
|
+
ERB
|
105
|
+
end
|
106
106
|
|
107
|
-
let(:expected_dsl)
|
108
|
-
erbh(<<-
|
107
|
+
let(:expected_dsl) do
|
108
|
+
erbh(<<-ERB)
|
109
109
|
create_table "dept_emp", primary_key: "emp_no", force: :cascade do |t|
|
110
110
|
t.integer "emp_no0", null: false
|
111
111
|
t.string "dept_no", limit: 4, null: false
|
112
112
|
t.date "from_date", null: false
|
113
113
|
t.date "to_date", null: false
|
114
114
|
end
|
115
|
-
|
116
|
-
|
115
|
+
ERB
|
116
|
+
end
|
117
117
|
|
118
118
|
before { subject.diff(actual_dsl).migrate }
|
119
119
|
subject { client }
|
@@ -125,7 +125,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
125
125
|
delta.migrate
|
126
126
|
expect(subject.dump).to match_ruby expected_dsl
|
127
127
|
|
128
|
-
expect(show_create_table_mysql('dept_emp')).to match_fuzzy erbh(<<-
|
128
|
+
expect(show_create_table_mysql('dept_emp')).to match_fuzzy erbh(<<-ERB)
|
129
129
|
CREATE TABLE `dept_emp` (
|
130
130
|
`emp_no` <%= cond('>= 5.1','bigint(20)', 'int(11)') %> NOT NULL AUTO_INCREMENT,
|
131
131
|
`emp_no0` int(11) NOT NULL,
|
@@ -134,13 +134,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
134
|
`to_date` date NOT NULL,
|
135
135
|
PRIMARY KEY (`emp_no`)
|
136
136
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
137
|
-
|
137
|
+
ERB
|
138
138
|
}
|
139
139
|
end
|
140
140
|
|
141
141
|
context 'when add column to first (with multiple pk)' do
|
142
|
-
let(:actual_dsl)
|
143
|
-
erbh(<<-
|
142
|
+
let(:actual_dsl) do
|
143
|
+
erbh(<<-ERB)
|
144
144
|
create_table "dept_emp", primary_key: ["emp_no1", "emp_no2"], force: :cascade do |t|
|
145
145
|
t.integer "emp_no1", null: false
|
146
146
|
t.integer "emp_no2", null: false
|
@@ -148,11 +148,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
148
148
|
t.date "from_date", null: false
|
149
149
|
t.date "to_date", null: false
|
150
150
|
end
|
151
|
-
|
152
|
-
|
151
|
+
ERB
|
152
|
+
end
|
153
153
|
|
154
|
-
let(:expected_dsl)
|
155
|
-
erbh(<<-
|
154
|
+
let(:expected_dsl) do
|
155
|
+
erbh(<<-ERB)
|
156
156
|
create_table "dept_emp", primary_key: ["emp_no1", "emp_no2"], force: :cascade do |t|
|
157
157
|
t.integer "emp_no1", null: false
|
158
158
|
t.integer "emp_no2", null: false
|
@@ -161,8 +161,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
161
161
|
t.date "from_date", null: false
|
162
162
|
t.date "to_date", null: false
|
163
163
|
end
|
164
|
-
|
165
|
-
|
164
|
+
ERB
|
165
|
+
end
|
166
166
|
|
167
167
|
before { subject.diff(actual_dsl).migrate }
|
168
168
|
subject { client }
|
@@ -174,7 +174,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
174
174
|
delta.migrate
|
175
175
|
expect(subject.dump).to match_ruby expected_dsl
|
176
176
|
|
177
|
-
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-
|
177
|
+
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-SQL
|
178
178
|
CREATE TABLE `dept_emp` (
|
179
179
|
`emp_no1` int(11) NOT NULL,
|
180
180
|
`emp_no2` int(11) NOT NULL,
|
@@ -184,13 +184,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
184
184
|
`to_date` date NOT NULL,
|
185
185
|
PRIMARY KEY (`emp_no1`,`emp_no2`)
|
186
186
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
187
|
-
|
187
|
+
SQL
|
188
188
|
}
|
189
189
|
end
|
190
190
|
|
191
191
|
context 'when add column to first (with multiple pk2)' do
|
192
|
-
let(:actual_dsl)
|
193
|
-
erbh(<<-
|
192
|
+
let(:actual_dsl) do
|
193
|
+
erbh(<<-ERB)
|
194
194
|
create_table "dept_emp", primary_key: ["emp_no1", "emp_no2"], force: :cascade do |t|
|
195
195
|
t.integer "emp_no1", null: false
|
196
196
|
t.integer "emp_no2", null: false
|
@@ -198,11 +198,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
198
198
|
t.date "from_date", null: false
|
199
199
|
t.date "to_date", null: false
|
200
200
|
end
|
201
|
-
|
202
|
-
|
201
|
+
ERB
|
202
|
+
end
|
203
203
|
|
204
|
-
let(:expected_dsl)
|
205
|
-
erbh(<<-
|
204
|
+
let(:expected_dsl) do
|
205
|
+
erbh(<<-ERB)
|
206
206
|
create_table "dept_emp", primary_key: ["emp_no1", "emp_no2"], force: :cascade do |t|
|
207
207
|
t.integer "emp_no0", null: false
|
208
208
|
t.integer "emp_no1", null: false
|
@@ -211,8 +211,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
211
211
|
t.date "from_date", null: false
|
212
212
|
t.date "to_date", null: false
|
213
213
|
end
|
214
|
-
|
215
|
-
|
214
|
+
ERB
|
215
|
+
end
|
216
216
|
|
217
217
|
before { subject.diff(actual_dsl).migrate }
|
218
218
|
subject { client }
|
@@ -224,7 +224,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
224
224
|
delta.migrate
|
225
225
|
expect(subject.dump).to match_ruby expected_dsl
|
226
226
|
|
227
|
-
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-
|
227
|
+
expect(show_create_table_mysql('dept_emp')).to match_fuzzy <<-SQL
|
228
228
|
CREATE TABLE `dept_emp` (
|
229
229
|
`emp_no0` int(11) NOT NULL,
|
230
230
|
`emp_no1` int(11) NOT NULL,
|
@@ -234,7 +234,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
234
234
|
`to_date` date NOT NULL,
|
235
235
|
PRIMARY KEY (`emp_no1`,`emp_no2`)
|
236
236
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
237
|
-
|
237
|
+
SQL
|
238
238
|
}
|
239
239
|
end
|
240
240
|
end
|