ridgepole 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +4 -0
  3. data/CHANGELOG.md +238 -0
  4. data/README.md +12 -142
  5. data/bin/ridgepole +1 -1
  6. data/docker-compose.yml +26 -18
  7. data/gemfiles/activerecord_7.0.gemfile +7 -0
  8. data/lib/ridgepole/delta.rb +1 -1
  9. data/lib/ridgepole/diff.rb +4 -1
  10. data/lib/ridgepole/execute_expander.rb +5 -2
  11. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
  12. data/lib/ridgepole/version.rb +1 -1
  13. data/ridgepole.gemspec +8 -5
  14. metadata +10 -284
  15. data/.github/workflows/test.yml +0 -70
  16. data/.gitignore +0 -25
  17. data/spec/cli_helper.rb +0 -65
  18. data/spec/dsl_parser/context_spec.rb +0 -16
  19. data/spec/erb_helper.rb +0 -26
  20. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  21. data/spec/hide_pending_formatter.rb +0 -9
  22. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  23. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  24. data/spec/mysql/cli/config_spec.rb +0 -210
  25. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  26. data/spec/mysql/collation/collation_spec.rb +0 -153
  27. data/spec/mysql/comment/comment_spec.rb +0 -179
  28. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  29. data/spec/mysql/diff/diff2_spec.rb +0 -189
  30. data/spec/mysql/diff/diff_spec.rb +0 -168
  31. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  32. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  33. data/spec/mysql/dump/dump_spec.rb +0 -74
  34. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  35. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  36. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  37. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  38. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  39. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  40. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  41. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  42. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  43. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  44. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  45. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  46. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -231
  47. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  48. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  49. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  50. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  51. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  52. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  53. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -34
  54. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  55. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  56. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  57. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  58. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  59. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  60. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  61. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  62. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  63. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  64. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  65. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  66. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  67. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  68. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  69. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  70. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  71. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  72. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  73. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  74. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  75. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  76. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  77. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  78. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  79. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  80. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  81. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  82. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  83. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  84. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  85. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  86. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  87. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  88. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  89. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  90. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  91. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  92. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  93. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  94. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  95. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  96. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  97. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  98. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  99. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  100. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  101. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  102. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  103. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  104. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  105. data/spec/mysql/ridgepole_test_database.sql +0 -2
  106. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  107. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  108. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  109. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  110. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  111. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  112. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  113. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  114. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  115. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  116. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  117. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  118. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  119. data/spec/postgresql/diff/diff_spec.rb +0 -216
  120. data/spec/postgresql/dump/dump_spec.rb +0 -69
  121. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  122. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  123. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  124. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  125. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  126. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  127. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  128. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  129. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  130. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  131. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  132. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  133. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  134. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  135. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  136. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  137. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  138. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  139. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  140. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  141. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  142. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  143. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  144. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  145. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  146. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  147. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  148. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  149. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  150. data/spec/processing_for_ci.rb +0 -13
  151. data/spec/spec_condition.rb +0 -58
  152. data/spec/spec_const.rb +0 -20
  153. data/spec/spec_helper.rb +0 -173
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when create_table options are different' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
8
- t.date "birth_date", null: false
9
- t.string "first_name", limit: 14, null: false
10
- t.string "last_name", limit: 16, null: false
11
- t.string "gender", limit: 1, null: false
12
- t.date "hire_date", null: false
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "employees", primary_key: "emp_no2", force: :cascade do |t|
20
- t.date "birth_date", null: false
21
- t.string "first_name", limit: 14, null: false
22
- t.string "last_name", limit: 16, null: false
23
- t.string "gender", limit: 1, null: false
24
- t.date "hire_date", null: false
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client }
31
-
32
- it {
33
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
34
- [WARNING] Table option changes are ignored on `employees`.
35
- from: {:primary_key=>"emp_no"}
36
- to: {:primary_key=>"emp_no2"}
37
- MSG
38
- delta = subject.diff(expected_dsl)
39
- expect(delta.differ?).to be_falsey
40
- expect(subject.dump).to match_ruby actual_dsl
41
- delta.migrate
42
- expect(subject.dump).to match_ruby actual_dsl
43
- }
44
- end
45
-
46
- context 'when create_table options are different (ignore comment)' do
47
- let(:actual_dsl) do
48
- erbh(<<-ERB)
49
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
50
- t.date "birth_date", null: false
51
- t.string "first_name", limit: 14, null: false
52
- t.string "last_name", limit: 16, null: false
53
- t.string "gender", limit: 1, null: false
54
- t.date "hire_date", null: false
55
- end
56
- ERB
57
- end
58
-
59
- let(:expected_dsl) do
60
- erbh(<<-ERB)
61
- create_table "employees", primary_key: "emp_no", comment: "my comment", force: :cascade do |t|
62
- t.date "birth_date", null: false
63
- t.string "first_name", limit: 14, null: false
64
- t.string "last_name", limit: 16, null: false
65
- t.string "gender", limit: 1, null: false
66
- t.date "hire_date", null: false
67
- end
68
- ERB
69
- end
70
-
71
- before { subject.diff(actual_dsl).migrate }
72
- subject { client(ignore_table_comment: true) }
73
-
74
- it {
75
- expect(Ridgepole::Logger.instance).to_not receive(:warn)
76
- delta = subject.diff(expected_dsl)
77
- expect(delta.differ?).to be_falsey
78
- expect(subject.dump).to match_ruby actual_dsl
79
- delta.migrate
80
- expect(subject.dump).to match_ruby actual_dsl
81
- }
82
- end
83
- end
@@ -1,225 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'with warning' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "dept_manager", force: :cascade do |t|
8
- t.string "dept_no", limit: 4, null: false
9
- t.date "from_date", null: false
10
- t.date "to_date", null: false
11
- end
12
-
13
- create_table "employees", force: :cascade do |t|
14
- t.integer "emp_no", null: false
15
- t.date "birth_date", null: false
16
- t.string "first_name", limit: 14, null: false
17
- t.string "last_name", limit: 16, null: false
18
- t.string "gender", limit: 1, null: false
19
- t.date "hire_date", null: false
20
- end
21
- ERB
22
- end
23
-
24
- let(:expected_dsl) do
25
- erbh(<<-ERB)
26
- create_table "dept_manager", force: :cascade do |t|
27
- t.integer "employee_id"
28
- t.string "dept_no", limit: 4, null: false
29
- t.date "from_date", null: false
30
- t.date "to_date", null: false
31
- end
32
-
33
- create_table "employees", force: :cascade do |t|
34
- t.integer "emp_no", null: false
35
- t.date "birth_date", null: false
36
- t.string "first_name", limit: 14, null: false
37
- t.string "last_name", limit: 16, null: false
38
- t.string "gender", limit: 1, null: false
39
- t.date "hire_date", null: false
40
- end
41
- ERB
42
- end
43
-
44
- before { subject.diff(actual_dsl).migrate }
45
- subject { client(check_relation_type: 'bigint') }
46
-
47
- it {
48
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
49
- [WARNING] Relation column type is different.
50
- employees.id: {:type=>:bigint}
51
- dept_manager.employee_id: {:type=>:integer}
52
- MSG
53
-
54
- delta = subject.diff(expected_dsl)
55
- expect(delta.differ?).to be_truthy
56
- expect(subject.dump).to match_ruby actual_dsl
57
- delta.migrate
58
- expect(subject.dump).to match_ruby expected_dsl
59
- }
60
- end
61
-
62
- context 'with unsigned warning' do
63
- let(:actual_dsl) do
64
- erbh(<<-ERB)
65
- create_table "dept_manager", force: :cascade do |t|
66
- t.string "dept_no", limit: 4, null: false
67
- t.date "from_date", null: false
68
- t.date "to_date", null: false
69
- end
70
-
71
- create_table "employees", <%= i cond(">= 6.1", { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade do |t|
72
- t.integer "emp_no", null: false
73
- t.date "birth_date", null: false
74
- t.string "first_name", limit: 14, null: false
75
- t.string "last_name", limit: 16, null: false
76
- t.string "gender", limit: 1, null: false
77
- t.date "hire_date", null: false
78
- end
79
- ERB
80
- end
81
-
82
- let(:expected_dsl) do
83
- erbh(<<-ERB)
84
- create_table "dept_manager", force: :cascade do |t|
85
- t.bigint "employee_id"
86
- t.string "dept_no", limit: 4, null: false
87
- t.date "from_date", null: false
88
- t.date "to_date", null: false
89
- end
90
-
91
- create_table "employees", <%= i cond(">= 6.1", { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade do |t|
92
- t.integer "emp_no", null: false
93
- t.date "birth_date", null: false
94
- t.string "first_name", limit: 14, null: false
95
- t.string "last_name", limit: 16, null: false
96
- t.string "gender", limit: 1, null: false
97
- t.date "hire_date", null: false
98
- end
99
- ERB
100
- end
101
-
102
- before { subject.diff(actual_dsl).migrate }
103
- subject { client(check_relation_type: 'bigint') }
104
-
105
- it {
106
- expect(Ridgepole::Logger.instance).to receive(:warn).with(<<-MSG)
107
- [WARNING] Relation column type is different.
108
- employees.id: {:type=>:bigint, :unsigned=>true}
109
- dept_manager.employee_id: {:type=>:bigint}
110
- MSG
111
-
112
- delta = subject.diff(expected_dsl)
113
- expect(delta.differ?).to be_truthy
114
- expect(subject.dump).to match_ruby actual_dsl
115
- delta.migrate
116
- expect(subject.dump).to match_ruby expected_dsl
117
- }
118
- end
119
-
120
- context 'without warning' do
121
- let(:actual_dsl) do
122
- erbh(<<-ERB)
123
- create_table "dept_manager", force: :cascade do |t|
124
- t.string "dept_no", limit: 4, null: false
125
- t.date "from_date", null: false
126
- t.date "to_date", null: false
127
- end
128
-
129
- create_table "employees", force: :cascade do |t|
130
- t.integer "emp_no", null: false
131
- t.date "birth_date", null: false
132
- t.string "first_name", limit: 14, null: false
133
- t.string "last_name", limit: 16, null: false
134
- t.string "gender", limit: 1, null: false
135
- t.date "hire_date", null: false
136
- end
137
- ERB
138
- end
139
-
140
- let(:expected_dsl) do
141
- erbh(<<-ERB)
142
- create_table "dept_manager", force: :cascade do |t|
143
- t.bigint "employee_id"
144
- t.string "dept_no", limit: 4, null: false
145
- t.date "from_date", null: false
146
- t.date "to_date", null: false
147
- end
148
-
149
- create_table "employees", force: :cascade do |t|
150
- t.integer "emp_no", null: false
151
- t.date "birth_date", null: false
152
- t.string "first_name", limit: 14, null: false
153
- t.string "last_name", limit: 16, null: false
154
- t.string "gender", limit: 1, null: false
155
- t.date "hire_date", null: false
156
- end
157
- ERB
158
- end
159
-
160
- before { subject.diff(actual_dsl).migrate }
161
- subject { client(check_relation_type: 'bigint') }
162
-
163
- it {
164
- expect(Ridgepole::Logger.instance).to_not receive(:warn)
165
- delta = subject.diff(expected_dsl)
166
- expect(delta.differ?).to be_truthy
167
- expect(subject.dump).to match_ruby actual_dsl
168
- delta.migrate
169
- expect(subject.dump).to match_ruby expected_dsl
170
- }
171
- end
172
-
173
- context 'with unsigned warning' do
174
- let(:actual_dsl) do
175
- erbh(<<-ERB)
176
- create_table "dept_manager", force: :cascade do |t|
177
- t.string "dept_no", limit: 4, null: false
178
- t.date "from_date", null: false
179
- t.date "to_date", null: false
180
- end
181
-
182
- create_table "employees", <%= i cond(">= 6.1", { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade do |t|
183
- t.integer "emp_no", null: false
184
- t.date "birth_date", null: false
185
- t.string "first_name", limit: 14, null: false
186
- t.string "last_name", limit: 16, null: false
187
- t.string "gender", limit: 1, null: false
188
- t.date "hire_date", null: false
189
- end
190
- ERB
191
- end
192
-
193
- let(:expected_dsl) do
194
- erbh(<<-ERB)
195
- create_table "dept_manager", force: :cascade do |t|
196
- t.bigint "employee_id", unsigned: true
197
- t.string "dept_no", limit: 4, null: false
198
- t.date "from_date", null: false
199
- t.date "to_date", null: false
200
- end
201
-
202
- create_table "employees", <%= i cond(">= 6.1", { id: { type: :bigint, unsigned: true } }, { id: :bigint, unsigned: true }) %>, force: :cascade do |t|
203
- t.integer "emp_no", null: false
204
- t.date "birth_date", null: false
205
- t.string "first_name", limit: 14, null: false
206
- t.string "last_name", limit: 16, null: false
207
- t.string "gender", limit: 1, null: false
208
- t.date "hire_date", null: false
209
- end
210
- ERB
211
- end
212
-
213
- before { subject.diff(actual_dsl).migrate }
214
- subject { client(check_relation_type: 'bigint') }
215
-
216
- it {
217
- expect(Ridgepole::Logger.instance).to_not receive(:warn)
218
- delta = subject.diff(expected_dsl)
219
- expect(delta.differ?).to be_truthy
220
- expect(subject.dump).to match_ruby actual_dsl
221
- delta.migrate
222
- expect(subject.dump).to match_ruby expected_dsl
223
- }
224
- end
225
- end
@@ -1,203 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when create index (use t.index)' do
5
- let(:dsl) do
6
- erbh(<<-ERB)
7
- create_table "clubs", force: :cascade do |t|
8
- t.string "name", default: "", null: false
9
- t.index ["name"], name: "idx_name", unique: true
10
- end
11
-
12
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
13
- t.string "dept_name", limit: 40, null: false
14
- t.index ["dept_name"], name: "dept_name", unique: true
15
- end
16
-
17
- create_table "dept_emp", id: false, force: :cascade do |t|
18
- t.integer "emp_no", null: false
19
- t.string "dept_no", null: false
20
- t.date "from_date", null: false
21
- t.date "to_date", null: false
22
- t.index ["dept_no"], name: "dept_no"
23
- t.index ["emp_no"], name: "emp_no"
24
- end
25
-
26
- create_table "dept_manager", id: false, force: :cascade do |t|
27
- t.string "dept_no", null: false
28
- t.integer "emp_no", null: false
29
- t.date "from_date", null: false
30
- t.date "to_date", null: false
31
- t.index ["dept_no"], name: "dept_no"
32
- t.index ["emp_no"], name: "emp_no"
33
- end
34
-
35
- create_table "employee_clubs", force: :cascade do |t|
36
- t.integer "emp_no", null: false
37
- t.integer "club_id", null: false
38
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
39
- end
40
-
41
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
42
- t.date "birth_date", null: false
43
- t.string "first_name", limit: 14, null: false
44
- t.string "last_name", limit: 16, null: false
45
- t.string "gender", limit: 1, null: false
46
- t.date "hire_date", null: false
47
- end
48
-
49
- create_table "salaries", id: false, force: :cascade do |t|
50
- t.integer "emp_no", null: false
51
- t.integer "salary", null: false
52
- t.date "from_date", null: false
53
- t.date "to_date", null: false
54
- t.index ["emp_no"], name: "emp_no"
55
- end
56
-
57
- create_table "titles", id: false, force: :cascade do |t|
58
- t.integer "emp_no", null: false
59
- t.string "title", limit: 50, null: false
60
- t.date "from_date", null: false
61
- t.date "to_date"
62
- t.index ["emp_no"], name: "emp_no"
63
- end
64
- ERB
65
- end
66
-
67
- let(:actual_dsl) do
68
- erbh(<<-ERB)
69
- create_table "clubs", force: :cascade do |t|
70
- t.string "name", default: "", null: false
71
- end
72
-
73
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
74
- t.string "dept_name", limit: 40, null: false
75
- t.index ["dept_name"], name: "dept_name", unique: true
76
- end
77
-
78
- create_table "dept_emp", id: false, force: :cascade do |t|
79
- t.integer "emp_no", null: false
80
- t.string "dept_no", null: false
81
- t.date "from_date", null: false
82
- t.date "to_date", null: false
83
- t.index ["dept_no"], name: "dept_no"
84
- t.index ["emp_no"], name: "emp_no"
85
- end
86
-
87
- create_table "dept_manager", id: false, force: :cascade do |t|
88
- t.string "dept_no", null: false
89
- t.integer "emp_no", null: false
90
- t.date "from_date", null: false
91
- t.date "to_date", null: false
92
- t.index ["dept_no"], name: "dept_no"
93
- t.index ["emp_no"], name: "emp_no"
94
- end
95
-
96
- create_table "employee_clubs", force: :cascade do |t|
97
- t.integer "emp_no", null: false
98
- t.integer "club_id", null: false
99
- end
100
-
101
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
102
- t.date "birth_date", null: false
103
- t.string "first_name", limit: 14, null: false
104
- t.string "last_name", limit: 16, null: false
105
- t.string "gender", limit: 1, null: false
106
- t.date "hire_date", null: false
107
- end
108
-
109
- create_table "salaries", id: false, force: :cascade do |t|
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"
115
- end
116
-
117
- create_table "titles", id: false, force: :cascade do |t|
118
- t.integer "emp_no", null: false
119
- t.string "title", limit: 50, null: false
120
- t.date "from_date", null: false
121
- t.date "to_date"
122
- end
123
- ERB
124
- end
125
-
126
- let(:expected_dsl) do
127
- erbh(<<-ERB)
128
- create_table "clubs", force: :cascade do |t|
129
- t.string "name", limit: 255, default: "", null: false
130
- t.index ["name"], name: "idx_name", unique: true
131
- end
132
-
133
- create_table "departments", primary_key: "dept_no", force: :cascade do |t|
134
- t.string "dept_name", limit: 40, null: false
135
- end
136
-
137
- add_index "departments", ["dept_name"], name: "dept_name", unique: true
138
-
139
- create_table "dept_emp", id: false, force: :cascade do |t|
140
- t.integer "emp_no", null: false
141
- t.string "dept_no", null: false
142
- t.date "from_date", null: false
143
- t.date "to_date", null: false
144
- end
145
-
146
- add_index "dept_emp", ["dept_no"], name: "dept_no"
147
- add_index "dept_emp", ["emp_no"], name: "emp_no"
148
-
149
- create_table "dept_manager", id: false, force: :cascade do |t|
150
- t.string "dept_no", null: false
151
- t.integer "emp_no", null: false
152
- t.date "from_date", null: false
153
- t.date "to_date", null: false
154
- end
155
-
156
- add_index "dept_manager", ["dept_no"], name: "dept_no"
157
- add_index "dept_manager", ["emp_no"], name: "emp_no"
158
-
159
- create_table "employee_clubs", force: :cascade do |t|
160
- t.integer "emp_no", null: false
161
- t.integer "club_id", null: false
162
- t.index ["emp_no", "club_id"], name: "idx_emp_no_club_id"
163
- end
164
-
165
- create_table "employees", primary_key: "emp_no", force: :cascade do |t|
166
- t.date "birth_date", null: false
167
- t.string "first_name", limit: 14, null: false
168
- t.string "last_name", limit: 16, null: false
169
- t.string "gender", limit: 1, null: false
170
- t.date "hire_date", null: false
171
- end
172
-
173
- create_table "salaries", id: false, force: :cascade do |t|
174
- t.integer "emp_no", null: false
175
- t.integer "salary", null: false
176
- t.date "from_date", null: false
177
- t.date "to_date", null: false
178
- end
179
-
180
- add_index "salaries", ["emp_no"], name: "emp_no"
181
-
182
- create_table "titles", id: false, force: :cascade do |t|
183
- t.integer "emp_no", null: false
184
- t.string "title", limit: 50, null: false
185
- t.date "from_date", null: false
186
- t.date "to_date"
187
- t.index ["emp_no"], name: "emp_no"
188
- end
189
- ERB
190
- end
191
-
192
- before { subject.diff(actual_dsl).migrate }
193
- subject { client }
194
-
195
- it {
196
- delta = subject.diff(expected_dsl)
197
- expect(delta.differ?).to be_truthy
198
- expect(subject.dump).to match_ruby actual_dsl
199
- delta.migrate
200
- expect(subject.dump).to match_ruby dsl
201
- }
202
- end
203
- end