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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -2
  3. data/Appraisals +1 -1
  4. data/README.md +3 -1
  5. data/gemfiles/activerecord_5.0.gemfile +1 -1
  6. data/lib/ridgepole/client.rb +5 -1
  7. data/lib/ridgepole/delta.rb +21 -5
  8. data/lib/ridgepole/diff.rb +13 -2
  9. data/lib/ridgepole/dsl_parser.rb +38 -3
  10. data/lib/ridgepole/dumper.rb +2 -2
  11. data/lib/ridgepole/ext/abstract_mysql_adapter/disable_table_options.rb +21 -0
  12. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +28 -0
  13. data/lib/ridgepole/version.rb +1 -1
  14. data/ridgepole.gemspec +3 -3
  15. data/spec/erb_helper.rb +43 -0
  16. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
  17. data/spec/mysql/collation/collation_spec.rb +39 -37
  18. data/spec/mysql/default_lambda/default_lambda_spec.rb +162 -0
  19. data/spec/mysql/diff/diff2_spec.rb +10 -10
  20. data/spec/mysql/diff/diff_spec.rb +6 -6
  21. data/spec/mysql/dump/dump_class_method_spec.rb +56 -39
  22. data/spec/mysql/dump/dump_some_tables_spec.rb +21 -13
  23. data/spec/mysql/dump/dump_spec.rb +49 -36
  24. data/spec/mysql/dump/dump_without_table_options_spec.rb +27 -9
  25. data/spec/mysql/fk/migrate_change_fk_spec.rb +17 -11
  26. data/spec/mysql/fk/migrate_create_fk_spec.rb +20 -18
  27. data/spec/mysql/fk/migrate_drop_fk_spec.rb +30 -16
  28. data/spec/mysql/migrate/migrate_add_column2_spec.rb +10 -8
  29. data/spec/mysql/migrate/migrate_add_column_spec.rb +49 -61
  30. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +46 -58
  31. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +46 -58
  32. data/spec/mysql/migrate/migrate_change_column2_spec.rb +12 -24
  33. data/spec/mysql/migrate/migrate_change_column3_spec.rb +18 -30
  34. data/spec/mysql/migrate/migrate_change_column5_spec.rb +8 -20
  35. data/spec/mysql/migrate/migrate_change_column6_spec.rb +8 -8
  36. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +20 -20
  37. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +2 -2
  38. data/spec/mysql/migrate/migrate_change_column_spec.rb +54 -68
  39. data/spec/mysql/migrate/migrate_change_index2_spec.rb +14 -14
  40. data/spec/mysql/migrate/migrate_change_index3_spec.rb +28 -28
  41. data/spec/mysql/migrate/migrate_change_index4_spec.rb +26 -38
  42. data/spec/mysql/migrate/migrate_change_index5_spec.rb +20 -32
  43. data/spec/mysql/migrate/migrate_change_index6_spec.rb +63 -75
  44. data/spec/mysql/migrate/migrate_change_index_spec.rb +62 -74
  45. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +8 -20
  46. data/spec/mysql/migrate/migrate_create_index2_spec.rb +98 -53
  47. data/spec/mysql/migrate/migrate_create_index_spec.rb +84 -39
  48. data/spec/mysql/migrate/migrate_create_table_spec.rb +69 -39
  49. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +69 -39
  50. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +47 -59
  51. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +43 -55
  52. data/spec/mysql/migrate/migrate_drop_column_spec.rb +48 -60
  53. data/spec/mysql/migrate/migrate_drop_index_spec.rb +84 -39
  54. data/spec/mysql/migrate/migrate_drop_table_spec.rb +76 -46
  55. data/spec/mysql/migrate/migrate_empty_spec.rb +24 -36
  56. data/spec/mysql/migrate/migrate_execute_spec.rb +30 -32
  57. data/spec/mysql/migrate/migrate_log_file_spec.rb +69 -39
  58. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +48 -48
  59. data/spec/mysql/migrate/migrate_noop_spec.rb +23 -13
  60. data/spec/mysql/migrate/migrate_rename_column_spec.rb +48 -60
  61. data/spec/mysql/migrate/migrate_rename_table_spec.rb +56 -68
  62. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +8 -20
  63. data/spec/mysql/migrate/migrate_same_spec.rb +49 -31
  64. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +48 -60
  65. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +48 -60
  66. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +34 -34
  67. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +84 -39
  68. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +84 -39
  69. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +84 -0
  70. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +14 -8
  71. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +15 -27
  72. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +10 -10
  73. data/spec/postgresql/dump/dump_spec.rb +40 -16
  74. data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
  75. data/spec/postgresql/fk/migrate_create_fk_spec.rb +11 -11
  76. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
  77. data/spec/postgresql/migrate/migrate_add_column_spec.rb +20 -20
  78. data/spec/postgresql/migrate/migrate_change_column_spec.rb +20 -20
  79. data/spec/postgresql/migrate/migrate_change_index_spec.rb +20 -20
  80. data/spec/postgresql/migrate/migrate_create_table_spec.rb +52 -12
  81. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +20 -20
  82. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +18 -18
  83. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +69 -13
  84. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +55 -13
  85. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +3 -1
  86. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +20 -20
  87. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +24 -24
  88. data/spec/postgresql/migrate/migrate_same_spec.rb +40 -16
  89. data/spec/postgresql/ridgepole_test_tables.sql +3 -0
  90. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
  91. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +11 -11
  92. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
  93. data/spec/spec_condition.rb +14 -2
  94. data/spec/spec_helper.rb +12 -11
  95. data/spec/string_ext.rb +2 -0
  96. metadata +16 -9
  97. 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}.unshift(@unsigned).i %> do |t|
21
- t.string "name", limit: 255, null: false
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}.unshift(@unsigned).i %> do |t|
25
- t.string "title", limit: 255, null: false
26
- t.integer "author_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
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", <%= {limit: 4, null: false}.push(@unsigned).i %>
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: 255, null: false
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: 255, null: false
98
- t.integer "author_id", limit: 4, null: false
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: 4, null: false
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}.unshift(@unsigned).i %> do |t|
167
- t.string "name", limit: 255, null: false
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}.unshift(@unsigned).i %> do |t|
171
- t.string "title", limit: 255, null: false
172
- t.integer "author_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
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", <%= {limit: 4, null: false}.push(@unsigned).i %>
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: 255, null: false
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: 255, null: false
243
- t.integer "author_id", limit: 4, null: false
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: 4, null: false
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, template_variables)
17
- create_table "clubs", <%= {force: :cascade}.unshift(@unsigned).i %> do |t|
18
- t.string "name", limit: 255, default: "", null: false
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
31
- t.string "dept_no", limit: 4, null: false
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: 4, null: false
41
- t.integer "emp_no", limit: 4, null: false
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}.unshift(@unsigned).i %> do |t|
50
- t.integer "emp_no", <%= {limit: 4, null: false}.push(@unsigned).i %>
51
- t.integer "club_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
66
- t.integer "salary", limit: 4, null: false
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: 4, null: false
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
- dsl.delete_create_table('clubs')
86
- .delete_create_table('employee_clubs')
87
- .delete_create_table('employees')
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}.unshift(@unsigned).i %> do |t|
18
- t.string "name", limit: 255, default: "", null: false
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
31
- t.string "dept_no", limit: 4, null: false
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: 4, null: false
41
- t.integer "emp_no", limit: 4, null: false
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}.unshift(@unsigned).i %> do |t|
50
- t.integer "emp_no", <%= {limit: 4, null: false}.push(@unsigned).i %>
51
- t.integer "club_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
66
- t.integer "salary", limit: 4, null: false
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: 4, null: false
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}.unshift(@unsigned).i %> do |t|
87
- t.string "name", limit: 255, default: "", null: false
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}.unshift(@unsigned).i %> do |t|
93
- t.string "name2", limit: 255, default: "", null: false
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
104
- t.string "dept_no", limit: 4, null: false
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: 4, null: false
114
- t.integer "emp_no", limit: 4, null: false
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}.unshift(@unsigned).i %> do |t|
123
- t.integer "emp_no", <%= {limit: 4, null: false}.push(@unsigned).i %>
124
- t.integer "club_id", <%= {limit: 4, null: false}.push(@unsigned).i %>
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}.unshift(@unsigned).i %> do |t|
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: 4, null: false
139
- t.integer "salary", limit: 4, null: false
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: 4, null: false
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