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

Changeset 8324

Show
Ignore:
Timestamp:
12/06/07 18:57:19 (2 years ago)
Author:
bitsweat
Message:

The test task stops with a warning if you have pending migrations. Closes #10377.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/migration.rb

    r8129 r8324  
    351351    end 
    352352 
     353    def pending_migrations 
     354      migration_classes.select { |m| m.version > current_version } 
     355    end 
     356 
    353357    private 
    354358      def migration_classes 
  • trunk/railties/CHANGELOG

    r8321 r8324  
    11*2.0.0* (December 6th, 2007) 
     2 
     3* The test task stops with a warning if you have pending migrations.  #10377 [Josh Knowles] 
    24 
    35* Add warning to documentation about using transactional fixtures when the code under test uses transactions itself. Closes #7548 [thijsv] 
  • trunk/railties/lib/tasks/databases.rake

    r8248 r8324  
    124124  task :version => :environment do 
    125125    puts "Current version: #{ActiveRecord::Migrator.current_version}" 
     126  end 
     127 
     128  desc "Raises an error if there are pending migrations" 
     129  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." 
     138    end 
    126139  end 
    127140 
     
    291304 
    292305    desc 'Prepare the test database and load the schema' 
    293     task :prepare => :environment do 
     306    task :prepare => %w(environment db:abort_if_pending_migrations) do 
    294307      if defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? 
    295308        Rake::Task[{ :sql  => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke