aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/support/schema_dumping_helper.rb
blob: 2ae8d299e5b963c6499b7cb801b7e666a8bc856f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                          
module SchemaDumpingHelper
  def dump_table_schema(table, connection = ActiveRecord::Base.connection)
    old_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
    ActiveRecord::SchemaDumper.ignore_tables = connection.tables - [table]
    stream = StringIO.new
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
    stream.string
  ensure
    ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
  end
end