Permalink
Browse files

Add PostgreSQL support for db:shell

  • Loading branch information...
1 parent 10807cb commit 76fa7ce6c2bca7faedde5ca00ada10d62cb7486b Danil Pismenny committed with mjankowski Sep 22, 2010
Showing with 10 additions and 3 deletions.
  1. +10 −3 tasks/db/shell.rake
View
@@ -13,11 +13,18 @@ namespace :db do
command << "--password=#{config['password'] || ''} "
command << config['database']
when 'postgresql'
- puts 'You should consider switching to MySQL or get off your butt and submit a patch'
+ command << "psql "
+ command << "-h #{config['host']} " unless config['host'].blank?
+ command << "-p #{config['port']} " unless config['port'].blank?
+ command << "-U #{config['username']} " unless config['username'].blank?
+ if config['password'].blank?
+ command << "#{config['database']}"
+ else
+ command << "\"dbname=#{config['database']} password=#{config['password']}\""
+ end
else
command << "echo Unsupported database adapter: #{config['adapter']}"
end
-
system command
end
-end
+end

0 comments on commit 76fa7ce

Please sign in to comment.