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

Changeset 9004

Show
Ignore:
Timestamp:
03/10/08 11:42:01 (2 months ago)
Author:
pratik
Message:

Fix database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r8921 r9004  
    11*SVN* 
     2 
     3* Fix database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt] 
    24 
    35* add a -e/--export to script/plugin install, uses svn export. #10847 [jon@blankpad.net)] 
  • trunk/railties/lib/tasks/databases.rake

    r8876 r9004  
    3838        begin 
    3939          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)}) 
    4141          ActiveRecord::Base.establish_connection(config) 
    4242        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)
    4444        end 
    4545      when 'postgresql' 
     
    6969  desc 'Drops the database for the current RAILS_ENV' 
    7070  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 "Couldn't drop #{config['database']} : #{e.inspect}" 
     76    end 
    7277  end 
    7378