mirror of
https://github.com/github/rails.git
synced 2026-02-19 02:14:20 -05:00
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
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user