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 drop index' do
|
15
3
|
let(: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", limit
|
31
|
-
t.string "dept_no", limit
|
18
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
19
|
+
t.string "dept_no", <%= i 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
|
-
t.string "dept_no", limit
|
41
|
-
t.integer "emp_no", limit
|
28
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
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", <%=
|
37
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
38
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
39
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
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,31 +50,88 @@ 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", limit
|
66
|
-
t.integer "salary", limit
|
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", limit
|
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(:actual_dsl) { dsl }
|
85
73
|
|
86
74
|
let(:expected_dsl) {
|
87
|
-
|
88
|
-
|
89
|
-
|
75
|
+
erbh(<<-EOS)
|
76
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
77
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
78
|
+
end
|
79
|
+
|
80
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
81
|
+
t.string "dept_name", limit: 40, null: false
|
82
|
+
end
|
83
|
+
|
84
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
85
|
+
|
86
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
88
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
89
|
+
t.date "from_date", null: false
|
90
|
+
t.date "to_date", null: false
|
91
|
+
end
|
92
|
+
|
93
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
94
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
95
|
+
|
96
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
97
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
98
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
99
|
+
t.date "from_date", null: false
|
100
|
+
t.date "to_date", null: false
|
101
|
+
end
|
102
|
+
|
103
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
104
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
105
|
+
|
106
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
107
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
108
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
109
|
+
end
|
110
|
+
|
111
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
112
|
+
t.date "birth_date", null: false
|
113
|
+
t.string "first_name", limit: 14, null: false
|
114
|
+
t.string "last_name", limit: 16, null: false
|
115
|
+
t.string "gender", limit: 1, null: false
|
116
|
+
t.date "hire_date", null: false
|
117
|
+
end
|
118
|
+
|
119
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
120
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
121
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
122
|
+
t.date "from_date", null: false
|
123
|
+
t.date "to_date", null: false
|
124
|
+
end
|
125
|
+
|
126
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
127
|
+
|
128
|
+
create_table "titles", id: false, force: :cascade do |t|
|
129
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
130
|
+
t.string "title", limit: 50, null: false
|
131
|
+
t.date "from_date", null: false
|
132
|
+
t.date "to_date"
|
133
|
+
end
|
134
|
+
EOS
|
90
135
|
}
|
91
136
|
|
92
137
|
before { subject.diff(actual_dsl).migrate }
|
@@ -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 drop table' do
|
15
3
|
let(: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", limit
|
31
|
-
t.string "dept_no", limit
|
18
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
19
|
+
t.string "dept_no", <%= i 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
|
-
t.string "dept_no", limit
|
41
|
-
t.integer "emp_no", limit
|
28
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
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", <%=
|
37
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
38
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
39
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
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,31 +50,73 @@ 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", limit
|
66
|
-
t.integer "salary", limit
|
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", limit
|
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(:actual_dsl) { dsl }
|
85
73
|
|
86
74
|
let(:expected_dsl) {
|
87
|
-
|
88
|
-
|
89
|
-
|
75
|
+
erbh(<<-EOS)
|
76
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
77
|
+
t.string "dept_name", limit: 40, null: false
|
78
|
+
end
|
79
|
+
|
80
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
81
|
+
|
82
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
83
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
84
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
85
|
+
t.date "from_date", null: false
|
86
|
+
t.date "to_date", null: false
|
87
|
+
end
|
88
|
+
|
89
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
90
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
91
|
+
|
92
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
93
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
94
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
95
|
+
t.date "from_date", null: false
|
96
|
+
t.date "to_date", null: false
|
97
|
+
end
|
98
|
+
|
99
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
100
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
101
|
+
|
102
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
103
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
104
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
105
|
+
t.date "from_date", null: false
|
106
|
+
t.date "to_date", null: false
|
107
|
+
end
|
108
|
+
|
109
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
110
|
+
|
111
|
+
create_table "titles", id: false, force: :cascade do |t|
|
112
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
113
|
+
t.string "title", limit: 50, null: false
|
114
|
+
t.date "from_date", null: false
|
115
|
+
t.date "to_date"
|
116
|
+
end
|
117
|
+
|
118
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
119
|
+
EOS
|
90
120
|
}
|
91
121
|
|
92
122
|
before { subject.diff(actual_dsl).migrate }
|
@@ -103,19 +133,19 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
103
133
|
it {
|
104
134
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
105
135
|
expect(delta.differ?).to be_truthy
|
106
|
-
expect(delta.script).to match_fuzzy erbh(<<-EOS
|
107
|
-
create_table("clubs", <%=
|
108
|
-
t.string("name",
|
136
|
+
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
137
|
+
create_table("clubs", <%= unsigned(true) %>) do |t|
|
138
|
+
t.string("name", <%= limit(255) >> {default: "", null: false, limit: 255} %>)
|
109
139
|
end
|
110
140
|
add_index("clubs", ["name"], {:name=>"idx_name", :unique=>true, :using=>:btree})
|
111
141
|
|
112
|
-
create_table("employee_clubs", <%=
|
113
|
-
t.integer("emp_no", <%= {:
|
114
|
-
t.integer("club_id", <%= {:
|
142
|
+
create_table("employee_clubs", <%= unsigned(true) %>) do |t|
|
143
|
+
t.integer("emp_no", <%= limit(4) >> {null: false, limit: 4} + unsigned(true) %>)
|
144
|
+
t.integer("club_id", <%= limit(4) >> {null: false, limit: 4} + unsigned(true) %>)
|
115
145
|
end
|
116
146
|
add_index("employee_clubs", ["emp_no", "club_id"], {:name=>"idx_emp_no_club_id", :using=>:btree})
|
117
147
|
|
118
|
-
create_table("employees", <%= {:
|
148
|
+
create_table("employees", <%= {primary_key: "emp_no"} + unsigned(true) %>) do |t|
|
119
149
|
t.date("birth_date", {:null=>false})
|
120
150
|
t.string("first_name", {:limit=>14, :null=>false})
|
121
151
|
t.string("last_name", {:limit=>16, :null=>false})
|
@@ -1,60 +1,48 @@
|
|
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 database is empty' do
|
15
3
|
let(:actual_dsl) { '' }
|
16
4
|
let(:expected_dsl) {
|
17
|
-
erbh(<<-EOS
|
18
|
-
create_table "clubs", <%= {force: :cascade}
|
19
|
-
t.string "name", limit
|
5
|
+
erbh(<<-EOS)
|
6
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
7
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
20
8
|
end
|
21
9
|
|
22
|
-
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
10
|
+
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
23
11
|
|
24
|
-
create_table "departments", primary_key: "dept_no", <%= {force: :cascade}
|
12
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
25
13
|
t.string "dept_name", limit: 40, null: false
|
26
14
|
end
|
27
15
|
|
28
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
16
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
29
17
|
|
30
18
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
31
|
-
t.integer "emp_no", limit
|
32
|
-
t.string "dept_no", limit
|
19
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
20
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
33
21
|
t.date "from_date", null: false
|
34
22
|
t.date "to_date", null: false
|
35
23
|
end
|
36
24
|
|
37
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
38
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
25
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
26
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
39
27
|
|
40
28
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
41
|
-
t.string "dept_no", limit
|
42
|
-
t.integer "emp_no", limit
|
29
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
30
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
43
31
|
t.date "from_date", null: false
|
44
32
|
t.date "to_date", null: false
|
45
33
|
end
|
46
34
|
|
47
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
48
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
35
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
36
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
49
37
|
|
50
|
-
create_table "employee_clubs", <%= {force: :cascade}
|
51
|
-
t.integer "emp_no", <%=
|
52
|
-
t.integer "club_id", <%=
|
38
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
39
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
40
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
53
41
|
end
|
54
42
|
|
55
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
43
|
+
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
56
44
|
|
57
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
45
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
58
46
|
t.date "birth_date", null: false
|
59
47
|
t.string "first_name", limit: 14, null: false
|
60
48
|
t.string "last_name", limit: 16, null: false
|
@@ -63,22 +51,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
63
51
|
end
|
64
52
|
|
65
53
|
create_table "salaries", id: false, force: :cascade do |t|
|
66
|
-
t.integer "emp_no", limit
|
67
|
-
t.integer "salary", limit
|
54
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
55
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
68
56
|
t.date "from_date", null: false
|
69
57
|
t.date "to_date", null: false
|
70
58
|
end
|
71
59
|
|
72
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
60
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
73
61
|
|
74
62
|
create_table "titles", id: false, force: :cascade do |t|
|
75
|
-
t.integer "emp_no", limit
|
63
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
76
64
|
t.string "title", limit: 50, null: false
|
77
65
|
t.date "from_date", null: false
|
78
66
|
t.date "to_date"
|
79
67
|
end
|
80
68
|
|
81
|
-
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
69
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
82
70
|
EOS
|
83
71
|
}
|
84
72
|
|