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,13 +1,11 @@
|
|
1
1
|
describe 'Ridgepole::Client#diff -> migrate' do
|
2
2
|
let(:template_variables) {
|
3
3
|
opts = {
|
4
|
-
unsigned: {},
|
5
4
|
sql_int_type: 'int(11)',
|
6
5
|
test_schema: TEST_SCHEMA,
|
7
6
|
}
|
8
7
|
|
9
8
|
if condition(:mysql_awesome_enabled)
|
10
|
-
opts[:unsigned] = {unsigned: true}
|
11
9
|
opts[:sql_int_type] = 'int(10) unsigned'
|
12
10
|
end
|
13
11
|
|
@@ -17,16 +15,16 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
17
15
|
context 'when execute' do
|
18
16
|
let(:dsl) {
|
19
17
|
erbh(<<-EOS, template_variables)
|
20
|
-
create_table "authors", <%= {force: :cascade}
|
21
|
-
t.string "name", limit
|
18
|
+
create_table "authors", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
19
|
+
t.string "name", <%= i limit(255) + {null: false} %>
|
22
20
|
end
|
23
21
|
|
24
|
-
create_table "books", <%= {force: :cascade}
|
25
|
-
t.string "title", limit
|
26
|
-
t.integer "author_id", <%=
|
22
|
+
create_table "books", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
23
|
+
t.string "title", <%= i limit(255) + {null: false} %>
|
24
|
+
t.integer "author_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
27
25
|
end
|
28
26
|
|
29
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
27
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
30
28
|
EOS
|
31
29
|
}
|
32
30
|
|
@@ -38,10 +36,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
38
36
|
|
39
37
|
create_table "books", force: :cascade do |t|
|
40
38
|
t.string "title", null: false
|
41
|
-
t.integer "author_id", <%=
|
39
|
+
t.integer "author_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
42
40
|
end
|
43
41
|
|
44
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
42
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
45
43
|
|
46
44
|
execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
|
47
45
|
c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '<%= @test_schema %>' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
|
@@ -88,17 +86,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
88
86
|
|
89
87
|
context 'when not execute' do
|
90
88
|
let(:dsl) {
|
91
|
-
<<-EOS
|
89
|
+
erbh(<<-EOS, template_variables)
|
92
90
|
create_table "authors", force: :cascade do |t|
|
93
|
-
t.string "name", limit
|
91
|
+
t.string "name", <%= i limit(255) + {null: false} %>
|
94
92
|
end
|
95
93
|
|
96
94
|
create_table "books", force: :cascade do |t|
|
97
|
-
t.string "title", limit
|
98
|
-
t.integer "author_id", limit
|
95
|
+
t.string "title", <%= i limit(255) + {null: false} %>
|
96
|
+
t.integer "author_id", <%= i limit(4) + {null: false} %>
|
99
97
|
end
|
100
98
|
|
101
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
99
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
102
100
|
add_foreign_key "books", "authors", name: "fk_author"
|
103
101
|
EOS
|
104
102
|
}
|
@@ -111,10 +109,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
111
109
|
|
112
110
|
create_table "books", force: :cascade do |t|
|
113
111
|
t.string "title", null: false
|
114
|
-
t.integer "author_id", limit
|
112
|
+
t.integer "author_id", <%= i limit(4) + {null: false} %>
|
115
113
|
end
|
116
114
|
|
117
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
115
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
118
116
|
|
119
117
|
execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
|
120
118
|
c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '<%= @test_schema %>' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
|
@@ -163,16 +161,16 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
163
161
|
context 'when execute (noop)' do
|
164
162
|
let(:dsl) {
|
165
163
|
erbh(<<-EOS, template_variables)
|
166
|
-
create_table "authors", <%= {force: :cascade}
|
167
|
-
t.string "name", limit
|
164
|
+
create_table "authors", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
165
|
+
t.string "name", <%= i limit(255) + {null: false} %>
|
168
166
|
end
|
169
167
|
|
170
|
-
create_table "books", <%= {force: :cascade}
|
171
|
-
t.string "title", limit
|
172
|
-
t.integer "author_id", <%=
|
168
|
+
create_table "books", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
169
|
+
t.string "title", <%= i limit(255) + {null: false} %>
|
170
|
+
t.integer "author_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
173
171
|
end
|
174
172
|
|
175
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
173
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
176
174
|
EOS
|
177
175
|
}
|
178
176
|
|
@@ -184,10 +182,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
184
182
|
|
185
183
|
create_table "books", force: :cascade do |t|
|
186
184
|
t.string "title", null: false
|
187
|
-
t.integer "author_id", <%=
|
185
|
+
t.integer "author_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
188
186
|
end
|
189
187
|
|
190
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
188
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
191
189
|
|
192
190
|
execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
|
193
191
|
c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '<%= @test_schema %>' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
|
@@ -233,17 +231,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
233
231
|
|
234
232
|
context 'when not execute (noop)' do
|
235
233
|
let(:dsl) {
|
236
|
-
<<-EOS
|
234
|
+
erbh(<<-EOS, template_variables)
|
237
235
|
create_table "authors", force: :cascade do |t|
|
238
|
-
t.string "name", limit
|
236
|
+
t.string "name", <%= i limit(255) + {null: false} %>
|
239
237
|
end
|
240
238
|
|
241
239
|
create_table "books", force: :cascade do |t|
|
242
|
-
t.string "title", limit
|
243
|
-
t.integer "author_id", limit
|
240
|
+
t.string "title", <%= i limit(255) + {null: false} %>
|
241
|
+
t.integer "author_id", <%= i limit(4) + {null: false} %>
|
244
242
|
end
|
245
243
|
|
246
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
244
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
247
245
|
add_foreign_key "books", "authors", name: "fk_author"
|
248
246
|
EOS
|
249
247
|
}
|
@@ -256,10 +254,10 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
256
254
|
|
257
255
|
create_table "books", force: :cascade do |t|
|
258
256
|
t.string "title", null: false
|
259
|
-
t.integer "author_id", limit
|
257
|
+
t.integer "author_id", <%= i limit(4) + {null: false} %>
|
260
258
|
end
|
261
259
|
|
262
|
-
add_index "books", ["author_id"], name: "idx_author_id", using: :btree
|
260
|
+
<%= add_index "books", ["author_id"], name: "idx_author_id", using: :btree %>
|
263
261
|
|
264
262
|
execute("ALTER TABLE books ADD CONSTRAINT fk_author FOREIGN KEY (author_id) REFERENCES authors (id)") do |c|
|
265
263
|
c.raw_connection.query("SELECT 1 FROM information_schema.key_column_usage WHERE TABLE_SCHEMA = '<%= @test_schema %>' AND CONSTRAINT_NAME = 'fk_author' LIMIT 1").each.length.zero?
|
@@ -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 create 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,29 +50,71 @@ 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) {
|
85
|
-
|
86
|
-
|
87
|
-
|
73
|
+
erbh(<<-EOS)
|
74
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
75
|
+
t.string "dept_name", limit: 40, null: false
|
76
|
+
end
|
77
|
+
|
78
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
79
|
+
|
80
|
+
create_table "dept_emp", id: false, force: :cascade do |t|
|
81
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
82
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
83
|
+
t.date "from_date", null: false
|
84
|
+
t.date "to_date", null: false
|
85
|
+
end
|
86
|
+
|
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
|
+
create_table "dept_manager", id: false, force: :cascade do |t|
|
91
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
92
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
93
|
+
t.date "from_date", null: false
|
94
|
+
t.date "to_date", null: false
|
95
|
+
end
|
96
|
+
|
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
|
+
create_table "salaries", id: false, force: :cascade do |t|
|
101
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
102
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
103
|
+
t.date "from_date", null: false
|
104
|
+
t.date "to_date", null: false
|
105
|
+
end
|
106
|
+
|
107
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
108
|
+
|
109
|
+
create_table "titles", id: false, force: :cascade do |t|
|
110
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
111
|
+
t.string "title", limit: 50, null: false
|
112
|
+
t.date "from_date", null: false
|
113
|
+
t.date "to_date"
|
114
|
+
end
|
115
|
+
|
116
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
117
|
+
EOS
|
88
118
|
}
|
89
119
|
|
90
120
|
let(:expected_dsl) { dsl }
|
@@ -14,46 +14,46 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
14
14
|
context 'when marge table' do
|
15
15
|
let(:actual_dsl) {
|
16
16
|
erbh(<<-EOS, template_variables)
|
17
|
-
create_table "clubs", <%= {force: :cascade}
|
18
|
-
t.string "name", limit
|
17
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
18
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
19
19
|
end
|
20
20
|
|
21
|
-
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
21
|
+
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
22
22
|
|
23
|
-
create_table "departments", primary_key: "dept_no", <%= {force: :cascade}
|
23
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
24
24
|
t.string "dept_name", limit: 40, null: false
|
25
25
|
end
|
26
26
|
|
27
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
27
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
28
28
|
|
29
29
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
30
|
-
t.integer "emp_no", limit
|
31
|
-
t.string "dept_no", limit
|
30
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
31
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
32
32
|
t.date "from_date", null: false
|
33
33
|
t.date "to_date", null: false
|
34
34
|
end
|
35
35
|
|
36
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
37
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
36
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
37
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
38
38
|
|
39
39
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
40
|
-
t.string "dept_no", limit
|
41
|
-
t.integer "emp_no", limit
|
40
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
41
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
42
42
|
t.date "from_date", null: false
|
43
43
|
t.date "to_date", null: false
|
44
44
|
end
|
45
45
|
|
46
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
47
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
46
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
47
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
48
48
|
|
49
|
-
create_table "employee_clubs", <%= {force: :cascade}
|
50
|
-
t.integer "emp_no", <%=
|
51
|
-
t.integer "club_id", <%=
|
49
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
50
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
51
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
52
52
|
end
|
53
53
|
|
54
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
54
|
+
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
55
55
|
|
56
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
56
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
57
57
|
t.date "birth_date", null: false
|
58
58
|
t.string "first_name", limit: 14, null: false
|
59
59
|
t.string "last_name", limit: 16, null: false
|
@@ -62,71 +62,71 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
create_table "salaries", id: false, force: :cascade do |t|
|
65
|
-
t.integer "emp_no", limit
|
66
|
-
t.integer "salary", limit
|
65
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
66
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
67
67
|
t.date "from_date", null: false
|
68
68
|
t.date "to_date", null: false
|
69
69
|
end
|
70
70
|
|
71
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
71
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
72
72
|
|
73
73
|
create_table "titles", id: false, force: :cascade do |t|
|
74
|
-
t.integer "emp_no", limit
|
74
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
75
75
|
t.string "title", limit: 50, null: false
|
76
76
|
t.date "from_date", null: false
|
77
77
|
t.date "to_date"
|
78
78
|
end
|
79
79
|
|
80
|
-
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
80
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
81
81
|
EOS
|
82
82
|
}
|
83
83
|
|
84
84
|
let(:expected_dsl) {
|
85
85
|
erbh(<<-EOS, template_variables)
|
86
|
-
create_table "clubs", <%= {force: :cascade}
|
87
|
-
t.string "name", limit
|
86
|
+
create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
87
|
+
t.string "name", <%= i limit(255) + {default: "", null: false} %>
|
88
88
|
end
|
89
89
|
|
90
|
-
add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree
|
90
|
+
<%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
|
91
91
|
|
92
|
-
create_table "clubs2", <%= {force: :cascade}
|
93
|
-
t.string "name2", limit
|
92
|
+
create_table "clubs2", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
93
|
+
t.string "name2", <%= i limit(255) + {default: "", null: false} %>
|
94
94
|
end
|
95
95
|
|
96
|
-
create_table "departments", primary_key: "dept_no", <%= {force: :cascade}
|
96
|
+
create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
97
97
|
t.string "dept_name", limit: 40, null: false
|
98
98
|
end
|
99
99
|
|
100
|
-
add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
|
100
|
+
<%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
|
101
101
|
|
102
102
|
create_table "dept_emp", id: false, force: :cascade do |t|
|
103
|
-
t.integer "emp_no", limit
|
104
|
-
t.string "dept_no", limit
|
103
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
104
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
105
105
|
t.date "from_date", null: false
|
106
106
|
t.date "to_date", null: false
|
107
107
|
end
|
108
108
|
|
109
|
-
add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
|
110
|
-
add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
|
109
|
+
<%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
|
110
|
+
<%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
|
111
111
|
|
112
112
|
create_table "dept_manager", id: false, force: :cascade do |t|
|
113
|
-
t.string "dept_no", limit
|
114
|
-
t.integer "emp_no", limit
|
113
|
+
t.string "dept_no", <%= i limit(4) + {null: false} %>
|
114
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
115
115
|
t.date "from_date", null: false
|
116
116
|
t.date "to_date", null: false
|
117
117
|
end
|
118
118
|
|
119
|
-
add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
|
120
|
-
add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
|
119
|
+
<%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
|
120
|
+
<%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
|
121
121
|
|
122
|
-
create_table "employee_clubs", <%= {force: :cascade}
|
123
|
-
t.integer "emp_no", <%=
|
124
|
-
t.integer "club_id", <%=
|
122
|
+
create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
123
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
|
124
|
+
t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
|
125
125
|
end
|
126
126
|
|
127
|
-
add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
|
127
|
+
<%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
|
128
128
|
|
129
|
-
create_table "employees", primary_key: "emp_no", <%= {force: :cascade}
|
129
|
+
create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
|
130
130
|
t.date "birth_date", null: false
|
131
131
|
t.string "first_name", limit: 14, null: false
|
132
132
|
t.string "last_name", limit: 16, null: false
|
@@ -135,22 +135,22 @@ describe 'Ridgepole::Client#diff -> migrate' do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
create_table "salaries", id: false, force: :cascade do |t|
|
138
|
-
t.integer "emp_no", limit
|
139
|
-
t.integer "salary", limit
|
138
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
139
|
+
t.integer "salary", <%= i limit(4) + {null: false} %>
|
140
140
|
t.date "from_date", null: false
|
141
141
|
t.date "to_date", null: false
|
142
142
|
end
|
143
143
|
|
144
|
-
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
144
|
+
<%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
|
145
145
|
|
146
146
|
create_table "titles", id: false, force: :cascade do |t|
|
147
|
-
t.integer "emp_no", limit
|
147
|
+
t.integer "emp_no", <%= i limit(4) + {null: false} %>
|
148
148
|
t.string "title", limit: 50, null: false
|
149
149
|
t.date "from_date", null: false
|
150
150
|
t.date "to_date"
|
151
151
|
end
|
152
152
|
|
153
|
-
add_index "titles", ["emp_no"], name: "emp_no", using: :btree
|
153
|
+
<%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
|
154
154
|
EOS
|
155
155
|
}
|
156
156
|
|