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
@@ -4,8 +4,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
4
4
|
sql_int_type: 'int(11)',
|
5
5
|
}
|
6
6
|
|
7
|
-
if condition(:mysql_awesome_enabled)
|
8
|
-
opts
|
7
|
+
if condition(:mysql_awesome_enabled, :activerecord_5)
|
8
|
+
opts.merge!(
|
9
|
+
sql_int_type: 'int'
|
10
|
+
)
|
9
11
|
end
|
10
12
|
|
11
13
|
opts
|
@@ -13,9 +15,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
13
15
|
|
14
16
|
context 'when add column (int/noop) (1)' do
|
15
17
|
let(:actual_dsl) {
|
16
|
-
<<-EOS
|
18
|
+
erbh(<<-EOS, template_variables)
|
17
19
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
18
|
-
t.integer "emp_no", limit
|
20
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
19
21
|
t.string "dept_no", limit: 4, null: false
|
20
22
|
t.date "from_date", null: false
|
21
23
|
t.date "to_date", null: false
|
@@ -52,9 +54,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
52
54
|
|
53
55
|
context 'when add column (int/noop) (2)' do
|
54
56
|
let(:actual_dsl) {
|
55
|
-
<<-EOS
|
57
|
+
erbh(<<-EOS, template_variables)
|
56
58
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
57
|
-
t.integer "emp_no", limit
|
59
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
58
60
|
t.string "dept_no", limit: 4, null: false
|
59
61
|
t.date "from_date", null: false
|
60
62
|
t.date "to_date", null: false
|
@@ -91,9 +93,9 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
91
93
|
|
92
94
|
context 'when add column (int/noop) (3)' do
|
93
95
|
let(:actual_dsl) {
|
94
|
-
<<-EOS
|
96
|
+
erbh(<<-EOS, template_variables)
|
95
97
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
96
|
-
t.integer "emp_no", limit
|
98
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
97
99
|
t.string "dept_no", limit: 4, null: false
|
98
100
|
t.date "from_date", null: false
|
99
101
|
t.date "to_date", null: false
|
@@ -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
|
|
@@ -179,13 +167,13 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
179
167
|
delta = client(:bulk_change => true).diff(expected_dsl)
|
180
168
|
expect(delta.differ?).to be_truthy
|
181
169
|
expect(subject.dump).to match_fuzzy actual_dsl
|
182
|
-
expect(delta.script).to match_fuzzy <<-EOS
|
170
|
+
expect(delta.script).to match_fuzzy erbh(<<-EOS)
|
183
171
|
change_table("employee_clubs", {:bulk => true}) do |t|
|
184
|
-
t.column("any_col", :string,
|
172
|
+
t.column("any_col", :string, <%= limit(255) >> {null: false, after: "club_id", limit: 255} %>)
|
185
173
|
end
|
186
174
|
|
187
175
|
change_table("employees", {:bulk => true}) do |t|
|
188
|
-
t.column("age", :integer,
|
176
|
+
t.column("age", :integer, <%= limit(4) >> {null: false, after: "hire_date", limit: 4} %>)
|
189
177
|
t.column("updated_at", :date, {:after=>"age"})
|
190
178
|
end
|
191
179
|
EOS
|
@@ -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
|
|