Permalink
Browse files

Re-factored database.rake to allow Jdbcpostgresql. #jruby

  • Loading branch information...
1 parent 4ce14fb commit c8102817ca0d355ece8b60007d230ab9292e7031 @arunagw arunagw committed Apr 26, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 activerecord/lib/active_record/railties/databases.rake
@@ -244,7 +244,7 @@ db_namespace = namespace :db do
when /mysql/
ActiveRecord::Base.establish_connection(config)
puts ActiveRecord::Base.connection.charset
- when 'postgresql'
+ when /postgresql/
ActiveRecord::Base.establish_connection(config)
puts ActiveRecord::Base.connection.encoding
when 'sqlite3'
@@ -362,7 +362,7 @@ db_namespace = namespace :db do
when /mysql/, "oci", "oracle"
ActiveRecord::Base.establish_connection(abcs[Rails.env])
File.open("#{Rails.root}/db/#{Rails.env}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
- when "postgresql"
+ when /postgresql/
ENV['PGHOST'] = abcs[Rails.env]["host"] if abcs[Rails.env]["host"]
ENV['PGPORT'] = abcs[Rails.env]["port"].to_s if abcs[Rails.env]["port"]
ENV['PGPASSWORD'] = abcs[Rails.env]["password"].to_s if abcs[Rails.env]["password"]
@@ -413,7 +413,7 @@ db_namespace = namespace :db do
IO.readlines("#{Rails.root}/db/#{Rails.env}_structure.sql").join.split("\n\n").each do |table|
ActiveRecord::Base.connection.execute(table)
end
- when "postgresql"
+ when /postgresql/
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
@@ -444,7 +444,7 @@ db_namespace = namespace :db do
when /mysql/
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
- when "postgresql"
+ when /postgresql/
ActiveRecord::Base.clear_active_connections!
drop_database(abcs['test'])
create_database(abcs['test'])
@@ -534,7 +534,7 @@ def drop_database(config)
file = path.absolute? ? path.to_s : File.join(Rails.root, path)
FileUtils.rm(file)
- when 'postgresql'
+ when /postgresql/
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
ActiveRecord::Base.connection.drop_database config['database']
end

0 comments on commit c810281

Please sign in to comment.