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

Ticket #11592: fix_11592_migrations_broken_on_clean_db.git.patch

File fix_11592_migrations_broken_on_clean_db.git.patch, 2.1 kB (added by ian.w.white@gmail.com, 3 months ago)
  • a/activerecord/lib/active_record/migration.rb

    old new  
    364364      end 
    365365 
    366366      def current_version 
    367         Base.connection.select_values( 
    368           "SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max || 0 
     367        version = Base.connection.select_values( 
     368          "SELECT version FROM #{schema_migrations_table_name}").map(&:to_i).max rescue nil 
     369        version || 0 
    369370      end 
    370371 
    371372      def proper_table_name(name) 
  • a/activerecord/test/cases/migration_test.rb

    old new  
    812812        ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/interleaved/pass_3") 
    813813      end 
    814814    end 
    815  
     815     
     816    def test_migrator_db_has_no_schema_migrations_table 
     817      ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations;") 
     818      assert_nothing_raised do 
     819        ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid", 1) 
     820      end 
     821    end 
     822     
    816823    def test_migrator_verbosity 
    817824      ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid", 1) 
    818825      assert PeopleHaveLastNames.message_count > 0 
     
    10101017      end 
    10111018 
    10121019  end 
    1013  
     1020   
    10141021  uses_mocha 'Sexy migration tests' do 
    10151022    class SexyMigrationsTest < ActiveRecord::TestCase 
    10161023      def test_references_column_type_adds_id