Ticket #11301: fixed_rake_db_create_drop_tasks.2.diff
| File fixed_rake_db_create_drop_tasks.2.diff, 1.6 kB (added by matt, 7 months ago) |
|---|
-
railties/lib/tasks/databases.rake
old new 37 37 @collation = ENV['COLLATION'] || 'utf8_general_ci' 38 38 begin 39 39 ActiveRecord::Base.establish_connection(config.merge({'database' => nil})) 40 ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation})40 ActiveRecord::Base.connection.create_database(config['database'], {:charset => (config['database']['charset'] || @charset), :collation => (config['database']['charset'] || @collation)}) 41 41 ActiveRecord::Base.establish_connection(config) 42 42 rescue 43 $stderr.puts "Couldn't create database for #{config.inspect} "43 $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)" 44 44 end 45 45 when 'postgresql' 46 46 `createdb "#{config['database']}" -E utf8` … … 68 68 69 69 desc 'Drops the database for the current RAILS_ENV' 70 70 task :drop => :environment do 71 drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development']) 71 config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] 72 begin 73 drop_database(config) 74 rescue Exception => e 75 puts "#{e.inspect} - #{config['database']} might have been already dropped" 76 end 72 77 end 73 78 74 79 def local_database?(config, &block)