Sha256: 2ab13fef6a46469f17d25dde5bb9ee8dd9000e703eba58d723c9cfb0317d7962

Contents?: true

Size: 847 Bytes

Versions: 6

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

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

  def dump_all_table_schema(ignore_tables)
    old_ignore_tables, ActiveRecord::SchemaDumper.ignore_tables = ActiveRecord::SchemaDumper.ignore_tables, ignore_tables
    stream = StringIO.new
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
    stream.string
  ensure
    ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ibm_db-5.5.0 test/support/schema_dumping_helper.rb
ibm_db-5.4.1 test/support/schema_dumping_helper.rb
ibm_db-5.4.0 test/support/schema_dumping_helper.rb
ibm_db-5.3.2 test/support/schema_dumping_helper.rb
ibm_db-5.3.1 test/support/schema_dumping_helper.rb
ruby-on-quails-0.1.0 activerecord/test/support/schema_dumping_helper.rb