From d3467de218b940c4334f6118bbe0659fa75a7fff Mon Sep 17 00:00:00 2001 From: Pete Deffendol Date: Sat, 3 May 2008 21:41:10 -0600 Subject: [PATCH] PostgreSQL: update rake tasks to use full settings from database.yml --- railties/lib/tasks/databases.rake | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 20fdcce..63f7144 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -46,7 +46,7 @@ namespace :db do @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) - ActiveRecord::Base.connection.create_database(config['database'], :encoding => @encoding) + ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding)) ActiveRecord::Base.establish_connection(config) rescue $stderr.puts $!, *($!.backtrace) @@ -314,14 +314,9 @@ namespace :db do ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"]) when "postgresql" - ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] - ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] - ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] - enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"] - ActiveRecord::Base.clear_active_connections! - `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}` - `createdb #{enc_option} -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}` + drop_database(abcs['test']) + create_database(abcs['test']) when "sqlite","sqlite3" dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] File.delete(dbfile) if File.exist?(dbfile) -- 1.5.4.3