-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Add config to disable schema dump after migration #13948
Conversation
Relevant discussion on the mailing list: https://groups.google.com/forum/#!topic/rubyonrails-core/h4cQXmKuB7M |
@@ -1,3 +1,12 @@ | |||
* Add flag to disable schema dump after migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing .
at the end.
@emilsoman this is looking good. I added a few minor comments about formatting and style. /cc @fxn |
@@ -81,4 +81,9 @@ Rails.application.configure do | |||
|
|||
# Use default logging formatter so that PID and timestamp are not suppressed. | |||
config.log_formatter = ::Logger::Formatter.new | |||
|
|||
<%- unless options.skip_active_record? -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move the blank line to inside the unless
clause, so that it doesn't end up with extra blank line when skipping AR.
@senny , @carlosantoniodasilva Thanks for the feedback ! Fixed formatting and style issues. Anything else ? |
Hey, gonna have a look today. |
@emilsoman you will need to squash all your commits into a single one but let's wait for feedback from @fxn first. |
Looks good. Just a couple of details. I believe the flag should not appear in test.rb. I explained the rationale in the mailing list but the summary is that since you are not supposed to run migrations in the test environment, it looks strange that the config file says anything about them. The comment is enlightening, see "Do not dump schema after migrations", "in the test environment? which migrations? I am not supposed to run migrations in the test environment!", the user may wonder. Since migrations do not run, the implicit true value is fine, it won't hurt. Then some details regarding the values of the flag. We try to avoid using singletons in docs and tests. As far as the user is concerned this is a flag. We could assign anything to it that is true, and the user can set it to |
@@ -1,3 +1,12 @@ | |||
* Add flag to disable schema dump after migration. | |||
|
|||
Add a config on active_record named `dump_schema_after_migration` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you mean by active_record
, but by itself doesn't have a lot of meaning. Better to just say "Active Record", those config parameters configure the ORM, "Active Record" is going to be good.
@fxn , Thanks for the amazing feedback ! I've removed the config from |
@emilsoman sorry for pointing you in the wrong direction with |
Exactly :), the idea is that we want to communicate that the default config is such that the schema is not dumped in production. The exact value needed to enable or disable the flag doesn't matter, any value works (interpreted as a flag). |
@@ -1,3 +1,11 @@ | |||
* Add flag to disable schema dump after migration. | |||
|
|||
Add a config parameter on ActiveRecord named `dump_schema_after_migration` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that "Active Record" has a space in its name, Active Record is an ORM, and ActiveRecord
is a Ruby module that generally has little to have documented.
## | ||
# :singleton-method: | ||
# Specify whether schema dump should happen at the end of the | ||
# db:migrate rake task. This is true by default, which is useful for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the development environment
I made some editorial comments. Almost there! |
@fxn Fixed. Can I squash the commits ? |
@@ -781,5 +781,22 @@ def index | |||
assert_not Rails.configuration.respond_to?(:method_missing) | |||
assert Rails.configuration.respond_to?(:method_missing, true) | |||
end | |||
|
|||
test "config.active_record.dump_schema_after_migration is falsy on production" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we try to avoid "truthy" and "falsy", "false" is enough
Awesome @emilsoman, added a few minor remarks and I think it is good to go. If you revise those and squash we'll apply. |
* Add a config on Active Record named `dump_schema_after_migration` * Schema dump doesn't happen if the config is set to false * Set default value of the config to true * Set config in generated production environment file to false * Update configuration guide * Update CHANGELOG
@fxn , done :) |
Fantastic! Thanks a lot for working on this 😄 ❤️ |
Thanks for guiding this into good shape. You guys were super helpful. Thank you ! |
Merged here. |
Scott I agree it's generally harmless. It bit us though when we switched from schema to structure, as we rightfully didn't supply pg_dump in our production environments. So grateful for Emil's contribution :) |
* Updated sample database.yml file. * Added sidekiq config file. * Removed rails_12factor gem. Added required config changes for heroku logging. * Removed tagged_logging initializer file. The tagged logging configs are handled separately for each env. * Do not dump schema after migrations. https://groups.google.com/forum/#!topic/rubyonrails-core/h4cQXmKuB7M rails/rails#13948 * Enabled force_ssl config. * Added comments about config/initializers/assets.rb. * reverting some of the changes Co-authored-by: Raj Singh <raj.singh@vineti.com>
dump_schema_after_migration