mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure indices don't flip order in schema.rb [#1266 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
This commit is contained in:
parent
7418d367f0
commit
a9e8168432
2 changed files with 14 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
*2.2.1 [RC2 or 2.2 final]*
|
||||
|
||||
* Ensure indices don't flip order in schema.rb #1266 [Jordi Bunster]
|
||||
|
||||
* Fixed that serialized strings should never be type-casted (i.e. turning "Yes" to a boolean) #857 [Andreas Korth]
|
||||
|
||||
|
||||
|
|
|
@ -159,13 +159,19 @@ HEADER
|
|||
end
|
||||
|
||||
def indexes(table, stream)
|
||||
indexes = @connection.indexes(table)
|
||||
indexes.each do |index|
|
||||
stream.print " add_index #{index.table.inspect}, #{index.columns.inspect}, :name => #{index.name.inspect}"
|
||||
stream.print ", :unique => true" if index.unique
|
||||
if (indexes = @connection.indexes(table)).any?
|
||||
add_index_statements = indexes.map do |index|
|
||||
statment_parts = [ ('add_index ' + index.table.inspect) ]
|
||||
statment_parts << index.columns.inspect
|
||||
statment_parts << (':name => ' + index.name.inspect)
|
||||
statment_parts << ':unique => true' if index.unique
|
||||
|
||||
' ' + statment_parts.join(', ')
|
||||
end
|
||||
|
||||
stream.puts add_index_statements.sort.join("\n")
|
||||
stream.puts
|
||||
end
|
||||
stream.puts unless indexes.empty?
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue