@@ -15,14 +15,6 @@ class SchemaDumperTest < ActiveRecord::TestCase
15
15
@schema_migration . create_table
16
16
end
17
17
18
- def standard_dump
19
- @@standard_dump ||= perform_schema_dump
20
- end
21
-
22
- def perform_schema_dump
23
- dump_all_table_schema [ ]
24
- end
25
-
26
18
# See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/347
27
19
def test_dump_index_rather_than_unique_constraints
28
20
ActiveRecord ::Base . with_connection do |conn |
@@ -35,13 +27,9 @@ def test_dump_index_rather_than_unique_constraints
35
27
end
36
28
end
37
29
38
- stream = StringIO . new
39
- ActiveRecord ::Base . connection_pool . with_connection do |conn |
40
- dumper = conn . create_schema_dumper ( { } )
41
- dumper . send ( :table , "payments" , stream )
42
- end
43
- stream . rewind
44
- index_lines = stream . each_line . select { _1 [ /simple_unique|unique_with_where|as_unique_constraint/ ] }
30
+ output = dump_table_schema ( "payments" )
31
+
32
+ index_lines = output . each_line . select { _1 [ /simple_unique|unique_with_where|as_unique_constraint/ ] }
45
33
assert_equal 2 , index_lines . size
46
34
index_lines . each do |line |
47
35
assert_match ( /t.index/ , line )
@@ -69,7 +57,8 @@ def down
69
57
end
70
58
migration . migrate ( :up )
71
59
72
- output = perform_schema_dump
60
+ output = dump_table_schema "timestamps"
61
+
73
62
assert output . include? ( 't.datetime "this_should_remain_datetime"' )
74
63
assert output . include? ( 't.datetime "this_is_an_alias_of_datetime"' )
75
64
assert output . include? ( 't.timestamp "without_time_zone"' )
@@ -97,7 +86,7 @@ def down
97
86
end
98
87
migration . migrate ( :up )
99
88
100
- output = perform_schema_dump
89
+ output = dump_table_schema "timestamps"
101
90
# Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
102
91
# to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
103
92
# are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -131,7 +120,7 @@ def down
131
120
end
132
121
migration . migrate ( :up )
133
122
134
- output = perform_schema_dump
123
+ output = dump_table_schema "timestamps"
135
124
# Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
136
125
# to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
137
126
# are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -166,7 +155,7 @@ def down
166
155
end
167
156
migration . migrate ( :up )
168
157
169
- output = perform_schema_dump
158
+ output = dump_table_schema "timestamps"
170
159
# Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
171
160
# to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
172
161
# are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -200,15 +189,15 @@ def down
200
189
end
201
190
migration . migrate ( :up )
202
191
203
- output = perform_schema_dump
192
+ output = dump_table_schema "timestamps"
204
193
assert output . include? ( 't.datetime "default_format"' )
205
194
assert output . include? ( 't.datetime "without_time_zone"' )
206
195
assert output . include? ( 't.timestamptz "with_time_zone"' )
207
196
208
197
datetime_type_was = ActiveRecord ::ConnectionAdapters ::CockroachDBAdapter . datetime_type
209
198
ActiveRecord ::ConnectionAdapters ::CockroachDBAdapter . datetime_type = :timestamptz
210
199
211
- output = perform_schema_dump
200
+ output = dump_table_schema "timestamps"
212
201
assert output . include? ( 't.timestamp "default_format"' )
213
202
assert output . include? ( 't.timestamp "without_time_zone"' )
214
203
assert output . include? ( 't.datetime "with_time_zone"' )
0 commit comments