Skip to content

Add config.active_record.dump_schemas.#19347

Merged
senny merged 1 commit into
rails:masterfrom
rywall:dump-schemas-config
Mar 17, 2015
Merged

Add config.active_record.dump_schemas.#19347
senny merged 1 commit into
rails:masterfrom
rywall:dump-schemas-config

Conversation

@rywall

@rywall rywall commented Mar 15, 2015

Copy link
Copy Markdown
Contributor

Fixes db:structure:dump when using schema_search_path and PostgreSQL extensions.

Closes #17157.

@rywall

rywall commented Mar 15, 2015

Copy link
Copy Markdown
Contributor Author

@senny @jimmykarily Here is a first pass. Feedback appreciated. :)

Comment thread activerecord/lib/active_record/core.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs should mention the default value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to model it after the documentation for schema_format (above) which doesn't specify the default in the doc. Should I change both?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's focus on this change for now. If you have time, you can update the other in a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@senny

senny commented Mar 16, 2015

Copy link
Copy Markdown
Member

@rywall looking good. Do you think you could add test-cases for this new functionality?

@jimmykarily

Copy link
Copy Markdown

👍

@rywall

rywall commented Mar 16, 2015

Copy link
Copy Markdown
Contributor Author

@senny I've added some tests. Anything else?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use an example with two schemas as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@senny

senny commented Mar 17, 2015

Copy link
Copy Markdown
Member

@rywall I added a couple comments. Thank you for your work on this 💛

Fixes db:structure:dump when using schema_search_path and PostgreSQL
extensions.

Closes rails#17157.
@rywall rywall force-pushed the dump-schemas-config branch from 8e10e5d to 7ab36f4 Compare March 17, 2015 17:45
@rywall

rywall commented Mar 17, 2015

Copy link
Copy Markdown
Contributor Author

I've refactored the tests to avoid side effects. I think I've addressed all you other comments as well. Thanks for your feedback. The pull request is much better for it. 👍

senny added a commit that referenced this pull request Mar 17, 2015
Add config.active_record.dump_schemas.
@senny senny merged commit ec85089 into rails:master Mar 17, 2015
@senny

senny commented Mar 17, 2015

Copy link
Copy Markdown
Member

@rywall awesome! Thank you for your work 💛

@jimmykarily

Copy link
Copy Markdown

Thanks!

@rywall rywall deleted the dump-schemas-config branch April 17, 2015 18:37
@GUI

GUI commented Nov 13, 2015

Copy link
Copy Markdown
Contributor

Thanks, @rywall! If anyone else stumbles upon this and would find this functionality useful in Rails 3 or Rails 4, I created a gem to backport this functionality to those versions of Rails: https://github.com/GUI/activerecord-postgres-dump-schemas

@njakobsen

Copy link
Copy Markdown
Contributor

❤️ @GUI.

@NikolayS

NikolayS commented May 18, 2017

Copy link
Copy Markdown

Thanks for this.

Any plans to support pg_dump's --exclude-schema as well?

In some cases, it might be more convenient to have a "black list", not a "white" one.

@rainhead

rainhead commented Oct 16, 2017

Copy link
Copy Markdown

For anyone looking for a way to dump extensions along with a subset of schemas, or otherwise needing extra control over pg_dump, set ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags:

ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = %w{
  --exclude-schema=schema2
  --exclude-schema=schema3
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No extensions in structure.sql when schema_search_path is defined

8 participants