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

Ticket #3707: better_init_scheme_info_errors.diff

File better_init_scheme_info_errors.diff, 1.2 kB (added by pezra@barelyenough.org, 2 years ago)

Change that allows any actual errors that occur while creating schema_info to be displayed to the user. No unit tests because I could not think of any reasonable way to write such a test.

  • activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

    old new  
    221221      def structure_dump 
    222222      end 
    223223 
    224       # Should not be called normally, but this operation is non-destructive. 
     224      # Creates the schema_info table in preparation for using  
     225      # ActiveRecord::Migration. Obviously, this should not be  
     226      # called normally, but this operation is non-destructive. 
    225227      # The migrations module handles this automatically. 
    226228      def initialize_schema_information 
    227229        begin 
     230          execute "SELECT COUNT(*) from #{ActiveRecord::Migrator.schema_info_table_name}" 
     231        rescue ActiveRecord::StatementInvalid 
    228232          execute "CREATE TABLE #{ActiveRecord::Migrator.schema_info_table_name} (version #{type_to_sql(:integer)})" 
    229233          execute "INSERT INTO #{ActiveRecord::Migrator.schema_info_table_name} (version) VALUES(0)" 
    230         rescue ActiveRecord::StatementInvalid 
    231           # Schema has been intialized 
    232234        end 
    233235      end 
    234236