Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1051

Show
Ignore:
Timestamp:
04/02/05 01:07:33 (3 years ago)
Author:
bitsweat
Message:

Skip rake tasks which operate on db if none is configured.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/conductor/Rakefile

    r1027 r1051  
    113113task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do 
    114114  abcs = ActiveRecord::Base.configurations 
    115   case abcs["test"]["adapter"] 
    116     when  "mysql" 
     115  if abcs["test"] 
     116    case abcs["test"]["adapter"] 
     117    when "mysql" 
    117118      ActiveRecord::Base.establish_connection(:test) 
    118119      ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') 
     
    120121        ActiveRecord::Base.connection.execute(table) 
    121122      end 
    122     when "postgresql" 
     123    when "postgresql" 
    123124      `psql -U #{abcs["test"]["username"]} -h #{abcs["test"]["host"]} -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` 
    124125    when "sqlite", "sqlite3" 
     
    126127    else  
    127128      raise "Unknown database adapter '#{abcs["test"]["adapter"]}'" 
     129    end 
    128130  end 
    129131end 
     
    148150task :purge_test_database => :environment do 
    149151  abcs = ActiveRecord::Base.configurations 
    150   case abcs["test"]["adapter"] 
     152  if abcs["test"] 
     153    case abcs["test"]["adapter"] 
    151154    when "mysql" 
    152155      ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) 
     
    159162    else  
    160163      raise "Unknown database adapter '#{abcs["test"]["adapter"]}'" 
     164    end 
    161165  end 
    162166end