aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/schema_dumper.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-10-08 09:15:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-10-10 11:53:22 +0900
commit5025fd3a99c68f95bdd6fd43f382c62e9653236b (patch)
tree4dfbc554f4a66855b112aa971a904d2352a90c30 /activerecord/lib/active_record/schema_dumper.rb
parent02989ee38f8cc5e82e7106ff8689d4635b016f40 (diff)
downloadrails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.tar.gz
rails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.tar.bz2
rails-5025fd3a99c68f95bdd6fd43f382c62e9653236b.zip
Dump index options to pretty format
```ruby # Before t.index ["firm_id", "type", "rating"], name: "company_index", order: {"rating"=>:desc}, using: :btree # After t.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree ```
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 41fed004a0..fc28ac7cb0 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -192,12 +192,8 @@ HEADER
"name: #{index.name.inspect}",
]
index_parts << "unique: true" if index.unique
-
- index_lengths = (index.lengths || []).compact
- index_parts << "length: #{Hash[index.columns.zip(index.lengths)].inspect}" if index_lengths.any?
-
- index_orders = index.orders || {}
- index_parts << "order: #{index.orders.inspect}" if index_orders.any?
+ index_parts << "length: { #{format_options(index.lengths)} }" if index.lengths.present?
+ index_parts << "order: { #{format_options(index.orders)} }" if index.orders.present?
index_parts << "where: #{index.where.inspect}" if index.where
index_parts << "using: #{index.using.inspect}" if index.using
index_parts << "type: #{index.type.inspect}" if index.type