diff options
author | Pete Deffendol <pete@mdsc.com> | 2008-04-22 14:23:17 -0600 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-05-04 12:20:14 +1200 |
commit | 205750c8dead2449a23173fab0720b7701231d2a (patch) | |
tree | 10e133ee8db1c2e99b304ae6b0e88b178a54f7ea /railties/lib | |
parent | 96980bd561d79824b6cb6efbcbecdcbf8785d452 (diff) | |
download | rails-205750c8dead2449a23173fab0720b7701231d2a.tar.gz rails-205750c8dead2449a23173fab0720b7701231d2a.tar.bz2 rails-205750c8dead2449a23173fab0720b7701231d2a.zip |
PostgreSQL: Connect to template1 database when creating or dropping db
* The template1 database is always available on a PostgreSQL install
* The previous behavior expected a database with the same name as the
connecting user, which may not be available
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#38 state:resolved]
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/tasks/databases.rake | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index e39f9ca197..20fdcce205 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -45,7 +45,7 @@ namespace :db do when 'postgresql' @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) + ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) ActiveRecord::Base.connection.create_database(config['database'], :encoding => @encoding) ActiveRecord::Base.establish_connection(config) rescue @@ -373,7 +373,7 @@ def drop_database(config) when /^sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) when 'postgresql' - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) + ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) ActiveRecord::Base.connection.drop_database config['database'] end end |