Changeset 1270

Show
Ignore:
Timestamp:
01/10/08 13:48:32 (9 months ago)
Author:
in..@loobmedia.com
Message:

Merb.environment is now set correctly for Rake, db:migrate now loads the correct environment settings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/merb_activerecord/lib/merb/orms/active_record/tasks/databases.rb

    r1247 r1270  
    11task :environment do 
    2  Merb.environment = ( ENV['Merb.environment'] || Merb.environment ).to_sym 
     2 Merb.environment = ( ENV['MERB_ENV'] || Merb.environment ).to_sym 
    33end 
    44 
     
    3333            ActiveRecord::Base.connection.create_database(config[:database]) #, {:charset => @charset, :collation => @collation}) 
    3434            ActiveRecord::Base.establish_connection(config) 
    35             p "MySQL #{config[:database]} database succesfully created" 
     35            puts "MySQL #{config[:database]} database succesfully created" 
    3636          rescue 
    3737            $stderr.puts "Couldn't create database for #{config.inspect}" 
     
    4545        end 
    4646      else 
    47         p "#{config[:database]} already exists" 
     47        puts "#{config[:database]} already exists" 
    4848      end 
    4949    else 
    50       p "This task only creates local databases. #{config[:database]} is on a remote host." 
     50      puts "This task only creates local databases. #{config[:database]} is on a remote host." 
    5151    end 
    5252  end 
     
    5555  task :drop => :environment do 
    5656    config = ActiveRecord::Base.configurations[Merb.environment || :development] 
    57     p config 
    5857    case config[:adapter] 
    5958    when 'mysql' 
     
    6867  desc "Migrate the database through scripts in schema/migrations. Target specific version with VERSION=x" 
    6968  task :migrate => :environment do 
     69    config = ActiveRecord::Base.configurations[Merb.environment || :development] 
     70    ActiveRecord::Base.establish_connection(config) 
    7071    ActiveRecord::Migrator.migrate("schema/migrations/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) 
    7172    Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby