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
@@ -2,24 +2,24 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when change column' do
|
3
3
|
let(:actual_dsl) {
|
4
4
|
erbh(<<-EOS)
|
5
|
-
create_table "employees", primary_key: "emp_no",
|
6
|
-
t.date "birth_date",
|
5
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
6
|
+
t.date "birth_date", null: false
|
7
7
|
t.string "first_name", limit: 14, null: false
|
8
|
-
t.string "last_name",
|
9
|
-
t.string "gender",
|
10
|
-
t.date "hire_date",
|
8
|
+
t.string "last_name", limit: 16, null: false
|
9
|
+
t.string "gender", limit: 1, null: false
|
10
|
+
t.date "hire_date", null: false
|
11
11
|
end
|
12
12
|
EOS
|
13
13
|
}
|
14
14
|
|
15
15
|
let(:expected_dsl) {
|
16
16
|
erbh(<<-EOS)
|
17
|
-
create_table "employees", primary_key: "emp_no2",
|
18
|
-
t.date "birth_date",
|
17
|
+
create_table "employees", primary_key: "emp_no2", force: :cascade do |t|
|
18
|
+
t.date "birth_date", null: false
|
19
19
|
t.string "first_name", limit: 14, null: false
|
20
|
-
t.string "last_name",
|
21
|
-
t.string "gender",
|
22
|
-
t.date "hire_date",
|
20
|
+
t.string "last_name", limit: 16, null: false
|
21
|
+
t.string "gender", limit: 1, null: false
|
22
|
+
t.date "hire_date", null: false
|
23
23
|
end
|
24
24
|
EOS
|
25
25
|
}
|
@@ -29,8 +29,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
29
29
|
|
30
30
|
it {
|
31
31
|
expect(Ridgepole::Logger.instance).to receive(:warn).with("[WARNING] No difference of schema configuration for table `employees` but table options differ.")
|
32
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! from:
|
33
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! to:
|
32
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! from: {:primary_key=>"emp_no"}!))
|
33
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! to: {:primary_key=>"emp_no2"}!))
|
34
34
|
delta = subject.diff(expected_dsl)
|
35
35
|
expect(delta.differ?).to be_falsey
|
36
36
|
expect(subject.dump).to match_fuzzy actual_dsl
|
@@ -40,8 +40,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
40
40
|
|
41
41
|
it {
|
42
42
|
expect(Ridgepole::Logger.instance).to receive(:warn).with("[WARNING] No difference of schema configuration for table `employees` but table options differ.")
|
43
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! from:
|
44
|
-
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! to:
|
43
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! from: {:primary_key=>"emp_no2"}!))
|
44
|
+
expect(Ridgepole::Logger.instance).to receive(:warn).with(erbh(%Q! to: {:primary_key=>"emp_no"}!))
|
45
45
|
delta = Ridgepole::Client.diff(actual_dsl, expected_dsl, reverse: true)
|
46
46
|
expect(delta.differ?).to be_falsey
|
47
47
|
}
|
@@ -2,131 +2,120 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
2
2
|
context 'when create index (use t.index)' 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 "clubs",
|
75
|
-
t.string "name",
|
67
|
+
create_table "clubs", force: :cascade do |t|
|
68
|
+
t.string "name", default: "", null: false
|
76
69
|
end
|
77
70
|
|
78
|
-
create_table "departments", primary_key: "dept_no",
|
71
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
79
72
|
t.string "dept_name", limit: 40, null: false
|
73
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
80
74
|
end
|
81
75
|
|
82
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
83
|
-
|
84
76
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
85
|
-
t.integer "emp_no",
|
86
|
-
t.string "dept_no",
|
87
|
-
t.date "from_date",
|
88
|
-
t.date "to_date",
|
77
|
+
t.integer "emp_no", null: false
|
78
|
+
t.string "dept_no", null: false
|
79
|
+
t.date "from_date", null: false
|
80
|
+
t.date "to_date", null: false
|
81
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
82
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
89
83
|
end
|
90
84
|
|
91
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
92
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
93
|
-
|
94
85
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
95
|
-
t.string "dept_no",
|
96
|
-
t.integer "emp_no",
|
97
|
-
t.date "from_date",
|
98
|
-
t.date "to_date",
|
86
|
+
t.string "dept_no", null: false
|
87
|
+
t.integer "emp_no", null: false
|
88
|
+
t.date "from_date", null: false
|
89
|
+
t.date "to_date", null: false
|
90
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
91
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
99
92
|
end
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
105
|
-
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
106
|
-
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
94
|
+
create_table "employee_clubs", force: :cascade do |t|
|
95
|
+
t.integer "emp_no", null: false
|
96
|
+
t.integer "club_id", null: false
|
107
97
|
end
|
108
98
|
|
109
|
-
create_table "employees", primary_key: "emp_no",
|
110
|
-
t.date "birth_date",
|
99
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
100
|
+
t.date "birth_date", null: false
|
111
101
|
t.string "first_name", limit: 14, null: false
|
112
|
-
t.string "last_name",
|
113
|
-
t.string "gender",
|
114
|
-
t.date "hire_date",
|
102
|
+
t.string "last_name", limit: 16, null: false
|
103
|
+
t.string "gender", limit: 1, null: false
|
104
|
+
t.date "hire_date", null: false
|
115
105
|
end
|
116
106
|
|
117
107
|
create_table "salaries", id: false, force: :cascade do |t|
|
118
|
-
t.integer "emp_no",
|
119
|
-
t.integer "salary",
|
120
|
-
t.date "from_date",
|
121
|
-
t.date "to_date",
|
108
|
+
t.integer "emp_no", null: false
|
109
|
+
t.integer "salary", null: false
|
110
|
+
t.date "from_date", null: false
|
111
|
+
t.date "to_date", null: false
|
112
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
122
113
|
end
|
123
114
|
|
124
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
125
|
-
|
126
115
|
create_table "titles", id: false, force: :cascade do |t|
|
127
|
-
t.integer "emp_no",
|
128
|
-
t.string "title",
|
129
|
-
t.date "from_date",
|
116
|
+
t.integer "emp_no", null: false
|
117
|
+
t.string "title", limit: 50, null: false
|
118
|
+
t.date "from_date", null: false
|
130
119
|
t.date "to_date"
|
131
120
|
end
|
132
121
|
EOS
|
@@ -134,66 +123,66 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
134
123
|
|
135
124
|
let(:expected_dsl) {
|
136
125
|
erbh(<<-EOS)
|
137
|
-
create_table "clubs",
|
126
|
+
create_table "clubs", force: :cascade do |t|
|
138
127
|
t.string "name", limit: 255, default: "", null: false
|
139
|
-
t.index ["name"], name: "idx_name", unique: true, using: :btree
|
128
|
+
t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
140
129
|
end
|
141
130
|
|
142
|
-
create_table "departments", primary_key: "dept_no",
|
131
|
+
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
143
132
|
t.string "dept_name", limit: 40, null: false
|
144
133
|
end
|
145
134
|
|
146
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
135
|
+
add_index "departments", ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
147
136
|
|
148
137
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
149
|
-
t.integer "emp_no",
|
150
|
-
t.string "dept_no",
|
151
|
-
t.date "from_date",
|
152
|
-
t.date "to_date",
|
138
|
+
t.integer "emp_no", null: false
|
139
|
+
t.string "dept_no", null: false
|
140
|
+
t.date "from_date", null: false
|
141
|
+
t.date "to_date", null: false
|
153
142
|
end
|
154
143
|
|
155
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
156
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
144
|
+
add_index "dept_emp", ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
145
|
+
add_index "dept_emp", ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
157
146
|
|
158
147
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
159
|
-
t.string "dept_no",
|
160
|
-
t.integer "emp_no",
|
161
|
-
t.date "from_date",
|
162
|
-
t.date "to_date",
|
148
|
+
t.string "dept_no", null: false
|
149
|
+
t.integer "emp_no", null: false
|
150
|
+
t.date "from_date", null: false
|
151
|
+
t.date "to_date", null: false
|
163
152
|
end
|
164
153
|
|
165
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
166
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
154
|
+
add_index "dept_manager", ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
155
|
+
add_index "dept_manager", ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
167
156
|
|
168
|
-
create_table "employee_clubs",
|
169
|
-
t.integer "emp_no",
|
170
|
-
t.integer "club_id",
|
171
|
-
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
157
|
+
create_table "employee_clubs", force: :cascade do |t|
|
158
|
+
t.integer "emp_no", null: false
|
159
|
+
t.integer "club_id", null: false
|
160
|
+
t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
|
172
161
|
end
|
173
162
|
|
174
|
-
create_table "employees", primary_key: "emp_no",
|
175
|
-
t.date "birth_date",
|
163
|
+
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
164
|
+
t.date "birth_date", null: false
|
176
165
|
t.string "first_name", limit: 14, null: false
|
177
|
-
t.string "last_name",
|
178
|
-
t.string "gender",
|
179
|
-
t.date "hire_date",
|
166
|
+
t.string "last_name", limit: 16, null: false
|
167
|
+
t.string "gender", limit: 1, null: false
|
168
|
+
t.date "hire_date", null: false
|
180
169
|
end
|
181
170
|
|
182
171
|
create_table "salaries", id: false, force: :cascade do |t|
|
183
|
-
t.integer "emp_no",
|
184
|
-
t.integer "salary",
|
185
|
-
t.date "from_date",
|
186
|
-
t.date "to_date",
|
172
|
+
t.integer "emp_no", null: false
|
173
|
+
t.integer "salary", null: false
|
174
|
+
t.date "from_date", null: false
|
175
|
+
t.date "to_date", null: false
|
187
176
|
end
|
188
177
|
|
189
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
178
|
+
add_index "salaries", ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
190
179
|
|
191
180
|
create_table "titles", id: false, force: :cascade do |t|
|
192
|
-
t.integer "emp_no",
|
193
|
-
t.string "title",
|
194
|
-
t.date "from_date",
|
181
|
+
t.integer "emp_no", null: false
|
182
|
+
t.string "title", limit: 50, null: false
|
183
|
+
t.date "from_date", null: false
|
195
184
|
t.date "to_date"
|
196
|
-
t.index ["emp_no"], name: "emp_no", using: :btree
|
185
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
197
186
|
end
|
198
187
|
EOS
|
199
188
|
}
|
@@ -4,68 +4,61 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
erbh(<<-EOS)
|
5
5
|
create_table "clubs", force: :cascade do |t|
|
6
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
|
-
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
10
|
-
|
11
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
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
35
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
36
|
-
|
37
33
|
create_table "employee_clubs", force: :cascade do |t|
|
38
|
-
t.integer "emp_no",
|
34
|
+
t.integer "emp_no", null: false
|
39
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
|
-
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
43
|
-
|
44
39
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
45
|
-
t.date "birth_date",
|
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
|
|
@@ -77,56 +70,52 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
77
70
|
|
78
71
|
create_table "departments", primary_key: "dept_no", force: :cascade do |t|
|
79
72
|
t.string "dept_name", limit: 40, null: false
|
73
|
+
t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
|
80
74
|
end
|
81
75
|
|
82
|
-
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
83
|
-
|
84
76
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
85
|
-
t.integer "emp_no",
|
86
|
-
t.string "dept_no",
|
87
|
-
t.date "from_date",
|
88
|
-
t.date "to_date",
|
77
|
+
t.integer "emp_no", null: false
|
78
|
+
t.string "dept_no", null: false
|
79
|
+
t.date "from_date", null: false
|
80
|
+
t.date "to_date", null: false
|
81
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
82
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
89
83
|
end
|
90
84
|
|
91
|
-
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
92
|
-
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
93
|
-
|
94
85
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
95
|
-
t.string "dept_no",
|
96
|
-
t.integer "emp_no",
|
97
|
-
t.date "from_date",
|
98
|
-
t.date "to_date",
|
86
|
+
t.string "dept_no", null: false
|
87
|
+
t.integer "emp_no", null: false
|
88
|
+
t.date "from_date", null: false
|
89
|
+
t.date "to_date", null: false
|
90
|
+
t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
|
91
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
99
92
|
end
|
100
93
|
|
101
|
-
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
102
|
-
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
103
|
-
|
104
94
|
create_table "employee_clubs", force: :cascade do |t|
|
105
|
-
t.integer "emp_no",
|
95
|
+
t.integer "emp_no", null: false
|
106
96
|
t.integer "club_id", null: false
|
107
97
|
end
|
108
98
|
|
109
99
|
create_table "employees", primary_key: "emp_no", force: :cascade do |t|
|
110
|
-
t.date "birth_date",
|
100
|
+
t.date "birth_date", null: false
|
111
101
|
t.string "first_name", limit: 14, null: false
|
112
|
-
t.string "last_name",
|
113
|
-
t.string "gender",
|
114
|
-
t.date "hire_date",
|
102
|
+
t.string "last_name", limit: 16, null: false
|
103
|
+
t.string "gender", limit: 1, null: false
|
104
|
+
t.date "hire_date", null: false
|
115
105
|
end
|
116
106
|
|
117
107
|
create_table "salaries", id: false, force: :cascade do |t|
|
118
|
-
t.integer "emp_no",
|
119
|
-
t.integer "salary",
|
120
|
-
t.date "from_date",
|
121
|
-
t.date "to_date",
|
108
|
+
t.integer "emp_no", null: false
|
109
|
+
t.integer "salary", null: false
|
110
|
+
t.date "from_date", null: false
|
111
|
+
t.date "to_date", null: false
|
112
|
+
t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
|
122
113
|
end
|
123
114
|
|
124
|
-
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
125
|
-
|
126
115
|
create_table "titles", id: false, force: :cascade do |t|
|
127
|
-
t.integer "emp_no",
|
128
|
-
t.string "title",
|
129
|
-
t.date "from_date",
|
116
|
+
t.integer "emp_no", null: false
|
117
|
+
t.string "title", limit: 50, null: false
|
118
|
+
t.date "from_date", null: false
|
130
119
|
t.date "to_date"
|
131
120
|
end
|
132
121
|
EOS
|