aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-03-10 11:42:01 +0000
committerPratik Naik <pratiknaik@gmail.com>2008-03-10 11:42:01 +0000
commit3d2177df26c8934320277a7aed84595decd94662 (patch)
tree0b979d7e382e171c1688c7c841b299ea0830d78d
parent8e21ec36cf110793d56fe281995939efd3533e34 (diff)
downloadrails-3d2177df26c8934320277a7aed84595decd94662.tar.gz
rails-3d2177df26c8934320277a7aed84595decd94662.tar.bz2
rails-3d2177df26c8934320277a7aed84595decd94662.zip
Fix database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9004 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake11
2 files changed, 10 insertions, 3 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index f2bd7d6930..bfc066e6f1 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt]
+
* add a -e/--export to script/plugin install, uses svn export. #10847 [jon@blankpad.net)]
* Add config.time_zone for configuring the default Time.zone value. #10982 [Geoff Buesing]
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 00c0fa4072..73259ee34d 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -37,10 +37,10 @@ namespace :db do
@collation = ENV['COLLATION'] || 'utf8_general_ci'
begin
ActiveRecord::Base.establish_connection(config.merge({'database' => nil}))
- ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation})
+ ActiveRecord::Base.connection.create_database(config['database'], {:charset => (config['database']['charset'] || @charset), :collation => (config['database']['charset'] || @collation)})
ActiveRecord::Base.establish_connection(config)
rescue
- $stderr.puts "Couldn't create database for #{config.inspect}"
+ $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{@charset}, collation: #{@collation} (if you set the charset manually, make sure you have a matching collation)"
end
when 'postgresql'
`createdb "#{config['database']}" -E utf8`
@@ -68,7 +68,12 @@ namespace :db do
desc 'Drops the database for the current RAILS_ENV'
task :drop => :environment do
- drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development'])
+ config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
+ begin
+ drop_database(config)
+ rescue Exception => e
+ puts "Couldn't drop #{config['database']} : #{e.inspect}"
+ end
end
def local_database?(config, &block)