diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-03-17 19:38:20 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-03-17 19:38:20 +0100 |
commit | ec850899d5a5de07ad48806cd5862b913c279929 (patch) | |
tree | be5515f76dd555cf9685ef1f2d390aa9a9aeed7c /activerecord/lib/active_record | |
parent | 80f66d405ce0e7c9be1ddf599104b9bcfe6c0e88 (diff) | |
parent | 7ab36f4532c891e8a4bdaee8924a197311ff25ff (diff) | |
download | rails-ec850899d5a5de07ad48806cd5862b913c279929.tar.gz rails-ec850899d5a5de07ad48806cd5862b913c279929.tar.bz2 rails-ec850899d5a5de07ad48806cd5862b913c279929.zip |
Merge pull request #19347 from rywall/dump-schemas-config
Add config.active_record.dump_schemas.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/core.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/postgresql_database_tasks.rb | 10 |
2 files changed, 18 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 82edc4eda5..9a39a0e919 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -85,6 +85,15 @@ module ActiveRecord mattr_accessor :dump_schema_after_migration, instance_writer: false self.dump_schema_after_migration = true + ## + # :singleton-method: + # Specifies which database schemas to dump when calling db:structure:dump. + # If :schema_search_path (the default), it will dumps any schemas listed in schema_search_path. + # Use :all to always dumps all schemas regardless of the schema_search_path. + # A string of comma separated schemas can also be used to pass a custom list of schemas. + mattr_accessor :dump_schemas, instance_writer: false + self.dump_schemas = :schema_search_path + mattr_accessor :maintain_test_schema, instance_accessor: false mattr_accessor :belongs_to_required_by_default, instance_accessor: false diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb index ce1de4b76e..435708a421 100644 --- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb @@ -46,7 +46,15 @@ module ActiveRecord def structure_dump(filename) set_psql_env - search_path = configuration['schema_search_path'] + + search_path = case ActiveRecord::Base.dump_schemas + when :schema_search_path + configuration['schema_search_path'] + when :all + nil + when String + ActiveRecord::Base.dump_schemas + end unless search_path.blank? search_path = search_path.split(",").map{|search_path_part| "--schema=#{Shellwords.escape(search_path_part.strip)}" }.join(" ") end |