mirror of https://github.com/rails/rails
Merge pull request #50336 from fatkodima/schema_dumper-dump-global-out
Change `SchemaDumper.dump` default stream to `$stdout`
This commit is contained in:
commit
970126e07e
|
@ -41,7 +41,7 @@ module ActiveRecord
|
|||
cattr_accessor :unique_ignore_pattern, default: /^uniq_rails_[0-9a-f]{10}$/
|
||||
|
||||
class << self
|
||||
def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base)
|
||||
def dump(connection = ActiveRecord::Base.connection, stream = $stdout, config = ActiveRecord::Base)
|
||||
connection.create_schema_dumper(generate_options(config)).dump(stream)
|
||||
stream
|
||||
end
|
||||
|
|
|
@ -5,19 +5,21 @@ module SchemaDumpingHelper
|
|||
connection = ActiveRecord::Base.connection
|
||||
old_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
|
||||
ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - tables
|
||||
stream = StringIO.new
|
||||
|
||||
ActiveRecord::SchemaDumper.dump(connection, stream)
|
||||
stream.string
|
||||
output, = capture_io do
|
||||
ActiveRecord::SchemaDumper.dump(connection)
|
||||
end
|
||||
output
|
||||
ensure
|
||||
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
|
||||
end
|
||||
|
||||
def dump_all_table_schema(ignore_tables = [], connection: ActiveRecord::Base.connection)
|
||||
old_ignore_tables, ActiveRecord::SchemaDumper.ignore_tables = ActiveRecord::SchemaDumper.ignore_tables, ignore_tables
|
||||
stream = StringIO.new
|
||||
ActiveRecord::SchemaDumper.dump(connection, stream)
|
||||
stream.string
|
||||
output, = capture_io do
|
||||
ActiveRecord::SchemaDumper.dump(connection)
|
||||
end
|
||||
output
|
||||
ensure
|
||||
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue