resync from rails_port 11795:12304
[rails.git] / vendor / gems / composite_primary_keys-1.1.0 / lib / composite_primary_keys / migration.rb
1 ActiveRecord::ConnectionAdapters::ColumnDefinition.send(:alias_method, :to_s_without_composite_keys, :to_s)
2
3 ActiveRecord::ConnectionAdapters::ColumnDefinition.class_eval <<-'EOF'
4   def to_s
5     if name.is_a? Array
6       "PRIMARY KEY (#{name.join(',')})"
7     else
8       to_s_without_composite_keys
9     end
10   end
11 EOF
12
13 ActiveRecord::ConnectionAdapters::TableDefinition.class_eval <<-'EOF'
14   def [](name)
15     @columns.find { |column|
16       !column.name.is_a?(Array) && column.name.to_s == name.to_s
17     }
18   end
19 EOF
20