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

Ticket #5470: migration_into_transactions.4485.diff

File migration_into_transactions.4485.diff, 0.9 kB (added by divoxx@gmail.com, 2 years ago)
  • activerecord/lib/active_record/migration.rb

    old new  
    329329        next if irrelevant_migration?(version) 
    330330 
    331331        Base.logger.info "Migrating to #{migration_class} (#{version})" 
    332         migration_class.migrate(@direction) 
    333         set_schema_version(version) 
     332        begin 
     333          Base.transaction do 
     334            migration_class.migrate(@direction) 
     335            set_schema_version(version) 
     336          end 
     337        rescue => e  
     338          raise( 
     339            "An error has ocurred. In order to make a migration atomic and keep the consistency between versions," +  
     340            "this and all the later migrations were cancelled:\n\n" + 
     341            "#{e}") 
     342          EOF 
     343          break unless @direction == :down 
     344        end 
    334345      end 
    335346    end 
    336347