ridgepole 0.8.13 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +27 -20
  3. data/.rubocop.yml +5 -4
  4. data/.simplecov +6 -0
  5. data/Appraisals +4 -5
  6. data/README.md +24 -43
  7. data/bin/ridgepole +13 -3
  8. data/gemfiles/{activerecord_5.0.gemfile → activerecord_6.1.gemfile} +1 -2
  9. data/lib/ridgepole/client.rb +8 -3
  10. data/lib/ridgepole/delta.rb +16 -1
  11. data/lib/ridgepole/diff.rb +50 -31
  12. data/lib/ridgepole/dsl_parser/table_definition.rb +8 -1
  13. data/lib/ridgepole/execute_expander.rb +10 -1
  14. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +9 -1
  15. data/lib/ridgepole/external_sql_executer.rb +12 -1
  16. data/lib/ridgepole/version.rb +1 -1
  17. data/ridgepole.gemspec +4 -3
  18. data/spec/erb_helper.rb +1 -1
  19. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +2 -2
  20. data/spec/mysql/bigint_pk/int_pk_spec.rb +1 -1
  21. data/spec/mysql/cli/ridgepole_spec.rb +35 -1
  22. data/spec/mysql/collation/collation_spec.rb +14 -14
  23. data/spec/mysql/comment/comment_spec.rb +9 -9
  24. data/spec/mysql/diff/diff2_spec.rb +5 -5
  25. data/spec/mysql/diff/diff_spec.rb +3 -3
  26. data/spec/mysql/dump/dump_class_method_spec.rb +13 -13
  27. data/spec/mysql/dump/dump_some_tables_spec.rb +4 -4
  28. data/spec/mysql/dump/dump_spec.rb +13 -13
  29. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +2 -2
  30. data/spec/mysql/dump/dump_without_table_options_spec.rb +2 -2
  31. data/spec/mysql/fk/migrate_change_fk2_spec.rb +2 -2
  32. data/spec/mysql/fk/migrate_change_fk_spec.rb +88 -20
  33. data/spec/mysql/fk/migrate_create_fk_spec.rb +77 -22
  34. data/spec/mysql/fk/migrate_drop_fk_spec.rb +81 -26
  35. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +16 -16
  36. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +6 -6
  37. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +2 -2
  38. data/spec/mysql/migrate/migrate_add_column_spec.rb +18 -18
  39. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +106 -18
  40. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +18 -18
  41. data/spec/mysql/migrate/migrate_change_column2_spec.rb +5 -5
  42. data/spec/mysql/migrate/migrate_change_column3_spec.rb +10 -10
  43. data/spec/mysql/migrate/migrate_change_column5_spec.rb +3 -3
  44. data/spec/mysql/migrate/migrate_change_column6_spec.rb +7 -7
  45. data/spec/mysql/migrate/migrate_change_column8_spec.rb +38 -5
  46. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +2 -14
  47. data/spec/mysql/migrate/migrate_change_column_spec.rb +21 -21
  48. data/spec/mysql/migrate/migrate_change_index2_spec.rb +5 -5
  49. data/spec/mysql/migrate/migrate_change_index3_spec.rb +7 -7
  50. data/spec/mysql/migrate/migrate_change_index4_spec.rb +6 -6
  51. data/spec/mysql/migrate/migrate_change_index5_spec.rb +4 -4
  52. data/spec/mysql/migrate/migrate_change_index6_spec.rb +27 -27
  53. data/spec/mysql/migrate/migrate_change_index7_spec.rb +4 -4
  54. data/spec/mysql/migrate/migrate_change_index8_spec.rb +4 -4
  55. data/spec/mysql/migrate/migrate_change_index_spec.rb +34 -28
  56. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +5 -5
  57. data/spec/mysql/migrate/migrate_create_index2_spec.rb +24 -24
  58. data/spec/mysql/migrate/migrate_create_index_spec.rb +78 -18
  59. data/spec/mysql/migrate/migrate_create_table_spec.rb +16 -16
  60. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +4 -4
  61. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +4 -4
  62. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +16 -16
  63. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +18 -18
  64. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +16 -16
  65. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +1 -1
  66. data/spec/mysql/migrate/migrate_drop_column_spec.rb +18 -18
  67. data/spec/mysql/migrate/migrate_drop_index_spec.rb +15 -15
  68. data/spec/mysql/migrate/migrate_drop_table_spec.rb +16 -16
  69. data/spec/mysql/migrate/migrate_empty_spec.rb +9 -9
  70. data/spec/mysql/migrate/migrate_execute_spec.rb +32 -32
  71. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +4 -4
  72. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +5 -5
  73. data/spec/mysql/migrate/migrate_log_file_spec.rb +16 -16
  74. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +18 -18
  75. data/spec/mysql/migrate/migrate_noop_spec.rb +12 -12
  76. data/spec/mysql/migrate/migrate_primary_key_spec.rb +31 -6
  77. data/spec/mysql/migrate/migrate_rename_column_spec.rb +18 -18
  78. data/spec/mysql/migrate/migrate_rename_table_spec.rb +22 -22
  79. data/spec/mysql/migrate/migrate_same_spec.rb +13 -13
  80. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +2 -2
  81. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +18 -18
  82. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +18 -18
  83. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +18 -18
  84. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +18 -18
  85. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +2 -2
  86. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +6 -6
  87. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +9 -9
  88. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +8 -8
  89. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +5 -5
  90. data/spec/mysql57/json/add_json_column_spec.rb +2 -2
  91. data/spec/mysql57/json/change_json_column_spec.rb +6 -6
  92. data/spec/mysql57/json/drop_json_column_spec.rb +2 -2
  93. data/spec/mysql57/virtual/add_virtual_column_spec.rb +1 -1
  94. data/spec/mysql57/virtual/change_virtual_column_spec.rb +1 -1
  95. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +1 -1
  96. data/spec/postgresql/dump/dump_spec.rb +13 -13
  97. data/spec/postgresql/fk/migrate_change_fk_spec.rb +6 -6
  98. data/spec/postgresql/fk/migrate_create_fk_spec.rb +5 -5
  99. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +8 -8
  100. data/spec/postgresql/migrate/migrate_add_column_spec.rb +16 -16
  101. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +1 -1
  102. data/spec/postgresql/migrate/migrate_change_column_spec.rb +16 -16
  103. data/spec/postgresql/migrate/migrate_change_index_spec.rb +18 -18
  104. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +1 -1
  105. data/spec/postgresql/migrate/migrate_create_table_spec.rb +14 -14
  106. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +18 -18
  107. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +17 -17
  108. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +3 -3
  109. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +15 -15
  110. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +16 -16
  111. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +1 -1
  112. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +1 -1
  113. data/spec/postgresql/migrate/migrate_references_spec.rb +6 -6
  114. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +18 -18
  115. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +20 -20
  116. data/spec/postgresql/migrate/migrate_same_spec.rb +13 -13
  117. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +3 -3
  118. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +4 -4
  119. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +4 -4
  120. data/spec/processing_for_ci.rb +13 -0
  121. data/spec/spec_const.rb +1 -1
  122. data/spec/spec_helper.rb +2 -1
  123. metadata +43 -46
  124. data/lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb +0 -31
  125. data/omnibus-ridgepole/.gitignore +0 -10
  126. data/omnibus-ridgepole/Dockerfile.centos +0 -25
  127. data/omnibus-ridgepole/Dockerfile.ubuntu +0 -21
  128. data/omnibus-ridgepole/Gemfile +0 -24
  129. data/omnibus-ridgepole/README.md +0 -15
  130. data/omnibus-ridgepole/Rakefile +0 -38
  131. data/omnibus-ridgepole/config/projects/ridgepole.rb +0 -27
  132. data/omnibus-ridgepole/config/software/ridgepole.rb +0 -13
  133. data/omnibus-ridgepole/omnibus.rb +0 -54
  134. data/omnibus-ridgepole/package-scripts/ridgepole/postinst +0 -1
  135. data/omnibus-ridgepole/package-scripts/ridgepole/postrm +0 -1
  136. data/spec/mysql/bigint_pk/bigint_pk_spec.rb +0 -47
  137. data/spec/mysql/migrate_/migrate_create_index_with_alter_spec.rb +0 -141
  138. data/spec/mysql/migrate_/migrate_drop_index_with_alter_spec.rb +0 -141
  139. data/spec/processing_for_travis.rb +0 -11
@@ -9,7 +9,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
9
9
  t.integer "salary", null: false
10
10
  t.date "from_date", null: false
11
11
  t.date "to_date", null: false
12
- t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
12
+ t.index ["emp_no", "id"], name: "emp_no"
13
13
  end
14
14
  ERB
15
15
  end
@@ -21,7 +21,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
21
21
  t.integer "salary", null: false
22
22
  t.date "from_date", null: false
23
23
  t.date "to_date", null: false
24
- t.index ["emp_no", "id"], name: "emp_no", unique: false, <%= i cond(5.0, using: :btree) %>
24
+ t.index ["emp_no", "id"], name: "emp_no", unique: false
25
25
  end
26
26
  ERB
27
27
  end
@@ -43,7 +43,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
43
43
  t.integer "salary", null: false
44
44
  t.date "from_date", null: false
45
45
  t.date "to_date", null: false
46
- t.index ["emp_no", "id"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
46
+ t.index ["emp_no", "id"], name: "emp_no"
47
47
  end
48
48
  ERB
49
49
  end
@@ -55,7 +55,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
55
55
  t.integer "salary", null: false
56
56
  t.date "from_date", null: false
57
57
  t.date "to_date", null: false
58
- t.index ["emp_no", "id"], name: "emp_no", unique: true, <%= i cond(5.0, using: :btree) %>
58
+ t.index ["emp_no", "id"], name: "emp_no", unique: true
59
59
  end
60
60
  ERB
61
61
  end
@@ -6,12 +6,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
6
6
  erbh(<<-ERB)
7
7
  create_table "clubs", force: :cascade do |t|
8
8
  t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
9
+ t.index ["name"], name: "idx_name", unique: true
10
10
  end
11
11
 
12
12
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
13
  t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
14
+ t.index ["dept_name"], name: "dept_name", unique: true
15
15
  end
16
16
 
17
17
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
19
19
  t.string "dept_no", null: false
20
20
  t.date "from_date", null: false
21
21
  t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
23
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
22
+ t.index ["dept_no"], name: "dept_no"
23
+ t.index ["emp_no"], name: "emp_no"
24
24
  end
25
25
 
26
26
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -28,14 +28,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
28
28
  t.integer "emp_no", null: false
29
29
  t.date "from_date", null: false
30
30
  t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
32
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
31
+ t.index ["dept_no"], name: "dept_no"
32
+ t.index ["emp_no"], name: "emp_no"
33
33
  end
34
34
 
35
35
  create_table "employee_clubs", force: :cascade do |t|
36
36
  t.integer "emp_no", null: false
37
37
  t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
38
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
39
39
  end
40
40
 
41
41
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
51
51
  t.integer "salary", null: false
52
52
  t.date "from_date", null: false
53
53
  t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
54
+ t.index ["emp_no"], name: "emp_no"
55
55
  end
56
56
 
57
57
  create_table "titles", id: false, force: :cascade do |t|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.string "title", limit: 50, null: false
60
60
  t.date "from_date", null: false
61
61
  t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
62
+ t.index ["emp_no"], name: "emp_no"
63
63
  end
64
64
  ERB
65
65
  end
@@ -68,12 +68,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
68
68
  erbh(<<-ERB)
69
69
  create_table "clubs", force: :cascade do |t|
70
70
  t.string "name", default: "", null: false
71
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
71
+ t.index ["name"], name: "idx_name", unique: true
72
72
  end
73
73
 
74
74
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
75
75
  t.string "dept_name", limit: 40, null: false
76
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
76
+ t.index ["dept_name"], name: "dept_name", unique: true
77
77
  end
78
78
 
79
79
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
81
81
  t.string "dept_no", null: false
82
82
  t.date "from_date", null: false
83
83
  t.date "to_date", null: false
84
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
85
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
84
+ t.index ["dept_no"], name: "dept_no"
85
+ t.index ["from_date"], name: "emp_no"
86
86
  end
87
87
 
88
88
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -90,14 +90,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
90
90
  t.integer "emp_no", null: false
91
91
  t.date "from_date", null: false
92
92
  t.date "to_date", null: false
93
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
94
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
93
+ t.index ["dept_no"], name: "dept_no"
94
+ t.index ["from_date"], name: "emp_no"
95
95
  end
96
96
 
97
97
  create_table "employee_clubs", force: :cascade do |t|
98
98
  t.integer "emp_no", null: false
99
99
  t.integer "club_id", null: false
100
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
100
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
101
101
  end
102
102
 
103
103
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -113,7 +113,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
113
113
  t.integer "salary", null: false
114
114
  t.date "from_date", null: false
115
115
  t.date "to_date", null: false
116
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
116
+ t.index ["from_date"], name: "emp_no"
117
117
  end
118
118
 
119
119
  create_table "titles", id: false, force: :cascade do |t|
@@ -121,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
121
121
  t.string "title", limit: 50, null: false
122
122
  t.date "from_date", null: false
123
123
  t.date "to_date"
124
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
124
+ t.index ["emp_no"], name: "emp_no"
125
125
  end
126
126
  ERB
127
127
  end
@@ -130,12 +130,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
130
130
  erbh(<<-ERB)
131
131
  create_table "clubs", force: :cascade do |t|
132
132
  t.string "name", default: "", null: false
133
- t.index "name", name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
133
+ t.index "name", name: "idx_name", unique: true
134
134
  end
135
135
 
136
136
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
137
137
  t.string "dept_name", limit: 40, null: false
138
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
138
+ t.index ["dept_name"], name: "dept_name", unique: true
139
139
  end
140
140
 
141
141
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -143,8 +143,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
143
143
  t.string "dept_no", null: false
144
144
  t.date "from_date", null: false
145
145
  t.date "to_date", null: false
146
- t.index "dept_no", name: "dept_no", <%= i cond(5.0, using: :btree) %>
147
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
146
+ t.index "dept_no", name: "dept_no"
147
+ t.index ["from_date"], name: "emp_no"
148
148
  end
149
149
 
150
150
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -152,14 +152,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
152
152
  t.integer "emp_no", null: false
153
153
  t.date "from_date", null: false
154
154
  t.date "to_date", null: false
155
- t.index "dept_no", name: "dept_no", <%= i cond(5.0, using: :btree) %>
156
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
155
+ t.index "dept_no", name: "dept_no"
156
+ t.index ["from_date"], name: "emp_no"
157
157
  end
158
158
 
159
159
  create_table "employee_clubs", force: :cascade do |t|
160
160
  t.integer "emp_no", null: false
161
161
  t.integer "club_id", null: false
162
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
162
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
163
163
  end
164
164
 
165
165
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -175,7 +175,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
175
175
  t.integer "salary", null: false
176
176
  t.date "from_date", null: false
177
177
  t.date "to_date", null: false
178
- t.index "from_date", name: "emp_no", <%= i cond(5.0, using: :btree) %>
178
+ t.index "from_date", name: "emp_no"
179
179
  end
180
180
 
181
181
  create_table "titles", id: false, force: :cascade do |t|
@@ -183,7 +183,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
183
183
  t.string "title", limit: 50, null: false
184
184
  t.date "from_date", null: false
185
185
  t.date "to_date"
186
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
186
+ t.index ["emp_no"], name: "emp_no"
187
187
  end
188
188
  ERB
189
189
  end
@@ -10,7 +10,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
10
10
  t.string "last_name", limit: 16, null: false
11
11
  t.string "gender", limit: 1, null: false
12
12
  t.date "hire_date", null: false
13
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
13
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
14
14
  end
15
15
  ERB
16
16
  end
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
23
23
  t.string "last_name", limit: 16, null: false
24
24
  t.string "gender", limit: 1, null: false
25
25
  t.date "hire_date", null: false
26
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>, <%= i cond(5.0, using: :btree) %>
26
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>
27
27
  end
28
28
  ERB
29
29
  end
@@ -59,14 +59,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.string "last_name", limit: 16, null: false
60
60
  t.string "gender", limit: 1, null: false
61
61
  t.date "hire_date", null: false
62
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>, <%= i cond(5.0, using: :btree) %>
62
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ first_name: 10, last_name: 10 }') %>
63
63
  end
64
64
  ERB
65
65
  end
66
66
 
67
67
  let(:actual_dsl_plus_index) do
68
68
  actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
69
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
69
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
70
70
  end
71
71
  ERB
72
72
  end
@@ -10,7 +10,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
10
10
  t.string "last_name", limit: 16, null: false
11
11
  t.string "gender", limit: 1, null: false
12
12
  t.date "hire_date", null: false
13
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
13
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
14
14
  end
15
15
  ERB
16
16
  end
@@ -23,7 +23,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
23
23
  t.string "last_name", limit: 16, null: false
24
24
  t.string "gender", limit: 1, null: false
25
25
  t.date "hire_date", null: false
26
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10, "foo" => nil }') %>, <%= i cond(5.0, using: :btree) %>
26
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10, "foo" => nil }') %>
27
27
  end
28
28
  ERB
29
29
  end
@@ -59,14 +59,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.string "last_name", limit: 16, null: false
60
60
  t.string "gender", limit: 1, null: false
61
61
  t.date "hire_date", null: false
62
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10 }') %>, <%= i cond(5.0, using: :btree) %>
62
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', 10, '{ "first_name" => 10, "last_name" => 10 }') %>
63
63
  end
64
64
  ERB
65
65
  end
66
66
 
67
67
  let(:actual_dsl_plus_index) do
68
68
  actual_dsl.sub(/\bend\b/, erbh(<<-ERB))
69
- t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>, <%= i cond(5.0, using: :btree) %>
69
+ t.index ["first_name", "last_name"], name: "idx_first_name_last_name", length: <%= cond('< 5.2.0.beta2', '{ first_name: 10, last_name: 10 }', 10) %>
70
70
  end
71
71
  ERB
72
72
  end
@@ -6,12 +6,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
6
6
  erbh(<<-ERB)
7
7
  create_table "clubs", force: :cascade do |t|
8
8
  t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
9
+ t.index ["name"], name: "idx_name", unique: true
10
10
  end
11
11
 
12
12
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
13
  t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
14
+ t.index ["dept_name"], name: "dept_name", unique: true
15
15
  end
16
16
 
17
17
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -19,8 +19,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
19
19
  t.string "dept_no", null: false
20
20
  t.date "from_date", null: false
21
21
  t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
23
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
22
+ t.index ["dept_no"], name: "dept_no"
23
+ t.index ["emp_no"], name: "emp_no"
24
24
  end
25
25
 
26
26
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -28,14 +28,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
28
28
  t.integer "emp_no", null: false
29
29
  t.date "from_date", null: false
30
30
  t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
32
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
31
+ t.index ["dept_no"], name: "dept_no"
32
+ t.index ["emp_no"], name: "emp_no"
33
33
  end
34
34
 
35
35
  create_table "employee_clubs", force: :cascade do |t|
36
36
  t.integer "emp_no", null: false
37
37
  t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
38
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
39
39
  end
40
40
 
41
41
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -51,7 +51,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
51
51
  t.integer "salary", null: false
52
52
  t.date "from_date", null: false
53
53
  t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
54
+ t.index ["emp_no"], name: "emp_no"
55
55
  end
56
56
 
57
57
  create_table "titles", id: false, force: :cascade do |t|
@@ -59,7 +59,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
59
59
  t.string "title", limit: 50, null: false
60
60
  t.date "from_date", null: false
61
61
  t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
62
+ t.index ["emp_no"], name: "emp_no"
63
63
  end
64
64
  ERB
65
65
  end
@@ -68,12 +68,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
68
68
  erbh(<<-ERB)
69
69
  create_table "clubs", force: :cascade do |t|
70
70
  t.string "name", default: "", null: false
71
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
71
+ t.index ["name"], name: "idx_name", unique: true
72
72
  end
73
73
 
74
74
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
75
75
  t.string "dept_name", limit: 40, null: false
76
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
76
+ t.index ["dept_name"], name: "dept_name", unique: true
77
77
  end
78
78
 
79
79
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -81,8 +81,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
81
81
  t.string "dept_no", null: false
82
82
  t.date "from_date", null: false
83
83
  t.date "to_date", null: false
84
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
85
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
84
+ t.index ["dept_no"], name: "dept_no"
85
+ t.index ["emp_no"], name: "emp_no"
86
86
  end
87
87
 
88
88
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -90,14 +90,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
90
90
  t.integer "emp_no", null: false
91
91
  t.date "from_date", null: false
92
92
  t.date "to_date", null: false
93
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
94
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
93
+ t.index ["dept_no"], name: "dept_no"
94
+ t.index ["emp_no"], name: "emp_no"
95
95
  end
96
96
 
97
97
  create_table "employee_clubs", force: :cascade do |t|
98
98
  t.integer "emp_no", null: false
99
99
  t.integer "club_id", null: false
100
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
100
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
101
101
  end
102
102
 
103
103
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -113,7 +113,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
113
113
  t.integer "salary", null: false
114
114
  t.date "from_date", null: false
115
115
  t.date "to_date", null: false
116
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
116
+ t.index ["emp_no"], name: "emp_no"
117
117
  end
118
118
 
119
119
  create_table "titles", id: false, force: :cascade do |t|
@@ -121,7 +121,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
121
121
  t.string "title", limit: 50, null: false
122
122
  t.date "from_date", null: false
123
123
  t.date "to_date"
124
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
124
+ t.index ["emp_no"], name: "emp_no"
125
125
  end
126
126
  ERB
127
127
  end
@@ -130,12 +130,12 @@ describe 'Ridgepole::Client#diff -> migrate' do
130
130
  erbh(<<-ERB)
131
131
  create_table "clubs", force: :cascade do |t|
132
132
  t.string "name", default: "", null: false
133
- t.index ["name"], name: "idx_name", unique: true, <%= i cond(5.0, using: :btree) %>
133
+ t.index ["name"], name: "idx_name", unique: true
134
134
  end
135
135
 
136
136
  create_table "departments", primary_key: "dept_no", force: :cascade do |t|
137
137
  t.string "dept_name", limit: 40, null: false
138
- t.index ["dept_name"], name: "dept_name", unique: true, <%= i cond(5.0, using: :btree) %>
138
+ t.index ["dept_name"], name: "dept_name", unique: true
139
139
  end
140
140
 
141
141
  create_table "dept_emp", id: false, force: :cascade do |t|
@@ -143,8 +143,8 @@ describe 'Ridgepole::Client#diff -> migrate' do
143
143
  t.string "dept_no", null: false
144
144
  t.date "from_date", null: false
145
145
  t.date "to_date", null: false
146
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
147
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
146
+ t.index ["dept_no"], name: "dept_no"
147
+ t.index ["from_date"], name: "emp_no"
148
148
  end
149
149
 
150
150
  create_table "dept_manager", id: false, force: :cascade do |t|
@@ -152,14 +152,14 @@ describe 'Ridgepole::Client#diff -> migrate' do
152
152
  t.integer "emp_no", null: false
153
153
  t.date "from_date", null: false
154
154
  t.date "to_date", null: false
155
- t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
156
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
155
+ t.index ["dept_no"], name: "dept_no"
156
+ t.index ["from_date"], name: "emp_no"
157
157
  end
158
158
 
159
159
  create_table "employee_clubs", force: :cascade do |t|
160
160
  t.integer "emp_no", null: false
161
161
  t.integer "club_id", null: false
162
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id", <%= i cond(5.0, using: :btree) %>
162
+ t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
163
163
  end
164
164
 
165
165
  create_table "employees", primary_key: "emp_no", force: :cascade do |t|
@@ -175,7 +175,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
175
175
  t.integer "salary", null: false
176
176
  t.date "from_date", null: false
177
177
  t.date "to_date", null: false
178
- t.index ["from_date"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
178
+ t.index ["from_date"], name: "emp_no"
179
179
  end
180
180
 
181
181
  create_table "titles", id: false, force: :cascade do |t|
@@ -183,7 +183,7 @@ describe 'Ridgepole::Client#diff -> migrate' do
183
183
  t.string "title", limit: 50, null: false
184
184
  t.date "from_date", null: false
185
185
  t.date "to_date"
186
- t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
186
+ t.index ["emp_no"], name: "emp_no"
187
187
  end
188
188
  ERB
189
189
  end
@@ -219,11 +219,17 @@ describe 'Ridgepole::Client#diff -> migrate' do
219
219
  t.index(["from_date"], **{:name=>"emp_no", :using=>:btree, :unique=>false})
220
220
  end
221
221
  RUBY
222
+ }
223
+
224
+ # duplicated index checker is deleted in 6.1
225
+ # https://github.com/rails/rails/commit/edb23791d2ee9df89c5a4f24d72940ff8eaec8fc#diff-5a1c923abf3a794dbc133959167f794b2479ea8bcd0b1deda7766c22f05e8dfeL1198
226
+ it 'detects duplicated index', condition: '< 6.1' do
227
+ delta = client(bulk_change: true).diff(expected_dsl)
222
228
 
223
229
  # XXX: Can not add an index of the same name
224
230
  expect do
225
231
  delta.migrate
226
232
  end.to raise_error(/Index name 'emp_no' on table 'dept_emp' already exists/)
227
- }
233
+ end
228
234
  end
229
235
  end