Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

db:drop:all throws error when database does not exist [#2997 state:re…

…solved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit 22b020db3ed3992b510b91d3fd423e510b9369e4 1 parent 2de3646
Neeraj Singh neerajdotname authored jeremy committed
Showing with 14 additions and 14 deletions.
  1. +14 −14 railties/lib/tasks/databases.rake
28 railties/lib/tasks/databases.rake
View
@@ -94,11 +94,7 @@ namespace :db do
desc 'Drops the database for the current RAILS_ENV'
task :drop => :load_config do
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
- begin
- drop_database(config)
- rescue Exception => e
- puts "Couldn't drop #{config['database']} : #{e.inspect}"
- end
+ drop_database(config)
end
def local_database?(config, &block)
@@ -410,15 +406,19 @@ namespace :db do
end
def drop_database(config)
- case config['adapter']
- when 'mysql'
- ActiveRecord::Base.establish_connection(config)
- ActiveRecord::Base.connection.drop_database config['database']
- when /^sqlite/
- FileUtils.rm(File.join(RAILS_ROOT, config['database']))
- when 'postgresql'
- ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
- ActiveRecord::Base.connection.drop_database config['database']
+ begin
+ case config['adapter']
+ when 'mysql'
+ ActiveRecord::Base.establish_connection(config)
+ ActiveRecord::Base.connection.drop_database config['database']
+ when /^sqlite/
+ FileUtils.rm(File.join(RAILS_ROOT, config['database']))
+ when 'postgresql'
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
+ ActiveRecord::Base.connection.drop_database config['database']
+ end
+ rescue Exception => e
+ puts "Couldn't drop #{config['database']} : #{e.inspect}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.