From d1dcdf21286cb459a422b6b88967d712c75f002a Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Thu, 19 Nov 2015 11:12:24 -0700 Subject: Fix rake db:structure:dump on Postgres when multiple schemas are used. If postgresql is being used and there are multiple schemas listed on the `schema_search_path`, then `structure.sql` dumps (triggered by `rake db:structure:dump` or `config.active_record.schema_format = :sql`) began failing in Rails 4.2.5. This is due to the changes made in https://github.com/rails/rails/pull/17885 The problem is that multiple schemas were getting getting passed to `Kernel.system` as a single, space delimited string argument (for example, "--schema=foo --schema=bar"). However, with the updated array style of calling `Kernel.system`, these need to be passed as separate arguments (for example, "--schema=foo", "--schema=bar"). If they get passed as a single string, then the underlying pg_dump program isn't sure how to interpret that single argument and you'll get an error reporting: "pg_dump: No matching schemas were found" --- activerecord/lib/active_record/tasks/postgresql_database_tasks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/tasks') diff --git a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb index cd7d949239..8b4874044c 100644 --- a/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb @@ -56,9 +56,9 @@ module ActiveRecord args = ['-s', '-x', '-O', '-f', filename] unless search_path.blank? - args << search_path.split(',').map do |part| + args += search_path.split(',').map do |part| "--schema=#{part.strip}" - end.join(' ') + end end args << configuration['database'] run_cmd('pg_dump', args, 'dumping') -- cgit v1.2.3