File tree Expand file tree Collapse file tree
lib/schema_plus/core/active_record Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,14 @@ def self.prepended(base)
1616
1717 def dump ( stream )
1818 @dump = SchemaDump . new ( self )
19- super stream
19+
20+ # If some other gem has a SchemaDumper, and it is higher than us in inheritance chain,
21+ # it still can write something into a "real" stream that would evade our redefined methods.
22+ # Tentatively consider that all it wrote can go to "header" (though it might be too naive).
23+ temp_stream = StringIO . new
24+ super temp_stream
25+ @dump . header += temp_stream . string
26+
2027 @dump . assemble ( stream )
2128 end
2229
@@ -54,7 +61,15 @@ def types(_)
5461
5562 def tables ( _ )
5663 SchemaMonkey ::Middleware ::Dumper ::Tables . start ( dumper : self , connection : @connection , dump : @dump ) do |env |
57- super nil
64+ # Other gems SchemaDumpers might redefine tables and, besides using methods like `table` inside
65+ # (which we override), they might also write directly to a stream.
66+ # For examples, https://github.com/bibendi/activerecord-postgres_enum/blob/v2.1.0/lib/active_record/postgres_enum/schema_dumper.rb
67+ # This gem overrides `tables` to drop `create_enum` statements into the stream before table definitions.
68+ #
69+ # Tentatively consider whatever is written this way as part of the header, though it might be too naive.
70+ stream = StringIO . new
71+ super stream
72+ @dump . header += stream . string
5873 end
5974 end
6075
You can’t perform that action at this time.
0 commit comments