-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rake db:structure:dump on Postgres when multiple schemas are used #22345
Conversation
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 rails#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"
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @carlosantoniodasilva (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
related #22346 |
r? @senny |
Fix rake db:structure:dump on Postgres when multiple schemas are used Conflicts: activerecord/CHANGELOG.md Closes #22346.
Fix rake db:structure:dump on Postgres when multiple schemas are used Conflicts: activerecord/CHANGELOG.md Closes #22346. Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/tasks/postgresql_rake_test.rb
@GUI thank you for the fix. I did a backport to |
Thanks for the merge and backport! |
If anyone else is needing this functionality in Rails 4.2.5 (namely to get the security updates in 4.2.5.1), I put together a quick gem to monkey-patch this functionality for Rails 4.2.5: https://github.com/GUI/rails_425_structure_dump_patch |
If postgresql is being used and there are multiple schemas listed on the
schema_search_path
, thenstructure.sql
dumps (triggered byrake db:structure:dump
orconfig.active_record.schema_format = :sql
) began failing in Rails 4.2.5.This is due to the changes made in #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 callingKernel.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 like: