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

Changeset 8338

Show
Ignore:
Timestamp:
12/09/07 04:18:28 (9 months ago)
Author:
bitsweat
Message:

Don't check for pending migrations if Active Record isn't loaded

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/lib/tasks/databases.rake

    r8324 r8338  
    128128  desc "Raises an error if there are pending migrations" 
    129129  task :abort_if_pending_migrations => :environment do 
    130     pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations 
    131  
    132     if pending_migrations.any? 
    133       puts "You have #{pending_migrations.size} pending migrations:" 
    134       pending_migrations.each do |pending_migration| 
    135         puts '  %4d %s' % [pending_migration.version, pending_migration.name] 
    136       end 
    137       abort "Run `rake db:migrate` to update your database then try again." 
     130    if defined? ActiveRecord 
     131      pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations 
     132 
     133      if pending_migrations.any? 
     134        puts "You have #{pending_migrations.size} pending migrations:" 
     135        pending_migrations.each do |pending_migration| 
     136          puts '  %4d %s' % [pending_migration.version, pending_migration.name] 
     137        end 
     138        abort "Run `rake db:migrate` to update your database then try again." 
     139      end 
    138140    end 
    139141  end 
     
    305307    desc 'Prepare the test database and load the schema' 
    306308    task :prepare => %w(environment db:abort_if_pending_migrations) do 
    307       if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? 
     309      if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? 
    308310        Rake::Task[{ :sql  => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke 
    309311      end