diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 14:41:26 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-20 14:41:26 +0000 |
commit | f22b000546301b0f87c5074b21552b77b7b2f98a (patch) | |
tree | 058abfaf9922c1ed1b3671aac5edd360a4914ef7 | |
parent | 1b40f051e7802a0235a777edb29f14230f89e43a (diff) | |
download | rails-f22b000546301b0f87c5074b21552b77b7b2f98a.tar.gz rails-f22b000546301b0f87c5074b21552b77b7b2f98a.tar.bz2 rails-f22b000546301b0f87c5074b21552b77b7b2f98a.zip |
Fixed the Rakefile's interaction with postgresql use PGPASSWORD and PGHOST in the environment to fix prompting for passwords when connecting to a remote db and local socket connections. Also added a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@931 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rwxr-xr-x | railties/fresh_rakefile | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 4c197ae8c3..9c4ef1823e 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed the Rakefile's interaction with postgresql use PGPASSWORD and PGHOST in the environment to fix prompting for passwords when connecting to a remote db and local socket connections. Also added a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik] + * Fixed the Rakefile's interaction with postgresql to quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson] diff --git a/railties/fresh_rakefile b/railties/fresh_rakefile index e503f236fd..40878d3e71 100755 --- a/railties/fresh_rakefile +++ b/railties/fresh_rakefile @@ -119,8 +119,10 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| ActiveRecord::Base.connection.execute(table) end - when "postgresql" - `psql -U "#{abcs["test"]["username"]}" -h #{abcs["test"]["host"]} -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` + when "postgresql" + ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] + ENV['PGPASSWORD'] = abcs["test"]["password"] + `psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` when "sqlite", "sqlite3" `#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql` else @@ -135,8 +137,10 @@ task :db_structure_dump => :environment do when "mysql" ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } - when "postgresql" - `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -h #{abcs[RAILS_ENV]["host"]} -s -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}` + when "postgresql" + ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"] + ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"] + `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}` when "sqlite", "sqlite3" `#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql` else @@ -152,8 +156,10 @@ task :purge_test_database => :environment do ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"]) when "postgresql" - `dropdb -U "#{abcs["test"]["username"]}" -h #{abcs["test"]["host"]} #{abcs["test"]["database"]}` - `createdb -T template0 -U "#{abcs["test"]["username"]}" -h #{abcs["test"]["host"]} #{abcs["test"]["database"]}` + ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] + ENV['PGPASSWORD'] = abcs["test"]["password"] + `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}` + `createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}` when "sqlite","sqlite3" File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"]) else |