]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/composite_primary_keys-1.1.0/tasks/databases/postgresql.rake
resync from rails_port 11795:12304
[rails.git] / vendor / gems / composite_primary_keys-1.1.0 / tasks / databases / postgresql.rake
1 namespace :postgresql do
2   desc 'Build the PostgreSQL test databases'
3   task :build_databases => :load_connection do 
4     sh %{ createdb "#{GEM_NAME}_unittest" }
5     sh %{ psql "#{GEM_NAME}_unittest" -f #{File.join(SCHEMA_PATH, 'postgresql.sql')} }
6   end
7
8   desc 'Drop the PostgreSQL test databases'
9   task :drop_databases => :load_connection do 
10     sh %{ dropdb "#{GEM_NAME}_unittest" }
11   end
12
13   desc 'Rebuild the PostgreSQL test databases'
14   task :rebuild_databases => [:drop_databases, :build_databases]
15
16   task :load_connection do
17     require File.join(PROJECT_ROOT, %w[lib adapter_helper postgresql])
18     spec = AdapterHelper::Postgresql.load_connection_from_env
19     options = {}
20     options['u'] = spec[:username]  if spec[:username]
21     options['p'] = spec[:password]  if spec[:password]
22     options_str = options.map { |key, value| "-#{key}#{value}" }.join(" ")
23     ENV['cpk_adapter_options_str'] = options_str
24   end
25 end
26