ridgepole 0.7.0.alpha → 0.7.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/README.md +7 -5
- data/bin/ridgepole +14 -14
- data/lib/ridgepole/cli/config.rb +1 -1
- data/lib/ridgepole/client.rb +0 -4
- data/lib/ridgepole/delta.rb +15 -9
- data/lib/ridgepole/diff.rb +13 -9
- data/lib/ridgepole/dsl_parser/context.rb +2 -6
- data/lib/ridgepole/version.rb +1 -1
- data/ridgepole.gemspec +3 -1
- data/spec/erb_helper.rb +0 -39
- data/spec/hide_pending_formatter.rb +6 -0
- data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
- data/spec/mysql/bigint_pk/int_pk_spec.rb +9 -9
- data/spec/mysql/cli/ridgepole_spec.rb +2 -2
- data/spec/mysql/collation/collation_spec.rb +28 -28
- data/spec/mysql/comment/comment_spec.rb +36 -36
- data/spec/mysql/default_lambda/default_lambda_spec.rb +1 -1
- data/spec/mysql/diff/diff2_spec.rb +41 -41
- data/spec/mysql/diff/diff_spec.rb +41 -41
- data/spec/mysql/dump/dump_class_method_spec.rb +26 -33
- data/spec/mysql/dump/dump_some_tables_spec.rb +16 -18
- data/spec/mysql/dump/dump_spec.rb +27 -34
- data/spec/mysql/dump/dump_without_table_options_spec.rb +5 -5
- data/spec/mysql/fk/migrate_change_fk_spec.rb +76 -23
- data/spec/mysql/fk/migrate_create_fk_spec.rb +70 -50
- data/spec/mysql/fk/migrate_drop_fk_spec.rb +131 -32
- data/spec/mysql/migrate/check_orphan_index_spec.rb +19 -19
- data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -45
- data/spec/mysql/migrate/migrate_add_column_order_spec.rb +47 -47
- data/spec/mysql/migrate/migrate_add_column_spec.rb +75 -89
- data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +72 -86
- data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +72 -86
- data/spec/mysql/migrate/migrate_change_column2_spec.rb +27 -32
- data/spec/mysql/migrate/migrate_change_column3_spec.rb +78 -78
- data/spec/mysql/migrate/migrate_change_column4_spec.rb +24 -24
- data/spec/mysql/migrate/migrate_change_column5_spec.rb +42 -42
- data/spec/mysql/migrate/migrate_change_column6_spec.rb +60 -60
- data/spec/mysql/migrate/migrate_change_column_default_spec.rb +47 -47
- data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
- data/spec/mysql/migrate/migrate_change_column_spec.rb +65 -79
- data/spec/mysql/migrate/migrate_change_index2_spec.rb +22 -27
- data/spec/mysql/migrate/migrate_change_index3_spec.rb +52 -62
- data/spec/mysql/migrate/migrate_change_index4_spec.rb +32 -38
- data/spec/mysql/migrate/migrate_change_index5_spec.rb +24 -28
- data/spec/mysql/migrate/migrate_change_index6_spec.rb +105 -119
- data/spec/mysql/migrate/migrate_change_index7_spec.rb +27 -30
- data/spec/mysql/migrate/migrate_change_index_spec.rb +99 -120
- data/spec/mysql/migrate/migrate_change_table_option_spec.rb +14 -14
- data/spec/mysql/migrate/migrate_create_index2_spec.rb +101 -112
- data/spec/mysql/migrate/migrate_create_index_spec.rb +55 -66
- data/spec/mysql/migrate/migrate_create_table_spec.rb +68 -91
- data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +1 -1
- data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +58 -70
- data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +62 -76
- data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +58 -72
- data/spec/mysql/migrate/migrate_drop_column_spec.rb +63 -77
- data/spec/mysql/migrate/migrate_drop_index_spec.rb +55 -66
- data/spec/mysql/migrate/migrate_drop_table_spec.rb +51 -63
- data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +3 -3
- data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +12 -12
- data/spec/mysql/migrate/migrate_empty_spec.rb +35 -42
- data/spec/mysql/migrate/migrate_execute_spec.rb +16 -24
- data/spec/mysql/migrate/migrate_log_file_spec.rb +58 -70
- data/spec/mysql/migrate/migrate_merge_mode_spec.rb +75 -99
- data/spec/mysql/migrate/migrate_noop_spec.rb +38 -38
- data/spec/mysql/migrate/migrate_rename_column_spec.rb +74 -88
- data/spec/mysql/migrate/migrate_rename_table_spec.rb +100 -97
- data/spec/mysql/migrate/migrate_same_default_null_spec.rb +18 -18
- data/spec/mysql/migrate/migrate_same_spec.rb +29 -37
- data/spec/mysql/migrate/migrate_script_error_spec.rb +19 -19
- data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +148 -0
- data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +70 -84
- data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +70 -84
- data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +87 -87
- data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +61 -75
- data/spec/mysql/migrate/migrate_with_tables_spec.rb +41 -41
- data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +10 -10
- data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +67 -78
- data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +67 -78
- data/spec/mysql/text_blob_types/text_blob_types_spec.rb +9 -9
- data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
- data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +35 -67
- data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
- data/spec/postgresql/diff/diff_spec.rb +37 -37
- data/spec/postgresql/dump/dump_spec.rb +27 -34
- data/spec/postgresql/fk/migrate_change_fk_spec.rb +76 -23
- data/spec/postgresql/fk/migrate_create_fk_spec.rb +73 -54
- data/spec/postgresql/fk/migrate_drop_fk_spec.rb +131 -32
- data/spec/postgresql/migrate/migrate_add_column_spec.rb +63 -75
- data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
- data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +7 -7
- data/spec/postgresql/migrate/migrate_change_column_spec.rb +53 -65
- data/spec/postgresql/migrate/migrate_change_index_spec.rb +54 -68
- data/spec/postgresql/migrate/migrate_create_table_spec.rb +56 -77
- data/spec/postgresql/migrate/migrate_drop_column_spec.rb +46 -60
- data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +41 -55
- data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
- data/spec/postgresql/migrate/migrate_drop_index_spec.rb +51 -62
- data/spec/postgresql/migrate/migrate_drop_table_spec.rb +48 -60
- data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -6
- data/spec/postgresql/migrate/migrate_rename_column_spec.rb +54 -68
- data/spec/postgresql/migrate/migrate_rename_table_spec.rb +62 -78
- data/spec/postgresql/migrate/migrate_same_spec.rb +27 -34
- data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
- data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +35 -66
- data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
- data/spec/spec_helper.rb +1 -1
- metadata +9 -8
- data/ridgepole.iml +0 -9
- data/spec/string_ext.rb +0 -40
@@ -1,130 +1,107 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
-
let(:template_variables) {
|
3
|
-
opts = {
|
4
|
-
dept_manager_pk: {primary_key: ["emp_no", "dept_no"]},
|
5
|
-
dept_emp_pk: {primary_key: ["emp_no", "dept_no"]},
|
6
|
-
salaries_pk: {primary_key: ["emp_no", "from_date"]},
|
7
|
-
titles_pk: {primary_key: ["emp_no", "title", "from_date"]},
|
8
|
-
}
|
9
|
-
|
10
|
-
opts
|
11
|
-
}
|
12
|
-
|
13
2
|
context 'when create table' do
|
14
3
|
let(:dsl) {
|
15
|
-
erbh(<<-EOS
|
16
|
-
create_table "clubs",
|
17
|
-
t.string "name",
|
4
|
+
erbh(<<-EOS)
|
5
|
+
create_table "clubs", force: :cascade do |t|
|
6
|
+
t.string "name", default: "", null: false
|
7
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
18
8
|
end
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
10
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
23
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
24
13
|
end
|
25
14
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
t.
|
30
|
-
t.
|
31
|
-
t.
|
32
|
-
t.
|
15
|
+
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
16
|
+
t.integer "emp_no", null: false
|
17
|
+
t.string "dept_no", null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
33
22
|
end
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
t.
|
40
|
-
t.
|
41
|
-
t.
|
42
|
-
t.date "to_date", null: false
|
24
|
+
create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
25
|
+
t.string "dept_no", null: false
|
26
|
+
t.integer "emp_no", null: false
|
27
|
+
t.date "from_date", null: false
|
28
|
+
t.date "to_date", null: false
|
29
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
43
31
|
end
|
44
32
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
50
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
33
|
+
create_table "employee_clubs", force: :cascade do |t|
|
34
|
+
t.integer "emp_no", null: false
|
35
|
+
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
51
37
|
end
|
52
38
|
|
53
|
-
|
54
|
-
|
55
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
56
|
-
t.date "birth_date", null: false
|
39
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
40
|
+
t.date "birth_date", null: false
|
57
41
|
t.string "first_name", limit: 14, null: false
|
58
|
-
t.string "last_name",
|
59
|
-
t.string "gender",
|
60
|
-
t.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.string "gender", limit: 1, null: false
|
44
|
+
t.date "hire_date", null: false
|
61
45
|
end
|
62
46
|
|
63
|
-
create_table "salaries",
|
64
|
-
t.integer "emp_no",
|
65
|
-
t.integer "salary",
|
66
|
-
t.date "from_date",
|
67
|
-
t.date "to_date",
|
47
|
+
create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
|
48
|
+
t.integer "emp_no", null: false
|
49
|
+
t.integer "salary", null: false
|
50
|
+
t.date "from_date", null: false
|
51
|
+
t.date "to_date", null: false
|
52
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
68
53
|
end
|
69
54
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
t.
|
74
|
-
t.string "title", limit: 50, null: false
|
75
|
-
t.date "from_date", null: false
|
55
|
+
create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.string "title", limit: 50, null: false
|
58
|
+
t.date "from_date", null: false
|
76
59
|
t.date "to_date"
|
60
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
77
61
|
end
|
78
|
-
|
79
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
80
62
|
EOS
|
81
63
|
}
|
82
64
|
|
83
65
|
let(:actual_dsl) {
|
84
|
-
erbh(<<-EOS
|
85
|
-
create_table "departments", primary_key: "dept_no",
|
66
|
+
erbh(<<-EOS)
|
67
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
86
68
|
t.string "dept_name", limit: 40, null: false
|
69
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
87
70
|
end
|
88
71
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
t.
|
93
|
-
t.
|
94
|
-
t.
|
95
|
-
t.
|
72
|
+
create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
73
|
+
t.integer "emp_no", null: false
|
74
|
+
t.string "dept_no", null: false
|
75
|
+
t.date "from_date", null: false
|
76
|
+
t.date "to_date", null: false
|
77
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
78
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
96
79
|
end
|
97
80
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
t.
|
103
|
-
t.
|
104
|
-
t.
|
105
|
-
t.date "to_date", null: false
|
81
|
+
create_table "dept_manager", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
|
82
|
+
t.string "dept_no", null: false
|
83
|
+
t.integer "emp_no", null: false
|
84
|
+
t.date "from_date", null: false
|
85
|
+
t.date "to_date", null: false
|
86
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
87
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
106
88
|
end
|
107
89
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
t.
|
113
|
-
t.
|
114
|
-
t.date "from_date", null: false
|
115
|
-
t.date "to_date", null: false
|
90
|
+
create_table "salaries", primary_key: ["emp_no", "from_date"], force: :cascade do |t|
|
91
|
+
t.integer "emp_no", null: false
|
92
|
+
t.integer "salary", null: false
|
93
|
+
t.date "from_date", null: false
|
94
|
+
t.date "to_date", null: false
|
95
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
116
96
|
end
|
117
97
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
t.
|
122
|
-
t.string "title", limit: 50, null: false
|
123
|
-
t.date "from_date", null: false
|
98
|
+
create_table "titles", primary_key: ["emp_no", "title", "from_date"], force: :cascade do |t|
|
99
|
+
t.integer "emp_no", null: false
|
100
|
+
t.string "title", limit: 50, null: false
|
101
|
+
t.date "from_date", null: false
|
124
102
|
t.date "to_date"
|
103
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
125
104
|
end
|
126
|
-
|
127
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
128
105
|
EOS
|
129
106
|
}
|
130
107
|
|
@@ -3,7 +3,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
3
3
|
let(:expected_dsl) {
|
4
4
|
<<-EOS
|
5
5
|
create_table "employee_clubs", force: :cascade do |t|
|
6
|
-
t.integer "emp_no",
|
6
|
+
t.integer "emp_no", null: false, unsigned: true
|
7
7
|
t.integer "club_id", null: false, unsigned: true
|
8
8
|
end
|
9
9
|
|
@@ -2,118 +2,106 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when create table' do
|
3
3
|
let(:dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "clubs",
|
6
|
-
t.string "name",
|
5
|
+
create_table "clubs", force: :cascade do |t|
|
6
|
+
t.string "name", default: "", null: false
|
7
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
10
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
12
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
16
|
-
|
17
15
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no",
|
19
|
-
t.string "dept_no",
|
20
|
-
t.date "from_date",
|
21
|
-
t.date "to_date",
|
16
|
+
t.integer "emp_no", null: false
|
17
|
+
t.string "dept_no", null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
26
|
-
|
27
24
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
|
-
t.string "dept_no",
|
29
|
-
t.integer "emp_no",
|
30
|
-
t.date "from_date",
|
31
|
-
t.date "to_date",
|
25
|
+
t.string "dept_no", null: false
|
26
|
+
t.integer "emp_no", null: false
|
27
|
+
t.date "from_date", null: false
|
28
|
+
t.date "to_date", null: false
|
29
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
39
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
33
|
+
create_table "employee_clubs", force: :cascade do |t|
|
34
|
+
t.integer "emp_no", null: false
|
35
|
+
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
45
|
-
t.date "birth_date", null: false
|
39
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
40
|
+
t.date "birth_date", null: false
|
46
41
|
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name",
|
48
|
-
t.string "gender",
|
49
|
-
t.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.string "gender", limit: 1, null: false
|
44
|
+
t.date "hire_date", null: false
|
50
45
|
end
|
51
46
|
|
52
47
|
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
-
t.integer "emp_no",
|
54
|
-
t.integer "salary",
|
55
|
-
t.date "from_date",
|
56
|
-
t.date "to_date",
|
48
|
+
t.integer "emp_no", null: false
|
49
|
+
t.integer "salary", null: false
|
50
|
+
t.date "from_date", null: false
|
51
|
+
t.date "to_date", null: false
|
52
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
57
53
|
end
|
58
54
|
|
59
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
60
|
-
|
61
55
|
create_table "titles", id: false, force: :cascade do |t|
|
62
|
-
t.integer "emp_no",
|
63
|
-
t.string "title",
|
64
|
-
t.date "from_date",
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.string "title", limit: 50, null: false
|
58
|
+
t.date "from_date", null: false
|
65
59
|
t.date "to_date"
|
60
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
66
61
|
end
|
67
|
-
|
68
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
69
62
|
EOS
|
70
63
|
}
|
71
64
|
|
72
65
|
let(:actual_dsl) {
|
73
66
|
erbh(<<-EOS)
|
74
|
-
create_table "departments", primary_key: "dept_no",
|
67
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
75
68
|
t.string "dept_name", limit: 40, null: false
|
69
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
76
70
|
end
|
77
71
|
|
78
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
79
|
-
|
80
72
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
81
|
-
t.integer "emp_no",
|
82
|
-
t.string "dept_no",
|
83
|
-
t.date "from_date",
|
84
|
-
t.date "to_date",
|
73
|
+
t.integer "emp_no", null: false
|
74
|
+
t.string "dept_no", null: false
|
75
|
+
t.date "from_date", null: false
|
76
|
+
t.date "to_date", null: false
|
77
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
78
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
85
79
|
end
|
86
80
|
|
87
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
88
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
89
|
-
|
90
81
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
91
|
-
t.string "dept_no",
|
92
|
-
t.integer "emp_no",
|
93
|
-
t.date "from_date",
|
94
|
-
t.date "to_date",
|
82
|
+
t.string "dept_no", null: false
|
83
|
+
t.integer "emp_no", null: false
|
84
|
+
t.date "from_date", null: false
|
85
|
+
t.date "to_date", null: false
|
86
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
87
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
95
88
|
end
|
96
89
|
|
97
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
98
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
99
|
-
|
100
90
|
create_table "salaries", id: false, force: :cascade do |t|
|
101
|
-
t.integer "emp_no",
|
102
|
-
t.integer "salary",
|
103
|
-
t.date "from_date",
|
104
|
-
t.date "to_date",
|
91
|
+
t.integer "emp_no", null: false
|
92
|
+
t.integer "salary", null: false
|
93
|
+
t.date "from_date", null: false
|
94
|
+
t.date "to_date", null: false
|
95
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
105
96
|
end
|
106
97
|
|
107
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
108
|
-
|
109
98
|
create_table "titles", id: false, force: :cascade do |t|
|
110
|
-
t.integer "emp_no",
|
111
|
-
t.string "title",
|
112
|
-
t.date "from_date",
|
99
|
+
t.integer "emp_no", null: false
|
100
|
+
t.string "title", limit: 50, null: false
|
101
|
+
t.date "from_date", null: false
|
113
102
|
t.date "to_date"
|
103
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
114
104
|
end
|
115
|
-
|
116
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
117
105
|
EOS
|
118
106
|
}
|
119
107
|
|
@@ -2,131 +2,117 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when drop column and index (2)' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "clubs",
|
6
|
-
t.string "name",
|
5
|
+
create_table "clubs", force: :cascade do |t|
|
6
|
+
t.string "name", default: "", null: false
|
7
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
10
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
12
11
|
t.string "dept_name", limit: 40, null: false
|
12
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
13
13
|
end
|
14
14
|
|
15
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
16
|
-
|
17
15
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no",
|
19
|
-
t.string "dept_no",
|
20
|
-
t.date "from_date",
|
21
|
-
t.date "to_date",
|
16
|
+
t.integer "emp_no", null: false
|
17
|
+
t.string "dept_no", null: false
|
18
|
+
t.date "from_date", null: false
|
19
|
+
t.date "to_date", null: false
|
20
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
21
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
22
22
|
end
|
23
23
|
|
24
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
25
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
26
|
-
|
27
24
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
28
|
-
t.string "dept_no",
|
29
|
-
t.integer "emp_no",
|
30
|
-
t.date "from_date",
|
31
|
-
t.date "to_date",
|
25
|
+
t.string "dept_no", null: false
|
26
|
+
t.integer "emp_no", null: false
|
27
|
+
t.date "from_date", null: false
|
28
|
+
t.date "to_date", null: false
|
29
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
30
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
32
31
|
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
39
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
33
|
+
create_table "employee_clubs", force: :cascade do |t|
|
34
|
+
t.integer "emp_no", null: false
|
35
|
+
t.integer "club_id", null: false
|
36
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
45
|
-
t.date "birth_date", null: false
|
39
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
40
|
+
t.date "birth_date", null: false
|
46
41
|
t.string "first_name", limit: 14, null: false
|
47
|
-
t.string "last_name",
|
48
|
-
t.string "gender",
|
49
|
-
t.date "hire_date",
|
42
|
+
t.string "last_name", limit: 16, null: false
|
43
|
+
t.string "gender", limit: 1, null: false
|
44
|
+
t.date "hire_date", null: false
|
50
45
|
end
|
51
46
|
|
52
47
|
create_table "salaries", id: false, force: :cascade do |t|
|
53
|
-
t.integer "emp_no",
|
54
|
-
t.integer "salary",
|
55
|
-
t.date "from_date",
|
56
|
-
t.date "to_date",
|
48
|
+
t.integer "emp_no", null: false
|
49
|
+
t.integer "salary", null: false
|
50
|
+
t.date "from_date", null: false
|
51
|
+
t.date "to_date", null: false
|
52
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
57
53
|
end
|
58
54
|
|
59
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
60
|
-
|
61
55
|
create_table "titles", id: false, force: :cascade do |t|
|
62
|
-
t.integer "emp_no",
|
63
|
-
t.string "title",
|
64
|
-
t.date "from_date",
|
56
|
+
t.integer "emp_no", null: false
|
57
|
+
t.string "title", limit: 50, null: false
|
58
|
+
t.date "from_date", null: false
|
65
59
|
t.date "to_date"
|
60
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
66
61
|
end
|
67
|
-
|
68
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
69
62
|
EOS
|
70
63
|
}
|
71
64
|
|
72
65
|
let(:expected_dsl) {
|
73
66
|
erbh(<<-EOS)
|
74
|
-
create_table "clubs",
|
75
|
-
t.string "name",
|
67
|
+
create_table "clubs", force: :cascade do |t|
|
68
|
+
t.string "name", default: "", null: false
|
69
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
76
70
|
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
72
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
81
73
|
t.string "dept_name", limit: 40, null: false
|
74
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
82
75
|
end
|
83
76
|
|
84
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
85
|
-
|
86
77
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
87
|
-
t.integer "emp_no2",
|
88
|
-
t.string "dept_no",
|
78
|
+
t.integer "emp_no2", null: false
|
79
|
+
t.string "dept_no", null: false
|
80
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
81
|
+
t.index ["emp_no2"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
89
82
|
end
|
90
83
|
|
91
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
92
|
-
<%= add_index "dept_emp", ["emp_no2"], name: "emp_no", using: :btree %>
|
93
|
-
|
94
84
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
95
|
-
t.string "dept_no",
|
85
|
+
t.string "dept_no", null: false
|
86
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
96
87
|
end
|
97
88
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
t.
|
102
|
-
t.
|
89
|
+
create_table "employee_clubs", force: :cascade do |t|
|
90
|
+
t.integer "emp_no", null: false
|
91
|
+
t.integer "club_id2", null: false
|
92
|
+
t.index ["emp_no", "club_id2"], name: "idx_emp_no_club_id2", <%= i cond(5.0, using: :btree) %>
|
93
|
+
t.index ["emp_no"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
103
94
|
end
|
104
95
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
109
|
-
t.date "birth_date", null: false
|
96
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
97
|
+
t.date "birth_date", null: false
|
110
98
|
t.string "first_name", limit: 14, null: false
|
111
99
|
end
|
112
100
|
|
113
101
|
create_table "salaries", id: false, force: :cascade do |t|
|
114
|
-
t.integer "emp_no",
|
115
|
-
t.integer "salary",
|
116
|
-
t.date "from_date",
|
117
|
-
t.date "to_date",
|
102
|
+
t.integer "emp_no", null: false
|
103
|
+
t.integer "salary", null: false
|
104
|
+
t.date "from_date", null: false
|
105
|
+
t.date "to_date", null: false
|
106
|
+
t.index ["emp_no", "salary"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
118
107
|
end
|
119
108
|
|
120
|
-
<%= add_index "salaries", ["emp_no", "salary"], name: "emp_no", using: :btree %>
|
121
|
-
|
122
109
|
create_table "titles", id: false, force: :cascade do |t|
|
123
|
-
t.integer "emp_no",
|
124
|
-
t.string "title",
|
125
|
-
t.date "from_date",
|
110
|
+
t.integer "emp_no", null: false
|
111
|
+
t.string "title", limit: 50, null: false
|
112
|
+
t.date "from_date", null: false
|
126
113
|
t.date "to_date"
|
114
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
127
115
|
end
|
128
|
-
|
129
|
-
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
130
116
|
EOS
|
131
117
|
}
|
132
118
|
|