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

Changeset 4768

Show
Ignore:
Timestamp:
08/15/06 23:51:27 (2 years ago)
Author:
bitsweat
Message:

Make indexed columns easy to extract from the index name. Oracle users should explicitly assign index names due to field length restrictions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb

    r4767 r4768  
    215215        if Hash === options # legacy support 
    216216          if options[:column] 
    217             "#{table_name}_#{Array(options[:column]).join('_')}_index
     217            "index_#{table_name}_on_#{Array(options[:column]) * '_and_'}
    218218          elsif options[:name] 
    219219            options[:name] 
  • trunk/activerecord/test/migration_test.rb

    r4767 r4768  
    5858      assert_nothing_raised { Person.connection.remove_index("people", "last_name") } 
    5959 
    60       assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
    61       assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } 
    62       assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
    63       assert_nothing_raised { Person.connection.remove_index("people", :name => "people_last_name_first_name_index") } 
    64       assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
    65       assert_nothing_raised { Person.connection.remove_index("people", "last_name_first_name") } 
    66       assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
    67       assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } 
     60      # Orcl nds shrt indx nms. 
     61      unless current_adapter?(:OracleAdapter) 
     62        assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
     63        assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } 
     64        assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
     65        assert_nothing_raised { Person.connection.remove_index("people", :name => "index_people_on_last_name_and_first_name") } 
     66        assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
     67        assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } 
     68        assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } 
     69        assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } 
     70      end 
    6871 
    6972      # quoting