When running "rake db:drop" also drop test database in development environment #2419

Merged
merged 1 commit into from Oct 24, 2011

6 participants

@dmitriy-kiriyenko

Hi.

There is an explicit code that if you run "rake db:create" in development environment, both development and test databases are created. However, rake db:drop just drops the database for the environment the task is run.

It would be more convenient if rake db:drop would also drop the test database if run in development environment. Suggested patch does this.

@dmitriy-kiriyenko

Any response, please?

@aratak

Indeed, it should be consistency.

@fxn
Ruby on Rails member

I think the implementation of configs_for_environment is a little bit too clever (I may copy-edit it later), but the PR seems good to me. It is not backwards compat but the test database is volatile by definition, so no big deal if drop destroys it and it didn't before in my view.

@fxn fxn merged commit b064614 into rails:master Oct 24, 2011
@fxn fxn added a commit that referenced this pull request Oct 24, 2011
@fxn fxn registers PR #2419 in the CHANGELOG 17bf04f
@georgeG georgeG added a commit to georgeG/rails that referenced this pull request Oct 26, 2011
@georgeG georgeG Merge remote-tracking branch 'upstream/master'
* upstream/master: (91 commits)
  Responders now return 204 No Content for API requests without a response body (as in the new scaffold)
  Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box.
  Fix failing tests.
  properly handle lists of lists. Thanks @adrianpike for reporting!
  Fix that changing a store should mark the store attribute as changed
  Clean up .gitignore and make a note about using global ignores
  Revert "Ignore .rbx directories (rbx compiled bytecode files)"
  Revert "Merge pull request #3395 from bdurand/fix_file_store_cleanup"
  Fix deprecation warnings in action pack test suite due to passing template formats in the template name.
  safeguard against configs missing environment or the database key
  Remove needless to_param in scaffold functional test
  Unused variable removed
  minor revision to some new code in databases.rake
  registers PR #2419 in the CHANGELOG
  ActionPack test fix for RBX
  Ignore .rbx directories (rbx compiled bytecode files)
  edge doesnt provide turn gem in the gemfile anymore
  Remove Turn from default Gemfile.
  Revert "Merge pull request #3405 from arunagw/middleware_name"
  minor fixes in the composed_of doc
  ...

Conflicts:
	.gitignore
79123aa
@brendon

Couldn't this have just been achieved with one line at the start of the begin block in task :drop?

drop_database(ActiveRecord::Base.configurations['test']) if !Rails.env || Rails.env == 'development'
@odigity

The docs were never updated to reflect this change. They still say db:drop drops only the database for the current environment, and there is in fact another task db:drop:all that claims to do all of them, which is really confusing when you run db:drop and all of them drop. :(

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