public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
PostgreSQL: update rake tasks to use full settings from database.yml

Signed-off-by: Michael Koziarski <michael@koziarski.com>
fragility (author)
Sat May 03 20:41:10 -0700 2008
NZKoz (committer)
Sat May 03 20:59:34 -0700 2008
commit  c26d10563eaa29961ae895a9fbe3afae7d24a9b1
tree    ee66087f52201971914285aafcc8c3bdafaae89d
parent  6a6b4392c16c665eb713705f2b38e959a658eeef
...
46
47
48
49
 
50
51
52
...
314
315
316
317
318
319
320
321
322
323
324
 
 
325
326
327
...
46
47
48
 
49
50
51
52
...
314
315
316
 
 
 
 
 
317
 
 
318
319
320
321
322
0
@@ -46,7 +46,7 @@ namespace :db do
0
         @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
0
         begin
0
           ActiveRecord::Base.establish_connection(config.merge('database' => 'template1'))
0
-          ActiveRecord::Base.connection.create_database(config['database'], :encoding => @encoding)
0
+          ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
0
           ActiveRecord::Base.establish_connection(config)
0
         rescue
0
           $stderr.puts $!, *($!.backtrace)
0
@@ -314,14 +314,9 @@ namespace :db do
0
         ActiveRecord::Base.establish_connection(:test)
0
         ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
0
       when "postgresql"
0
-        ENV['PGHOST']     = abcs["test"]["host"] if abcs["test"]["host"]
0
-        ENV['PGPORT']     = abcs["test"]["port"].to_s if abcs["test"]["port"]
0
-        ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
0
-        enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"]
0
-
0
         ActiveRecord::Base.clear_active_connections!
0
-        `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
0
-        `createdb #{enc_option} -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
0
+        drop_database(abcs['test'])
0
+        create_database(abcs['test'])
0
       when "sqlite","sqlite3"
0
         dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
0
         File.delete(dbfile) if File.exist?(dbfile)

Comments

eagleas Thu May 08 02:53:59 -0700 2008

After this commit I see in db:test:purge, drop_database on configuration with schema_search_path broken: rake aborted! PGError: ERROR: schema “my_schema” does not exist : SET search_path TO my_schema

eagleas Thu May 08 04:07:58 -0700 2008

For fix:

- vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb + vendor.patched/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @ -856,7 +856,7 @ module ActiveRecord end end self.client_min_messages = @config[:min_messages] if @config[:min_messages] - self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] + self.schema_search_path = @config[:schema_search_path] || @config[:schema_order] unless @config[:database] == ‘template1’ end

  1. Returns the current ID of a table’s sequence.
eagleas Thu May 08 05:16:55 -0700 2008

Oh, sorry… It’s patch. :( In short: activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:856 add “unless @config[:database] == ‘template1’”