Skip to content

Commit

Permalink
Fixed the Rakefile's interaction with postgresql to quote the user na…
Browse files Browse the repository at this point in the history
…me and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@929 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Mar 20, 2005
1 parent dabf906 commit 58bf8f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions railties/CHANGELOG
@@ -1,3 +1,8 @@
*SVN*

* 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]


*0.10.1* (7th March, 2005) *0.10.1* (7th March, 2005)


* Fixed rake stats to ignore editor backup files like model.rb~ #791 [skanthak] * Fixed rake stats to ignore editor backup files like model.rb~ #791 [skanthak]
Expand Down
8 changes: 4 additions & 4 deletions railties/fresh_rakefile
Expand Up @@ -120,7 +120,7 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
ActiveRecord::Base.connection.execute(table) ActiveRecord::Base.connection.execute(table)
end end
when "postgresql" when "postgresql"
`psql -U #{abcs["test"]["username"]} -h #{abcs["test"]["host"]} -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` `psql -U "#{abcs["test"]["username"]}" -h #{abcs["test"]["host"]} -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
when "sqlite", "sqlite3" when "sqlite", "sqlite3"
`#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql` `#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
else else
Expand All @@ -136,7 +136,7 @@ task :db_structure_dump => :environment do
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
when "postgresql" 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"]}` `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -h #{abcs[RAILS_ENV]["host"]} -s -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
when "sqlite", "sqlite3" when "sqlite", "sqlite3"
`#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql` `#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
else else
Expand All @@ -152,8 +152,8 @@ task :purge_test_database => :environment do
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"]) ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
when "postgresql" when "postgresql"
`dropdb -U #{abcs["test"]["username"]} -h #{abcs["test"]["host"]} #{abcs["test"]["database"]}` `dropdb -U "#{abcs["test"]["username"]}" -h #{abcs["test"]["host"]} #{abcs["test"]["database"]}`
`createdb -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"]}`
when "sqlite","sqlite3" when "sqlite","sqlite3"
File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"]) File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
else else
Expand Down

0 comments on commit 58bf8f4

Please sign in to comment.