Class: Ridgepole::Dumper

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_schema_dumper/ridgepole.rb

Instance Method Summary collapse

Instance Method Details

#dumpObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fast_schema_dumper/ridgepole.rb', line 14

def dump
  case ENV['FAST_SCHEMA_DUMPER_MODE']
  in 'disabled'
    original_dump
  in 'verify'
    puts "Warning: fast_schema_dumper is enabled in verify mode" unless ENV['FAST_SCHEMA_DUMPER_SUPPRESS_MESSAGE'] == '1'
    original_results = original_dump
    fast_results = fast_dump
    File.write("orig.txt", original_results)
    File.write("fast.txt", fast_results)
    if original_results != fast_results
      raise "Dumped schema do not match between ActiveRecord::SchemaDumper and fast_schema_dumper. This is a fast_schema_dumper bug."
    end
    fast_results
  else
    puts "Warning: fast_schema_dumper is enabled" unless ENV['FAST_SCHEMA_DUMPER_SUPPRESS_MESSAGE'] == '1'
    fast_dump
  end
end

#fast_dumpObject



34
35
36
37
38
39
# File 'lib/fast_schema_dumper/ridgepole.rb', line 34

def fast_dump
  s = StringIO.new
  FastSchemaDumper::SchemaDumper.dump(ActiveRecord::Base.connection_pool, s)
  s.rewind
  s.read
end

#original_dumpObject



12
# File 'lib/fast_schema_dumper/ridgepole.rb', line 12

alias_method :original_dump, :dump