diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-23 08:11:26 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-23 08:11:26 -0700 |
commit | eec00b8c03273d006aa12505bde32e2a2547b670 (patch) | |
tree | 8029cab88f9c0ae2b64c44cb4f0a8cd5272eaf5d /activerecord | |
parent | 68d7a1e3f2e131541881ed41cd5b1cdf169c4fe8 (diff) | |
parent | 9f82fb3f63015bbbd643bc624a49d98e97803681 (diff) | |
download | rails-eec00b8c03273d006aa12505bde32e2a2547b670.tar.gz rails-eec00b8c03273d006aa12505bde32e2a2547b670.tar.bz2 rails-eec00b8c03273d006aa12505bde32e2a2547b670.zip |
Merge pull request #11987 from wangjohn/schema_dumper_options
Creating options for schema dumper.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 1181cc739e..8986d255cd 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -17,9 +17,19 @@ module ActiveRecord cattr_accessor :ignore_tables @@ignore_tables = [] - def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT) - new(connection).dump(stream) - stream + class << self + def dump(connection=ActiveRecord::Base.connection, stream=STDOUT, config = ActiveRecord::Base) + new(connection, generate_options(config)).dump(stream) + stream + end + + private + def generate_options(config) + { + table_name_prefix: config.table_name_prefix, + table_name_suffix: config.table_name_suffix + } + end end def dump(stream) @@ -32,10 +42,11 @@ module ActiveRecord private - def initialize(connection) + def initialize(connection, options = {}) @connection = connection @types = @connection.native_database_types @version = Migrator::current_version rescue nil + @options = options end def header(stream) @@ -201,7 +212,7 @@ HEADER end def remove_prefix_and_suffix(table) - table.gsub(/^(#{ActiveRecord::Base.table_name_prefix})(.+)(#{ActiveRecord::Base.table_name_suffix})$/, "\\2") + table.gsub(/^(#{@options[:table_name_prefix]})(.+)(#{@options[:table_name_suffix]})$/, "\\2") end end end |