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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -0
  4. data/README.md +7 -5
  5. data/bin/ridgepole +14 -14
  6. data/lib/ridgepole/cli/config.rb +1 -1
  7. data/lib/ridgepole/client.rb +0 -4
  8. data/lib/ridgepole/delta.rb +15 -9
  9. data/lib/ridgepole/diff.rb +13 -9
  10. data/lib/ridgepole/dsl_parser/context.rb +2 -6
  11. data/lib/ridgepole/version.rb +1 -1
  12. data/ridgepole.gemspec +3 -1
  13. data/spec/erb_helper.rb +0 -39
  14. data/spec/hide_pending_formatter.rb +6 -0
  15. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +9 -9
  16. data/spec/mysql/bigint_pk/int_pk_spec.rb +9 -9
  17. data/spec/mysql/cli/ridgepole_spec.rb +2 -2
  18. data/spec/mysql/collation/collation_spec.rb +28 -28
  19. data/spec/mysql/comment/comment_spec.rb +36 -36
  20. data/spec/mysql/default_lambda/default_lambda_spec.rb +1 -1
  21. data/spec/mysql/diff/diff2_spec.rb +41 -41
  22. data/spec/mysql/diff/diff_spec.rb +41 -41
  23. data/spec/mysql/dump/dump_class_method_spec.rb +26 -33
  24. data/spec/mysql/dump/dump_some_tables_spec.rb +16 -18
  25. data/spec/mysql/dump/dump_spec.rb +27 -34
  26. data/spec/mysql/dump/dump_without_table_options_spec.rb +5 -5
  27. data/spec/mysql/fk/migrate_change_fk_spec.rb +76 -23
  28. data/spec/mysql/fk/migrate_create_fk_spec.rb +70 -50
  29. data/spec/mysql/fk/migrate_drop_fk_spec.rb +131 -32
  30. data/spec/mysql/migrate/check_orphan_index_spec.rb +19 -19
  31. data/spec/mysql/migrate/migrate_add_column2_spec.rb +33 -45
  32. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +47 -47
  33. data/spec/mysql/migrate/migrate_add_column_spec.rb +75 -89
  34. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +72 -86
  35. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +72 -86
  36. data/spec/mysql/migrate/migrate_change_column2_spec.rb +27 -32
  37. data/spec/mysql/migrate/migrate_change_column3_spec.rb +78 -78
  38. data/spec/mysql/migrate/migrate_change_column4_spec.rb +24 -24
  39. data/spec/mysql/migrate/migrate_change_column5_spec.rb +42 -42
  40. data/spec/mysql/migrate/migrate_change_column6_spec.rb +60 -60
  41. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +47 -47
  42. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +16 -16
  43. data/spec/mysql/migrate/migrate_change_column_spec.rb +65 -79
  44. data/spec/mysql/migrate/migrate_change_index2_spec.rb +22 -27
  45. data/spec/mysql/migrate/migrate_change_index3_spec.rb +52 -62
  46. data/spec/mysql/migrate/migrate_change_index4_spec.rb +32 -38
  47. data/spec/mysql/migrate/migrate_change_index5_spec.rb +24 -28
  48. data/spec/mysql/migrate/migrate_change_index6_spec.rb +105 -119
  49. data/spec/mysql/migrate/migrate_change_index7_spec.rb +27 -30
  50. data/spec/mysql/migrate/migrate_change_index_spec.rb +99 -120
  51. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +14 -14
  52. data/spec/mysql/migrate/migrate_create_index2_spec.rb +101 -112
  53. data/spec/mysql/migrate/migrate_create_index_spec.rb +55 -66
  54. data/spec/mysql/migrate/migrate_create_table_spec.rb +68 -91
  55. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +1 -1
  56. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +58 -70
  57. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +62 -76
  58. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +58 -72
  59. data/spec/mysql/migrate/migrate_drop_column_spec.rb +63 -77
  60. data/spec/mysql/migrate/migrate_drop_index_spec.rb +55 -66
  61. data/spec/mysql/migrate/migrate_drop_table_spec.rb +51 -63
  62. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +3 -3
  63. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +12 -12
  64. data/spec/mysql/migrate/migrate_empty_spec.rb +35 -42
  65. data/spec/mysql/migrate/migrate_execute_spec.rb +16 -24
  66. data/spec/mysql/migrate/migrate_log_file_spec.rb +58 -70
  67. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +75 -99
  68. data/spec/mysql/migrate/migrate_noop_spec.rb +38 -38
  69. data/spec/mysql/migrate/migrate_rename_column_spec.rb +74 -88
  70. data/spec/mysql/migrate/migrate_rename_table_spec.rb +100 -97
  71. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +18 -18
  72. data/spec/mysql/migrate/migrate_same_spec.rb +29 -37
  73. data/spec/mysql/migrate/migrate_script_error_spec.rb +19 -19
  74. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +148 -0
  75. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +70 -84
  76. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +70 -84
  77. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +87 -87
  78. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +61 -75
  79. data/spec/mysql/migrate/migrate_with_tables_spec.rb +41 -41
  80. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +10 -10
  81. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +67 -78
  82. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +67 -78
  83. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +9 -9
  84. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
  85. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +35 -67
  86. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
  87. data/spec/postgresql/diff/diff_spec.rb +37 -37
  88. data/spec/postgresql/dump/dump_spec.rb +27 -34
  89. data/spec/postgresql/fk/migrate_change_fk_spec.rb +76 -23
  90. data/spec/postgresql/fk/migrate_create_fk_spec.rb +73 -54
  91. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +131 -32
  92. data/spec/postgresql/migrate/migrate_add_column_spec.rb +63 -75
  93. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
  94. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +7 -7
  95. data/spec/postgresql/migrate/migrate_change_column_spec.rb +53 -65
  96. data/spec/postgresql/migrate/migrate_change_index_spec.rb +54 -68
  97. data/spec/postgresql/migrate/migrate_create_table_spec.rb +56 -77
  98. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +46 -60
  99. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +41 -55
  100. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
  101. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +51 -62
  102. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +48 -60
  103. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +6 -6
  104. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +54 -68
  105. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +62 -78
  106. data/spec/postgresql/migrate/migrate_same_spec.rb +27 -34
  107. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +21 -24
  108. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +35 -66
  109. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +28 -34
  110. data/spec/spec_helper.rb +1 -1
  111. metadata +9 -8
  112. data/ridgepole.iml +0 -9
  113. data/spec/string_ext.rb +0 -40
@@ -1,154 +1,130 @@
1
1
  describe 'Ridgepole::Client#diff -> migrate' do
2
- let(:template_variables) {
3
- opts = {
4
- unsigned: {}
5
- }
6
-
7
- opts[:unsigned] = {unsigned: true}
8
-
9
- opts
10
- }
11
-
12
2
  context 'when marge table' do
13
3
  let(:actual_dsl) {
14
- erbh(<<-EOS, template_variables)
15
- create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
16
- t.string "name", <%= i limit(255) + {default: "", null: false} %>
4
+ erbh(<<-EOS)
5
+ create_table "clubs", force: :cascade do |t|
6
+ t.string "name", default: "", null: false
7
+ t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
17
8
  end
18
9
 
19
- <%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
20
-
21
- 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|
22
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) %>
23
13
  end
24
14
 
25
- <%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
26
-
27
15
  create_table "dept_emp", id: false, force: :cascade do |t|
28
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
29
- t.string "dept_no", <%= i limit(4) + {null: false} %>
30
- t.date "from_date", null: false
31
- t.date "to_date", null: false
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) %>
32
22
  end
33
23
 
34
- <%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
35
- <%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
36
-
37
24
  create_table "dept_manager", id: false, force: :cascade do |t|
38
- t.string "dept_no", <%= i limit(4) + {null: false} %>
39
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
40
- t.date "from_date", null: false
41
- t.date "to_date", null: false
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) %>
42
31
  end
43
32
 
44
- <%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
45
- <%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
46
-
47
- create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
48
- t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
49
- 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) %>
50
37
  end
51
38
 
52
- <%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
53
-
54
- create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
55
- 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
56
41
  t.string "first_name", limit: 14, null: false
57
- t.string "last_name", limit: 16, null: false
58
- t.string "gender", limit: 1, null: false
59
- t.date "hire_date", null: false
42
+ t.string "last_name", limit: 16, null: false
43
+ t.string "gender", limit: 1, null: false
44
+ t.date "hire_date", null: false
60
45
  end
61
46
 
62
47
  create_table "salaries", id: false, force: :cascade do |t|
63
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
64
- t.integer "salary", <%= i limit(4) + {null: false} %>
65
- t.date "from_date", null: false
66
- t.date "to_date", null: false
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) %>
67
53
  end
68
54
 
69
- <%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
70
-
71
55
  create_table "titles", id: false, force: :cascade do |t|
72
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
73
- t.string "title", limit: 50, null: false
74
- t.date "from_date", null: false
56
+ t.integer "emp_no", null: false
57
+ t.string "title", limit: 50, null: false
58
+ t.date "from_date", null: false
75
59
  t.date "to_date"
60
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
76
61
  end
77
-
78
- <%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
79
62
  EOS
80
63
  }
81
64
 
82
65
  let(:expected_dsl) {
83
- erbh(<<-EOS, template_variables)
84
- create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
85
- t.string "name", <%= i limit(255) + {default: "", null: false} %>
66
+ erbh(<<-EOS)
67
+ create_table "clubs", force: :cascade do |t|
68
+ t.string "name", default: "", null: false
69
+ t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
86
70
  end
87
71
 
88
- <%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
89
-
90
- create_table "clubs2", <%= i unsigned(true) + {force: :cascade} %> do |t|
91
- t.string "name2", <%= i limit(255) + {default: "", null: false} %>
72
+ create_table "clubs2", force: :cascade do |t|
73
+ t.string "name2", default: "", null: false
92
74
  end
93
75
 
94
- create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
76
+ create_table "departments", primary_key: "dept_no", force: :cascade do |t|
95
77
  t.string "dept_name", limit: 40, null: false
78
+ t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
96
79
  end
97
80
 
98
- <%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
99
-
100
81
  create_table "dept_emp", id: false, force: :cascade do |t|
101
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
102
- t.string "dept_no", <%= i limit(4) + {null: false} %>
103
- t.date "from_date", null: false
104
- t.date "to_date", null: false
82
+ t.integer "emp_no", null: false
83
+ t.string "dept_no", null: false
84
+ t.date "from_date", null: false
85
+ t.date "to_date", null: false
86
+ t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
87
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
105
88
  end
106
89
 
107
- <%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
108
- <%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
109
-
110
90
  create_table "dept_manager", id: false, force: :cascade do |t|
111
- t.string "dept_no", <%= i limit(4) + {null: false} %>
112
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
113
- t.date "from_date", null: false
114
- t.date "to_date", null: false
91
+ t.string "dept_no", null: false
92
+ t.integer "emp_no", null: false
93
+ t.date "from_date", null: false
94
+ t.date "to_date", null: false
95
+ t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
96
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
115
97
  end
116
98
 
117
- <%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
118
- <%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
119
-
120
- create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
121
- t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
122
- t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
99
+ create_table "employee_clubs", force: :cascade do |t|
100
+ t.integer "emp_no", null: false
101
+ t.integer "club_id", null: false
102
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
123
103
  end
124
104
 
125
- <%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
126
-
127
- create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
128
- t.date "birth_date", null: false
105
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
106
+ t.date "birth_date", null: false
129
107
  t.string "first_name", limit: 14, null: false
130
- t.string "last_name", limit: 16, null: false
131
- t.string "gender", limit: 1, null: false
132
- t.date "hire_date", null: false
108
+ t.string "last_name", limit: 16, null: false
109
+ t.string "gender", limit: 1, null: false
110
+ t.date "hire_date", null: false
133
111
  end
134
112
 
135
113
  create_table "salaries", id: false, force: :cascade do |t|
136
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
137
- t.integer "salary", <%= i limit(4) + {null: false} %>
138
- t.date "from_date", null: false
139
- t.date "to_date", null: false
114
+ t.integer "emp_no", null: false
115
+ t.integer "salary", null: false
116
+ t.date "from_date", null: false
117
+ t.date "to_date", null: false
118
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
140
119
  end
141
120
 
142
- <%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
143
-
144
121
  create_table "titles", id: false, force: :cascade do |t|
145
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
146
- t.string "title", limit: 50, null: false
147
- t.date "from_date", null: false
122
+ t.integer "emp_no", null: false
123
+ t.string "title", limit: 50, null: false
124
+ t.date "from_date", null: false
148
125
  t.date "to_date"
126
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
149
127
  end
150
-
151
- <%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
152
128
  EOS
153
129
  }
154
130
 
@@ -156,7 +132,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
156
132
  subject { client(merge: true) }
157
133
 
158
134
  it {
159
- delta = subject.diff(expected_dsl.delete_create_table('clubs'))
135
+ delta = subject.diff(expected_dsl.gsub(/create_table "clubs".+\n\s*t\..+\n\s*end/, ""))
160
136
  expect(delta.differ?).to be_truthy
161
137
  expect(subject.dump).to match_fuzzy actual_dsl
162
138
  delta.migrate
@@ -16,53 +16,53 @@ describe 'Ridgepole::Client#diff -> migrate' do
16
16
  add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
17
17
 
18
18
  create_table "dept_emp", id: false, force: :cascade do |t|
19
- t.integer "emp_no", null: false
20
- t.string "dept_no", limit: 4, null: false
21
- t.date "from_date", null: false
22
- t.date "to_date", null: false
19
+ t.integer "emp_no", null: false
20
+ t.string "dept_no", limit: 4, null: false
21
+ t.date "from_date", null: false
22
+ t.date "to_date", null: false
23
23
  end
24
24
 
25
25
  add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
26
26
  add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
27
27
 
28
28
  create_table "dept_manager", id: false, force: :cascade do |t|
29
- t.string "dept_no", limit: 4, null: false
30
- t.integer "emp_no", null: false
31
- t.date "from_date", null: false
32
- t.date "to_date", null: false
29
+ t.string "dept_no", limit: 4, null: false
30
+ t.integer "emp_no", null: false
31
+ t.date "from_date", null: false
32
+ t.date "to_date", null: false
33
33
  end
34
34
 
35
35
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
36
36
  add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
37
37
 
38
38
  create_table "employee_clubs", force: :cascade do |t|
39
- t.integer "emp_no", null: false, unsigned: true
39
+ t.integer "emp_no", null: false, unsigned: true
40
40
  t.integer "club_id", null: false, unsigned: true
41
41
  end
42
42
 
43
43
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
44
44
 
45
45
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
46
- t.date "birth_date", null: false
46
+ t.date "birth_date", null: false
47
47
  t.string "first_name", limit: 14, null: false
48
- t.string "last_name", limit: 16, null: false
49
- t.string "gender", limit: 1, null: false
50
- t.date "hire_date", null: false
48
+ t.string "last_name", limit: 16, null: false
49
+ t.string "gender", limit: 1, null: false
50
+ t.date "hire_date", null: false
51
51
  end
52
52
 
53
53
  create_table "salaries", id: false, force: :cascade do |t|
54
- t.integer "emp_no", null: false
55
- t.integer "salary", null: false
54
+ t.integer "emp_no", null: false
55
+ t.integer "salary", null: false
56
56
  t.date "from_date", null: false
57
- t.date "to_date", null: false
57
+ t.date "to_date", null: false
58
58
  end
59
59
 
60
60
  add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
61
61
 
62
62
  create_table "titles", id: false, force: :cascade do |t|
63
- t.integer "emp_no", null: false
64
- t.string "title", limit: 50, null: false
65
- t.date "from_date", null: false
63
+ t.integer "emp_no", null: false
64
+ t.string "title", limit: 50, null: false
65
+ t.date "from_date", null: false
66
66
  t.date "to_date"
67
67
  end
68
68
 
@@ -145,53 +145,53 @@ describe 'Ridgepole::Client#diff -> migrate' do
145
145
  add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree
146
146
 
147
147
  create_table "dept_emp", id: false, force: :cascade do |t|
148
- t.integer "emp_no", null: false
149
- t.string "dept_no", limit: 4, null: false
150
- t.date "from_date", null: false
151
- t.date "to_date", null: false
148
+ t.integer "emp_no", null: false
149
+ t.string "dept_no", limit: 4, null: false
150
+ t.date "from_date", null: false
151
+ t.date "to_date", null: false
152
152
  end
153
153
 
154
154
  add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree
155
155
  add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree
156
156
 
157
157
  create_table "dept_manager", id: false, force: :cascade do |t|
158
- t.string "dept_no", limit: 4, null: false
159
- t.integer "emp_no", limit: 4, null: false
160
- t.date "from_date", null: false
161
- t.date "to_date", null: false
158
+ t.string "dept_no", limit: 4, null: false
159
+ t.integer "emp_no", limit: 4, null: false
160
+ t.date "from_date", null: false
161
+ t.date "to_date", null: false
162
162
  end
163
163
 
164
164
  add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree
165
165
  add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree
166
166
 
167
167
  create_table "employee_clubs", force: :cascade do |t|
168
- t.integer "emp_no", null: false, unsigned: true
168
+ t.integer "emp_no", null: false, unsigned: true
169
169
  t.integer "club_id", null: false, unsigned: true
170
170
  end
171
171
 
172
172
  add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree
173
173
 
174
174
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
175
- t.date "birth_date", null: false
175
+ t.date "birth_date", null: false
176
176
  t.string "first_name", limit: 14, null: false
177
- t.string "last_name", limit: 16, null: false
178
- t.string "gender", limit: 1, null: false
179
- t.date "hire_date", null: false
177
+ t.string "last_name", limit: 16, null: false
178
+ t.string "gender", limit: 1, null: false
179
+ t.date "hire_date", null: false
180
180
  end
181
181
 
182
182
  create_table "salaries", id: false, force: :cascade do |t|
183
- t.integer "emp_no", null: false
184
- t.integer "salary", null: false
183
+ t.integer "emp_no", null: false
184
+ t.integer "salary", null: false
185
185
  t.date "from_date", null: false
186
- t.date "to_date", null: false
186
+ t.date "to_date", null: false
187
187
  end
188
188
 
189
189
  add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
190
190
 
191
191
  create_table "titles", id: false, force: :cascade do |t|
192
- t.integer "emp_no", null: false
193
- t.string "title", limit: 50, null: false
194
- t.date "from_date", null: false
192
+ t.integer "emp_no", null: false
193
+ t.string "title", limit: 50, null: false
194
+ t.date "from_date", null: false
195
195
  t.date "to_date"
196
196
  end
197
197
 
@@ -2,139 +2,125 @@ describe 'Ridgepole::Client#diff -> migrate' do
2
2
  context 'when rename column' do
3
3
  let(:actual_dsl) {
4
4
  erbh(<<-EOS)
5
- create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
6
- t.string "name", <%= i limit(255) + {default: "", null: false} %>
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
- <%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
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", <%= i limit(4) + {null: false} %>
19
- t.string "dept_no", <%= i limit(4) + {null: false} %>
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
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", <%= i limit(4) + {null: false} %>
29
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
30
- t.date "from_date", null: false
31
- t.date "to_date", null: false
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
- 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) %>
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
- <%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
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", limit: 16, null: false
48
- t.string "gender", limit: 1, null: false
49
- t.date "hire_date", null: false
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", <%= i limit(4) + {null: false} %>
54
- t.integer "salary", <%= i limit(4) + {null: false} %>
55
- t.date "from_date", null: false
56
- t.date "to_date", null: false
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", <%= i limit(4) + {null: false} %>
63
- t.string "title", limit: 50, null: false
64
- t.date "from_date", null: false
56
+ t.integer "emp_no", null: false
57
+ t.string "title", limit: 50, null: false
58
+ t.date "from_date", null: false
65
59
  t.date "to_date"
60
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
66
61
  end
67
-
68
- <%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
69
62
  EOS
70
63
  }
71
64
 
72
65
  let(:expected_dsl) {
73
66
  erbh(<<-EOS)
74
- create_table "clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
75
- t.string "name", <%= i limit(255) + {default: "", null: false} %>
67
+ create_table "clubs", force: :cascade do |t|
68
+ t.string "name", default: "", null: false
69
+ t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
76
70
  end
77
71
 
78
- <%= add_index "clubs", ["name"], name: "idx_name", unique: true, using: :btree %>
79
-
80
- create_table "departments", primary_key: "dept_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
72
+ create_table "departments", primary_key: "dept_no", force: :cascade do |t|
81
73
  t.string "dept_name", limit: 40, null: false
74
+ t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
82
75
  end
83
76
 
84
- <%= add_index "departments", ["dept_name"], name: "dept_name", unique: true, using: :btree %>
85
-
86
77
  create_table "dept_emp", id: false, force: :cascade do |t|
87
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
88
- t.string "dept_no", <%= i limit(4) + {null: false} %>
89
- t.date "from_date2", null: false, renamed_from: 'from_date'
90
- t.date "to_date", null: false
78
+ t.integer "emp_no", null: false
79
+ t.string "dept_no", null: false
80
+ t.date "from_date2", null: false, renamed_from: 'from_date'
81
+ t.date "to_date", null: false
82
+ t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
83
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
91
84
  end
92
85
 
93
- <%= add_index "dept_emp", ["dept_no"], name: "dept_no", using: :btree %>
94
- <%= add_index "dept_emp", ["emp_no"], name: "emp_no", using: :btree %>
95
-
96
86
  create_table "dept_manager", id: false, force: :cascade do |t|
97
- t.string "dept_no", <%= i limit(4) + {null: false} %>
98
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
99
- t.date "from_date", null: false
100
- t.date "to_date2", null: false, renamed_from: 'to_date'
87
+ t.string "dept_no", null: false
88
+ t.integer "emp_no", null: false
89
+ t.date "from_date", null: false
90
+ t.date "to_date2", null: false, renamed_from: 'to_date'
91
+ t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
92
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
101
93
  end
102
94
 
103
- <%= add_index "dept_manager", ["dept_no"], name: "dept_no", using: :btree %>
104
- <%= add_index "dept_manager", ["emp_no"], name: "emp_no", using: :btree %>
105
-
106
- create_table "employee_clubs", <%= i unsigned(true) + {force: :cascade} %> do |t|
107
- t.integer "emp_no", <%= i limit(4) + {null: false} + unsigned(true) %>
108
- t.integer "club_id", <%= i limit(4) + {null: false} + unsigned(true) %>
95
+ create_table "employee_clubs", force: :cascade do |t|
96
+ t.integer "emp_no", null: false
97
+ t.integer "club_id", null: false
98
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
109
99
  end
110
100
 
111
- <%= add_index "employee_clubs", ["emp_no", "club_id"], name: "idx_emp_no_club_id", using: :btree %>
112
-
113
- create_table "employees", primary_key: "emp_no", <%= i unsigned(true) + {force: :cascade} %> do |t|
114
- t.date "birth_date", null: false
101
+ create_table "employees", primary_key: "emp_no", force: :cascade do |t|
102
+ t.date "birth_date", null: false
115
103
  t.string "first_name", limit: 14, null: false
116
- t.string "last_name", limit: 16, null: false
117
- t.string "gender2", limit: 1, null: false, renamed_from: 'gender'
118
- t.date "hire_date", null: false
104
+ t.string "last_name", limit: 16, null: false
105
+ t.string "gender2", limit: 1, null: false, renamed_from: 'gender'
106
+ t.date "hire_date", null: false
119
107
  end
120
108
 
121
109
  create_table "salaries", id: false, force: :cascade do |t|
122
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
123
- t.integer "salary", <%= i limit(4) + {null: false} %>
124
- t.date "from_date", null: false
125
- t.date "to_date", null: false
110
+ t.integer "emp_no", null: false
111
+ t.integer "salary", null: false
112
+ t.date "from_date", null: false
113
+ t.date "to_date", null: false
114
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
126
115
  end
127
116
 
128
- <%= add_index "salaries", ["emp_no"], name: "emp_no", using: :btree %>
129
-
130
117
  create_table "titles", id: false, force: :cascade do |t|
131
- t.integer "emp_no", <%= i limit(4) + {null: false} %>
132
- t.string "title", limit: 50, null: false
133
- t.date "from_date", null: false
118
+ t.integer "emp_no", null: false
119
+ t.string "title", limit: 50, null: false
120
+ t.date "from_date", null: false
134
121
  t.date "to_date"
122
+ t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
135
123
  end
136
-
137
- <%= add_index "titles", ["emp_no"], name: "emp_no", using: :btree %>
138
124
  EOS
139
125
  }
140
126
 
@@ -190,11 +176,11 @@ describe 'Ridgepole::Client#diff -> migrate' do
190
176
  let(:dsl) {
191
177
  <<-EOS
192
178
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
193
- t.date "birth_date", null: false
179
+ t.date "birth_date", null: false
194
180
  t.string "first_name", limit: 14, null: false
195
- t.string "last_name", limit: 16, null: false
196
- t.string "gender2", limit: 1, null: false, renamed_from: 'age'
197
- t.date "hire_date", null: false
181
+ t.string "last_name", limit: 16, null: false
182
+ t.string "gender2", limit: 1, null: false, renamed_from: 'age'
183
+ t.date "hire_date", null: false
198
184
  end
199
185
  EOS
200
186
  }