diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-08 09:15:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-10 11:53:22 +0900 |
commit | 5025fd3a99c68f95bdd6fd43f382c62e9653236b (patch) | |
tree | 4dfbc554f4a66855b112aa971a904d2352a90c30 /activerecord/test | |
parent | 02989ee38f8cc5e82e7106ff8689d4635b016f40 (diff) | |
download | rails-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/test')
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 8b604ba930..7f9a5798dd 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -183,8 +183,10 @@ class SchemaDumperTest < ActiveRecord::TestCase def test_schema_dumps_index_columns_in_right_order index_definition = standard_dump.split(/\n/).grep(/t\.index.*company_index/).first.strip - if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter) - assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index", using: :btree', index_definition + if current_adapter?(:PostgreSQLAdapter) + assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }, using: :btree', index_definition + elsif current_adapter?(:Mysql2Adapter) + assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index", length: { type: 10 }, using: :btree', index_definition else assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index"', index_definition end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index a4756ec75a..d2fb090118 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -197,7 +197,7 @@ ActiveRecord::Schema.define do t.integer :rating, default: 1 t.integer :account_id t.string :description, default: "" - t.index [:firm_id, :type, :rating], name: "company_index" + t.index [:firm_id, :type, :rating], name: "company_index", length: { type: 10 }, order: { rating: :desc } t.index [:firm_id, :type], name: "company_partial_index", where: "rating > 10" t.index :name, name: "company_name_index", using: :btree t.index "lower(name)", name: "company_expression_index" if supports_expression_index? |