[go: up one dir, main page]

Skip to content
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

Merged
merged 1 commit into from
Feb 6, 2014

Conversation

emilsoman
Copy link
Contributor
  • 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 and test environment files to false
  • Update configuration guide
  • Update CHANGELOG

@senny
Copy link
Member
senny commented Feb 5, 2014

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
Copy link
Member

Choose a reason for hiding this comment

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

missing . at the end.

@senny
Copy link
Member
senny commented Feb 5, 2014

@emilsoman this is looking good. I added a few minor comments about formatting and style.

/cc @fxn

@senny senny closed this Feb 5, 2014
@senny senny reopened this Feb 5, 2014
@@ -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? -%>

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.

@emilsoman
Copy link
Contributor Author

@senny , @carlosantoniodasilva Thanks for the feedback ! Fixed formatting and style issues. Anything else ?

@fxn
Copy link
Member
fxn commented Feb 5, 2014

Hey, gonna have a look today.

@senny
Copy link
Member
senny commented Feb 5, 2014

@emilsoman you will need to squash all your commits into a single one but let's wait for feedback from @fxn first.

@fxn
Copy link
Member
fxn commented Feb 5, 2014

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 nil if he so wishes, we only use the flag for its boolean interpretation. I am going to do some inline comments to be more specific.

@@ -1,3 +1,12 @@
* Add flag to disable schema dump after migration.

Add a config on active_record named `dump_schema_after_migration`
Copy link
Member

Choose a reason for hiding this comment

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

config parameter

Copy link
Member

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.

@emilsoman
Copy link
Contributor Author

@fxn , Thanks for the amazing feedback ! I've removed the config from config/environments/test.rb because what you said makes perfect sense. I've fixed the grammatical issues that you pointed out. I am not sure about a couple of things for which I've left inline comments. Please take a look whenever you can. Thank you :)

@senny
Copy link
Member
senny commented Feb 6, 2014

@emilsoman sorry for pointing you in the wrong direction with true and false 😓

@fxn
Copy link
Member
fxn commented Feb 6, 2014

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`
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

for the development environment

@fxn
Copy link
Member
fxn commented Feb 6, 2014

I made some editorial comments. Almost there!

@emilsoman
Copy link
Contributor Author

@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
Copy link
Member

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

@fxn
Copy link
Member
fxn commented Feb 6, 2014

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
@emilsoman
Copy link
Contributor Author

@fxn , done :)

@fxn
Copy link
Member
fxn commented Feb 6, 2014

Fantastic! Thanks a lot for working on this 😄 ❤️

@emilsoman
Copy link
Contributor Author

Thanks for guiding this into good shape. You guys were super helpful. Thank you !

@fxn fxn merged commit 8806768 into rails:master Feb 6, 2014
@fxn
Copy link
Member
fxn commented Feb 6, 2014

Merged here.

@gkop
Copy link
gkop commented Apr 6, 2018

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 :)

neerajsingh0101 pushed a commit to bigbinary/wheel that referenced this pull request Mar 13, 2020
* 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>
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.

6 participants