Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11602 (new defect)

Opened 8 months ago

Last modified 8 months ago

databases.rake should check for localhost and 127.0.0.1 when dropping databases

Reported by: antun Assigned to: core
Priority: normal Milestone: 2.x
Component: Railties Version: edge
Severity: normal Keywords:
Cc:

Description

SYMPTOMS

On some (mine, at least) Cygwin environments with Rails, user sees the following error when running rake db:drop:all :

"This task only drops local databases. mp is on a remote host." rake aborted!

Note that when using Cygwin, you have to enter 127.0.0.1 as your host in database.yml.

CAUSE

This section of the databases.rake file seems to cause the problem:

if confighost? == 'localhost' confighost?.blank?

drop_database(config)

else

p "This task only drops local databases. #{configdatabase?} is on a remote host."

end

Note that the conditional doesn't check if confighost? is 'localhost' *or* '127.0.0.1'. If you look at the part of databases.rake that deals with *creating* databases, it has conditional that deals with this:

if %w( 127.0.0.1 localhost ).include?(confighost?) confighost?.blank?

...

SOLUTION

I think the right thing is to use the same check for dropping databases as for creating them.

Attachments

databases.rake (14.7 kB) - added by antun on 04/19/08 06:15:05.
Here's my fixed databases.rake file.

Change History

04/19/08 06:15:05 changed by antun

  • attachment databases.rake added.

Here's my fixed databases.rake file.

04/20/08 08:58:13 changed by yaroslav

Could you please check this on Edge Rails? seems to be fixed

http://github.com/rails/rails/tree/master/railties/lib/tasks/databases.rake