ridgepole 0.6.5.beta → 0.6.5.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/Appraisals +1 -1
- data/README.md +3 -1
- data/gemfiles/activerecord_5.0.gemfile +1 -1
- data/lib/ridgepole/client.rb +5 -1
- data/lib/ridgepole/delta.rb +21 -5
- data/lib/ridgepole/diff.rb +13 -2
- data/lib/ridgepole/dsl_parser.rb +38 -3
- data/lib/ridgepole/dumper.rb +2 -2
- data/lib/ridgepole/ext/abstract_mysql_adapter/disable_table_options.rb +21 -0
- data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +28 -0
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +3 -3
- data/spec/erb_helper.rb +43 -0
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
- data/spec/mysql/collation/collation_spec.rb +39 -37
- data/spec/mysql/default_lambda/default_lambda_spec.rb +162 -0
- data/spec/mysql/diff/diff2_spec.rb +10 -10
- data/spec/mysql/diff/diff_spec.rb +6 -6
- data/spec/mysql/dump/dump_class_method_spec.rb +56 -39
- data/spec/mysql/dump/dump_some_tables_spec.rb +21 -13
- data/spec/mysql/dump/dump_spec.rb +49 -36
- data/spec/mysql/dump/dump_without_table_options_spec.rb +27 -9
- data/spec/mysql/fk/migrate_change_fk_spec.rb +17 -11
- data/spec/mysql/fk/migrate_create_fk_spec.rb +20 -18
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +30 -16
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +10 -8
- data/spec/mysql/migrate/migrate_add_column_spec.rb +49 -61
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +46 -58
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +46 -58
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +12 -24
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +18 -30
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +8 -20
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +8 -8
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +20 -20
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +2 -2
- data/spec/mysql/migrate/migrate_change_column_spec.rb +54 -68
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +14 -14
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +28 -28
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +26 -38
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +20 -32
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +63 -75
- data/spec/mysql/migrate/migrate_change_index_spec.rb +62 -74
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +8 -20
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +98 -53
- data/spec/mysql/migrate/migrate_create_index_spec.rb +84 -39
- data/spec/mysql/migrate/migrate_create_table_spec.rb +69 -39
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +69 -39
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +47 -59
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +43 -55
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +48 -60
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +84 -39
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +76 -46
- data/spec/mysql/migrate/migrate_empty_spec.rb +24 -36
- data/spec/mysql/migrate/migrate_execute_spec.rb +30 -32
- data/spec/mysql/migrate/migrate_log_file_spec.rb +69 -39
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +48 -48
- data/spec/mysql/migrate/migrate_noop_spec.rb +23 -13
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +48 -60
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +56 -68
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +8 -20
- data/spec/mysql/migrate/migrate_same_spec.rb +49 -31
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +48 -60
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +48 -60
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +34 -34
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +84 -39
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +84 -39
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +84 -0
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +14 -8
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +15 -27
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +10 -10
- data/spec/postgresql/dump/dump_spec.rb +40 -16
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +11 -11
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +52 -12
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +18 -18
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +69 -13
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +55 -13
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +3 -1
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +20 -20
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +24 -24
- data/spec/postgresql/migrate/migrate_same_spec.rb +40 -16
- data/spec/postgresql/ridgepole_test_tables.sql +3 -0
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +11 -11
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
- data/spec/spec_condition.rb +14 -2
- data/spec/spec_helper.rb +12 -11
- data/spec/string_ext.rb +2 -0
- metadata +16 -9
- data/lib/ridgepole/ext/abstract_mysql_adapter.rb +0 -26
@@ -1,59 +1,47 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
-
let(:template_variables) {
|
3
|
-
opts = {
|
4
|
-
unsigned: {}
|
5
|
-
}
|
6
|
-
|
7
|
-
if condition(:mysql_awesome_enabled)
|
8
|
-
opts[:unsigned] = {unsigned: true}
|
9
|
-
end
|
10
|
-
|
11
|
-
opts
|
12
|
-
}
|
13
|
-
|
14
2
|
context 'when add column' do
|
15
3
|
let(:actual_dsl) {
|
16
|
-
erbh(<<-EOS
|
17
|
-
create_table "clubs", <%= {force: :cascade}
|
18
|
-
t.string "name", limit
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
6
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
19
7
|
end
|
20
8
|
|
21
|
-
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
9
|
+
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
22
10
|
|
23
|
-
create_table "departments", primary_key: "dept_no", <%= {force: :cascade}
|
11
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
24
12
|
t.string "dept_name", limit: 40, null: false
|
25
13
|
end
|
26
14
|
|
27
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
15
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
28
16
|
|
29
17
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
30
|
-
t.integer "emp_no",
|
18
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
31
19
|
t.string "dept_no", limit: 4, null: false
|
32
20
|
t.date "from_date", null: false
|
33
21
|
t.date "to_date", null: false
|
34
22
|
end
|
35
23
|
|
36
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
37
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
24
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
25
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
38
26
|
|
39
27
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
40
28
|
t.string "dept_no", limit: 4, null: false
|
41
|
-
t.integer "emp_no",
|
29
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
42
30
|
t.date "from_date", null: false
|
43
31
|
t.date "to_date", null: false
|
44
32
|
end
|
45
33
|
|
46
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
47
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
34
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
35
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
48
36
|
|
49
|
-
create_table "employee_clubs", <%= {force: :cascade}
|
50
|
-
t.integer "emp_no",
|
51
|
-
t.integer "club_id", limit
|
37
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
38
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
39
|
+
t.integer "club_id", <%= i limit(4) + {null: false} %>
|
52
40
|
end
|
53
41
|
|
54
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
42
|
+
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
55
43
|
|
56
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
44
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
57
45
|
t.date "birth_date", null: false
|
58
46
|
t.string "first_name", limit: 14, null: false
|
59
47
|
t.string "last_name", limit: 16, null: false
|
@@ -62,94 +50,94 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
62
50
|
end
|
63
51
|
|
64
52
|
create_table "salaries", id: false, force: :cascade do |t|
|
65
|
-
t.integer "emp_no",
|
66
|
-
t.integer "salary",
|
53
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
54
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
67
55
|
t.date "from_date", null: false
|
68
56
|
t.date "to_date", null: false
|
69
57
|
end
|
70
58
|
|
71
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
59
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
72
60
|
|
73
61
|
create_table "titles", id: false, force: :cascade do |t|
|
74
|
-
t.integer "emp_no",
|
62
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
75
63
|
t.string "title", limit: 50, null: false
|
76
64
|
t.date "from_date", null: false
|
77
65
|
t.date "to_date"
|
78
66
|
end
|
79
67
|
|
80
|
-
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
68
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
81
69
|
EOS
|
82
70
|
}
|
83
71
|
|
84
72
|
let(:expected_dsl) {
|
85
|
-
erbh(<<-EOS
|
86
|
-
create_table "clubs", <%= {force: :cascade}
|
87
|
-
t.string "name", limit
|
73
|
+
erbh(<<-EOS)
|
74
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
75
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
88
76
|
end
|
89
77
|
|
90
|
-
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
78
|
+
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
91
79
|
|
92
|
-
create_table "departments", primary_key: "dept_no", <%= {force: :cascade}
|
80
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
93
81
|
t.string "dept_name", limit: 40, null: false
|
94
82
|
end
|
95
83
|
|
96
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
84
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
97
85
|
|
98
86
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
99
|
-
t.integer "emp_no",
|
87
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
100
88
|
t.string "dept_no", limit: 4, null: false
|
101
89
|
t.date "from_date", null: false
|
102
90
|
t.date "to_date", null: false
|
103
91
|
end
|
104
92
|
|
105
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
106
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
93
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
94
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
107
95
|
|
108
96
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
109
97
|
t.string "dept_no", limit: 4, null: false
|
110
|
-
t.integer "emp_no",
|
98
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
111
99
|
t.date "from_date", null: false
|
112
100
|
t.date "to_date", null: false
|
113
101
|
end
|
114
102
|
|
115
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
116
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
103
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
104
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
117
105
|
|
118
|
-
create_table "employee_clubs", <%= {force: :cascade}
|
119
|
-
t.integer "emp_no",
|
120
|
-
t.integer "club_id", limit
|
121
|
-
t.string "any_col", limit
|
106
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
107
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
108
|
+
t.integer "club_id", <%= i limit(4) + {null: false} %>
|
109
|
+
t.string "any_col", <%= i limit(255) + {null: false} %>
|
122
110
|
end
|
123
111
|
|
124
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
112
|
+
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
125
113
|
|
126
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
114
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
127
115
|
t.date "birth_date", null: false
|
128
116
|
t.string "first_name", limit: 14, null: false
|
129
117
|
t.string "last_name", limit: 16, null: false
|
130
118
|
t.string "gender", limit: 1, null: false
|
131
119
|
t.date "hire_date", null: false
|
132
|
-
t.integer "age", limit
|
120
|
+
t.integer "age", <%= i limit(4) + {null: false} %>
|
133
121
|
t.date "updated_at"
|
134
122
|
end
|
135
123
|
|
136
124
|
create_table "salaries", id: false, force: :cascade do |t|
|
137
|
-
t.integer "emp_no",
|
138
|
-
t.integer "salary",
|
125
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
126
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
139
127
|
t.date "from_date", null: false
|
140
128
|
t.date "to_date", null: false
|
141
129
|
end
|
142
130
|
|
143
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
131
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
144
132
|
|
145
133
|
create_table "titles", id: false, force: :cascade do |t|
|
146
|
-
t.integer "emp_no",
|
134
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
147
135
|
t.string "title", limit: 50, null: false
|
148
136
|
t.date "from_date", null: false
|
149
137
|
t.date "to_date"
|
150
138
|
end
|
151
139
|
|
152
|
-
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
140
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
153
141
|
EOS
|
154
142
|
}
|
155
143
|
|
@@ -1,19 +1,7 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
-
let(:template_variables) {
|
3
|
-
opts = {
|
4
|
-
unsigned: {}
|
5
|
-
}
|
6
|
-
|
7
|
-
if condition(:mysql_awesome_enabled)
|
8
|
-
opts[:unsigned] = {unsigned: true}
|
9
|
-
end
|
10
|
-
|
11
|
-
opts
|
12
|
-
}
|
13
|
-
|
14
2
|
context 'when change column (no change)' do
|
15
3
|
let(:actual_dsl) {
|
16
|
-
<<-EOS
|
4
|
+
erbh(<<-EOS)
|
17
5
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
18
6
|
t.date "birth_date", null: false
|
19
7
|
t.string "first_name", limit: 14, null: false
|
@@ -22,12 +10,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
22
10
|
t.date "hire_date", null: false
|
23
11
|
end
|
24
12
|
|
25
|
-
add_index "employees", ["gender"], name: "gender", using: :btree
|
13
|
+
<%= add_index "employees", ["gender"], name: "gender", using: :btree %>
|
26
14
|
EOS
|
27
15
|
}
|
28
16
|
|
29
17
|
let(:expected_dsl) {
|
30
|
-
<<-EOS
|
18
|
+
erbh(<<-EOS)
|
31
19
|
create_table :employees, primary_key: :emp_no, force: :cascade do |t|
|
32
20
|
t.date "birth_date", null: false
|
33
21
|
t.string "first_name", limit: 14, null: false
|
@@ -36,7 +24,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
36
24
|
t.date :hire_date, null: false
|
37
25
|
end
|
38
26
|
|
39
|
-
add_index :employees, :gender, name: :gender, using: :btree
|
27
|
+
<%= add_index :employees, :gender, name: :gender, using: :btree %>
|
40
28
|
EOS
|
41
29
|
}
|
42
30
|
|
@@ -51,8 +39,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
51
39
|
|
52
40
|
context 'when change column (change)' do
|
53
41
|
let(:actual_dsl) {
|
54
|
-
erbh(<<-EOS
|
55
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
42
|
+
erbh(<<-EOS)
|
43
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
56
44
|
t.date "birth_date", null: false
|
57
45
|
t.string "first_name", limit: 14, null: false
|
58
46
|
t.string "last_name", limit: 16, null: false
|
@@ -60,12 +48,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
60
48
|
t.date "hire_date", null: false
|
61
49
|
end
|
62
50
|
|
63
|
-
add_index "employees", ["gender"], name: "gender", using: :btree
|
51
|
+
<%= add_index "employees", ["gender"], name: "gender", using: :btree %>
|
64
52
|
EOS
|
65
53
|
}
|
66
54
|
|
67
55
|
let(:dsl) {
|
68
|
-
<<-EOS
|
56
|
+
erbh(<<-EOS)
|
69
57
|
create_table :employees, primary_key: :emp_no, force: :cascade do |t|
|
70
58
|
t.date "birth_date", null: false
|
71
59
|
t.string "first_name", limit: 14, null: false
|
@@ -74,13 +62,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
74
62
|
t.date :hire_date2, null: false
|
75
63
|
end
|
76
64
|
|
77
|
-
add_index :employees, :last_name, name: :last_name, using: :btree
|
65
|
+
<%= add_index :employees, :last_name, name: :last_name, using: :btree %>
|
78
66
|
EOS
|
79
67
|
}
|
80
68
|
|
81
69
|
let(:expected_dsl) {
|
82
|
-
erbh(<<-EOS
|
83
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
70
|
+
erbh(<<-EOS)
|
71
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
84
72
|
t.date "birth_date", null: false
|
85
73
|
t.string "first_name", limit: 14, null: false
|
86
74
|
t.string "last_name", limit: 16, null: false
|
@@ -88,7 +76,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
88
76
|
t.date "hire_date2", null: false
|
89
77
|
end
|
90
78
|
|
91
|
-
add_index "employees", ["last_name"], name: "last_name", using: :btree
|
79
|
+
<%= add_index "employees", ["last_name"], name: "last_name", using: :btree %>
|
92
80
|
EOS
|
93
81
|
}
|
94
82
|
|
@@ -1,16 +1,4 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
-
let(:template_variables) {
|
3
|
-
opts = {
|
4
|
-
unsigned: {}
|
5
|
-
}
|
6
|
-
|
7
|
-
if condition(:mysql_awesome_enabled)
|
8
|
-
opts[:unsigned] = {unsigned: true}
|
9
|
-
end
|
10
|
-
|
11
|
-
opts
|
12
|
-
}
|
13
|
-
|
14
2
|
context 'when use timestamps (no change)' do
|
15
3
|
let(:actual_dsl) {
|
16
4
|
<<-EOS
|
@@ -50,8 +38,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
50
38
|
|
51
39
|
context 'when use timestamps (change)' do
|
52
40
|
let(:actual_dsl) {
|
53
|
-
erbh(<<-EOS
|
54
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
41
|
+
erbh(<<-EOS)
|
42
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
55
43
|
t.date "birth_date", null: false
|
56
44
|
t.string "first_name", limit: 14, null: false
|
57
45
|
t.string "last_name", limit: 16, null: false
|
@@ -75,8 +63,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
75
63
|
}
|
76
64
|
|
77
65
|
let(:expected_dsl) {
|
78
|
-
erbh(<<-EOS
|
79
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
66
|
+
erbh(<<-EOS)
|
67
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
80
68
|
t.date "birth_date", null: false
|
81
69
|
t.string "first_name", limit: 14, null: false
|
82
70
|
t.string "last_name", limit: 16, null: false
|
@@ -178,8 +166,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
178
166
|
|
179
167
|
context 'when use references (change)' do
|
180
168
|
let(:actual_dsl) {
|
181
|
-
erbh(<<-EOS
|
182
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
169
|
+
erbh(<<-EOS)
|
170
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
183
171
|
t.date "birth_date", null: false
|
184
172
|
t.string "first_name", limit: 14, null: false
|
185
173
|
t.string "last_name", limit: 16, null: false
|
@@ -203,15 +191,15 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
203
191
|
}
|
204
192
|
|
205
193
|
let(:expected_dsl) {
|
206
|
-
erbh(<<-EOS
|
207
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
194
|
+
erbh(<<-EOS)
|
195
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
208
196
|
t.date "birth_date", null: false
|
209
197
|
t.string "first_name", limit: 14, null: false
|
210
198
|
t.string "last_name", limit: 16, null: false
|
211
199
|
t.string "gender", limit: 1, null: false
|
212
200
|
t.date "hire_date", null: false
|
213
|
-
t.integer "products_id", limit
|
214
|
-
t.integer "user_id",
|
201
|
+
t.integer "products_id", <%= i limit(4) %>
|
202
|
+
t.integer "user_id", <%= i limit(4) %>
|
215
203
|
end
|
216
204
|
EOS
|
217
205
|
}
|
@@ -230,8 +218,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
230
218
|
|
231
219
|
context 'when use references with polymorphic (change)' do
|
232
220
|
let(:actual_dsl) {
|
233
|
-
erbh(<<-EOS
|
234
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
221
|
+
erbh(<<-EOS)
|
222
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
235
223
|
t.date "birth_date", null: false
|
236
224
|
t.string "first_name", limit: 14, null: false
|
237
225
|
t.string "last_name", limit: 16, null: false
|
@@ -255,17 +243,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
255
243
|
}
|
256
244
|
|
257
245
|
let(:expected_dsl) {
|
258
|
-
erbh(<<-EOS
|
259
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
246
|
+
erbh(<<-EOS)
|
247
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
260
248
|
t.date "birth_date", null: false
|
261
249
|
t.string "first_name", limit: 14, null: false
|
262
250
|
t.string "last_name", limit: 16, null: false
|
263
251
|
t.string "gender", limit: 1, null: false
|
264
252
|
t.date "hire_date", null: false
|
265
|
-
t.integer "products_id", limit
|
266
|
-
t.string "products_type", limit
|
267
|
-
t.integer "user_id", limit
|
268
|
-
t.string "user_type", limit
|
253
|
+
t.integer "products_id", <%= i limit(4) %>
|
254
|
+
t.string "products_type", <%= i limit(255) %>
|
255
|
+
t.integer "user_id", <%= i limit(4) %>
|
256
|
+
t.string "user_type", <%= i limit(255) %>
|
269
257
|
end
|
270
258
|
EOS
|
271
259
|
}
|
@@ -1,20 +1,8 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
-
let(:template_variables) {
|
3
|
-
opts = {
|
4
|
-
unsigned: {}
|
5
|
-
}
|
6
|
-
|
7
|
-
if condition(:mysql_awesome_enabled)
|
8
|
-
opts[:unsigned] = {unsigned: true}
|
9
|
-
end
|
10
|
-
|
11
|
-
opts
|
12
|
-
}
|
13
|
-
|
14
2
|
context 'when change column (binary: blob -> varbinary)' do
|
15
3
|
let(:actual_dsl) {
|
16
|
-
erbh(<<-EOS
|
17
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
18
6
|
t.date "birth_date", null: false
|
19
7
|
t.string "first_name", limit: 14, null: false
|
20
8
|
t.string "last_name", limit: 16, null: false
|
@@ -28,8 +16,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
28
16
|
}
|
29
17
|
|
30
18
|
let(:expected_dsl) {
|
31
|
-
erbh(<<-EOS
|
32
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
19
|
+
erbh(<<-EOS)
|
20
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
33
21
|
t.date "birth_date", null: false
|
34
22
|
t.string "first_name", limit: 14, null: false
|
35
23
|
t.string "last_name", limit: 16, null: false
|
@@ -56,8 +44,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
56
44
|
|
57
45
|
context 'when change column (binary: varbinary -> blob)' do
|
58
46
|
let(:actual_dsl) {
|
59
|
-
erbh(<<-EOS
|
60
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
47
|
+
erbh(<<-EOS)
|
48
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
61
49
|
t.date "birth_date", null: false
|
62
50
|
t.string "first_name", limit: 14, null: false
|
63
51
|
t.string "last_name", limit: 16, null: false
|
@@ -71,8 +59,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
71
59
|
}
|
72
60
|
|
73
61
|
let(:expected_dsl) {
|
74
|
-
erbh(<<-EOS
|
75
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
62
|
+
erbh(<<-EOS)
|
63
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
76
64
|
t.date "birth_date", null: false
|
77
65
|
t.string "first_name", limit: 14, null: false
|
78
66
|
t.string "last_name", limit: 16, null: false
|