Commit 31f0d524 by Alex Chaffee

Merge branch 'master' of github.com:ctran/annotate_models

Conflicts: lib/annotate/annotate_models.rb
parents 7e2cd422 18cd39ad
...@@ -9,3 +9,4 @@ Gemfile.lock ...@@ -9,3 +9,4 @@ Gemfile.lock
*.gem *.gem
/.idea/ /.idea/
.rvmrc .rvmrc
.bundle
...@@ -139,9 +139,8 @@ module AnnotateModels ...@@ -139,9 +139,8 @@ module AnnotateModels
indexes = klass.connection.indexes(klass.table_name) indexes = klass.connection.indexes(klass.table_name)
return "" if indexes.empty? return "" if indexes.empty?
max_size = indexes.collect{|index| index.name.size}.max || 0 max_size = indexes.collect{|index| index.name.size}.max + 1
max_size += 1 indexes.sort_by{|index| index.name}.each do |index|
indexes.each do |index|
index_info << sprintf("# %-#{max_size}.#{max_size}s %s %s", index.name, "(#{index.columns.join(",")})", index.unique ? "UNIQUE" : "").rstrip + "\n" index_info << sprintf("# %-#{max_size}.#{max_size}s %s %s", index.name, "(#{index.columns.join(",")})", index.unique ? "UNIQUE" : "").rstrip + "\n"
end end
return index_info return index_info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment